예제 #1
0
        public static DicomDataset CreateRandomInstanceDataset(PatientInstance pI)
        {
            EnsureArg.IsNotNull(pI, nameof(pI));

            var      rand      = new Random();
            DateTime studyTime = DateTime.Parse(pI.PerformedProcedureStepStartDate).AddMinutes(-10);
            var      dicomTime = studyTime.ToString("HHmmss.fffff");

            var procedureDate      = studyTime.ToString("yyyyMMdd");
            var dicomProcedureTime = studyTime.ToString("HHmmss.fffff");

            var    age      = int.Parse(pI.PatientAge);
            string dicomAge = age.ToString().PadLeft(3, '0') + "Y";

            var occupation = pI.PatientOccupation.Length > 16 ? pI.PatientOccupation.Substring(0, 16) : pI.PatientOccupation;
            var laterality = new List <string> {
                "R", "L"
            };

            var physicianName = pI.PhysicianName.Split()[0] + "^" + pI.PhysicianName.Split()[1];
            var name          = pI.Name.Split()[0] + "^" + pI.Name.Split()[1];

            var ds = new DicomDataset(DicomTransferSyntax.ExplicitVRLittleEndian)
            {
                { DicomTag.StudyInstanceUID, pI.StudyUid ?? TestUidGenerator.Generate() },
                { DicomTag.SeriesInstanceUID, pI.SeriesUid ?? TestUidGenerator.Generate() },
                { DicomTag.SOPInstanceUID, pI.InstanceUid ?? TestUidGenerator.Generate() },
                { DicomTag.SOPClassUID, TestUidGenerator.Generate() },
                { DicomTag.BitsAllocated, (ushort)8 },
                { DicomTag.PhotometricInterpretation, PhotometricInterpretation.Monochrome2.Value },
                { DicomTag.PatientID, pI.PatientId ?? TestUidGenerator.Generate() },
                { DicomTag.SpecificCharacterSet, "ISO_IR 100" },
                { DicomTag.StudyDate, procedureDate },
                { DicomTag.SeriesDate, procedureDate },
                { DicomTag.StudyTime, dicomTime },
                { DicomTag.SeriesTime, dicomTime },
                { DicomTag.AccessionNumber, pI.AccessionNumber },
                { DicomTag.InstanceAvailability, "ONLINE" },
                { DicomTag.Modality, pI.Modality },
                { DicomTag.StudyDescription, pI.StudyDescription },
                { DicomTag.SeriesDescription, pI.StudyDescription },
                { DicomTag.NameOfPhysiciansReadingStudy, physicianName },
                { DicomTag.ReferringPhysicianName, physicianName },
                { DicomTag.PatientName, name },
                { DicomTag.PatientBirthDate, pI.PatientBirthDate },
                { DicomTag.PatientSex, pI.PatientSex },
                { DicomTag.PatientAge, dicomAge },
                { DicomTag.PatientWeight, pI.PatientWeight },
                { DicomTag.Occupation, occupation },
                { DicomTag.StudyID, rand.Next(10000000, 100000000).ToString() },
                { DicomTag.SeriesNumber, pI.SeriesIndex },
                { DicomTag.InstanceNumber, pI.InstanceIndex },
                { DicomTag.Laterality, laterality.RandomElement() },
                { DicomTag.PerformedProcedureStepStartDate, procedureDate },
                { DicomTag.PerformedProcedureStepStartTime, dicomProcedureTime },
            };

            return(ds);
        }
예제 #2
0
        public static DicomFile CreateRandomDicomFileWithPixelData(
            PatientInstance pI,
            int rows    = 50,
            int columns = 50,
            int frames  = 1)
        {
            var result = new DicomFile(CreateRandomInstanceDataset(pI));

            AppendRandomPixelData(rows, columns, frames, result);
            return(result);
        }