Exemplo n.º 1
0
        public DicomFile Build(StudyBuilder study, SeriesBuilder series)
        {
            var file    = new DicomFile();
            var dataset = file.DataSet;

            if (study != null)
            {
                dataset.SaveDicomFields(study);
            }
            if (series != null)
            {
                dataset.SaveDicomFields(series);
            }

            dataset.SaveDicomFields(this);

            dataset[DicomTags.SopInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);

            dataset[DicomTags.PixelSpacing].SetStringValue(string.Format(@"{0}\{1}", 0.5, 0.5));
            dataset[DicomTags.PhotometricInterpretation].SetStringValue("MONOCHROME2");
            dataset[DicomTags.SamplesPerPixel].SetInt32(0, 1);
            dataset[DicomTags.BitsStored].SetInt32(0, 16);
            dataset[DicomTags.BitsAllocated].SetInt32(0, 16);
            dataset[DicomTags.HighBit].SetInt32(0, 15);
            dataset[DicomTags.PixelRepresentation].SetInt32(0, 1);
            dataset[DicomTags.Rows].SetInt32(0, 10);
            dataset[DicomTags.Columns].SetInt32(0, 10);

            CreatePixelData(dataset);

            SetupMetaInfo(file);
            file.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian;

            return(file);
        }
Exemplo n.º 2
0
        public static SeriesBuilder CreateDigitalMammoSeriesBuilder(string seriesDescription, int seriesNumber, bool forProcessing)
        {
            var series = new SeriesBuilder
            {
                Modality          = "MG",
                SeriesDescription = seriesDescription,
                SeriesNumber      = seriesNumber
            };

            var sopClass = forProcessing
                               ? SopClass.DigitalMammographyXRayImageStorageForProcessingUid
                               : SopClass.DigitalMammographyXRayImageStorageForPresentationUid;

            var presentationIntentType = forProcessing ? "FOR PROCESSING" : "FOR PRESENTATION";

            series.Images = new List <ImageBuilder>
            {
                new ImageBuilder {
                    ImageLaterality = "L", ViewPosition = "MLO", InstanceNumber = 1, SopClassUid = sopClass, PresentationIntentType = presentationIntentType
                },
                new ImageBuilder {
                    ImageLaterality = "L", ViewPosition = "CC", InstanceNumber = 2, SopClassUid = sopClass, PresentationIntentType = presentationIntentType
                },
                new ImageBuilder {
                    ImageLaterality = "R", ViewPosition = "MLO", InstanceNumber = 3, SopClassUid = sopClass, PresentationIntentType = presentationIntentType
                },
                new ImageBuilder {
                    ImageLaterality = "R", ViewPosition = "CC", InstanceNumber = 4, SopClassUid = sopClass, PresentationIntentType = presentationIntentType
                }
            };
            return(series);
        }
Exemplo n.º 3
0
        public static SeriesBuilder CreateDigitalMammoSeriesBuilder(string seriesDescription, int seriesNumber, bool forProcessing)
        {
            var series = new SeriesBuilder
            {
                Modality = "MG",
                SeriesDescription = seriesDescription,
                SeriesNumber = seriesNumber
            };

            var sopClass = forProcessing
                               ? SopClass.DigitalMammographyXRayImageStorageForProcessingUid
                               : SopClass.DigitalMammographyXRayImageStorageForPresentationUid;

            var presentationIntentType = forProcessing ? "FOR PROCESSING" : "FOR PRESENTATION";
            series.Images = new List<ImageBuilder>
                                    {
                                        new ImageBuilder {ImageLaterality = "L", ViewPosition = "MLO", InstanceNumber = 1, SopClassUid = sopClass, PresentationIntentType = presentationIntentType },
                                        new ImageBuilder {ImageLaterality = "L", ViewPosition = "CC", InstanceNumber = 2, SopClassUid = sopClass , PresentationIntentType = presentationIntentType },
                                        new ImageBuilder {ImageLaterality = "R", ViewPosition = "MLO", InstanceNumber = 3, SopClassUid = sopClass , PresentationIntentType = presentationIntentType },
                                        new ImageBuilder {ImageLaterality = "R", ViewPosition = "CC", InstanceNumber = 4, SopClassUid = sopClass , PresentationIntentType = presentationIntentType }
                                    };
            return series;
        }
Exemplo n.º 4
0
        public DicomFile Build(StudyBuilder study, SeriesBuilder series)
        {
            var file = new DicomFile();
            var dataset = file.DataSet;

            if (study != null)
                dataset.SaveDicomFields(study);
            if (series != null)
                dataset.SaveDicomFields(series);

            dataset.SaveDicomFields(this);

            dataset[DicomTags.SopInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);

            dataset[DicomTags.PixelSpacing].SetStringValue(string.Format(@"{0}\{1}", 0.5, 0.5));
            dataset[DicomTags.PhotometricInterpretation].SetStringValue("MONOCHROME2");
            dataset[DicomTags.SamplesPerPixel].SetInt32(0, 1);
            dataset[DicomTags.BitsStored].SetInt32(0, 16);
            dataset[DicomTags.BitsAllocated].SetInt32(0, 16);
            dataset[DicomTags.HighBit].SetInt32(0, 15);
            dataset[DicomTags.PixelRepresentation].SetInt32(0, 1);
            dataset[DicomTags.Rows].SetInt32(0, 10);
            dataset[DicomTags.Columns].SetInt32(0, 10);

            CreatePixelData(dataset);

            SetupMetaInfo(file);
            file.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian;

            return file;
        }
Exemplo n.º 5
0
        public static StudyBuilder CreateMixedMultiframeUltrasound
        (
            string patientId,
            string patientsName,
            string studyDescription,
            string studyInstanceUid,
            int seriesNumber,
            string seriesDescription,
            int numberSingleImages,
            int numberMultiframes,
            bool createSeriesDisplaySet,
            bool createSingleImageDisplaySets
        )
        {
            var studyBuilder = new StudyBuilder
            {
                PatientId        = patientId,
                PatientsName     = patientsName,
                StudyDescription = studyDescription,
                StudyInstanceUid = studyInstanceUid
            };

            if (numberMultiframes <= 0 && numberSingleImages <= 0)
            {
                throw new ArgumentException();
            }

            SeriesBuilder seriesBuilder;

            studyBuilder.Series.Add(seriesBuilder = new SeriesBuilder
            {
                SeriesDescription = seriesDescription,
                Modality          = "US",
                SeriesNumber      = seriesNumber
            });

            int instanceNumber = 1;

            for (int i = 0; i < numberSingleImages; i++, instanceNumber++)
            {
                seriesBuilder.Images.Add(new ImageBuilder
                {
                    InstanceNumber = instanceNumber,
                    SopClassUid    = SopClass.UltrasoundImageStorageUid
                });
            }

            for (int i = 0; i < numberMultiframes; i++, instanceNumber++)
            {
                seriesBuilder.Images.Add(new ImageBuilder
                {
                    InstanceNumber = instanceNumber,
                    NumberOfFrames = 3,
                    SopClassUid    = SopClass.UltrasoundMultiFrameImageStorageUid
                });
            }

            if (createSingleImageDisplaySets)
            {
                studyBuilder.DisplaySetFactory = new BasicDisplaySetFactory {
                    CreateSingleImageDisplaySets = true
                }
            }
            ;
            //Only use the mixed multi-frame factory if it's going to work.
            else if (!createSeriesDisplaySet && (numberMultiframes > 1 || (numberMultiframes > 0 && numberSingleImages > 0)))
            {
                studyBuilder.DisplaySetFactory = new MixedMultiFrameDisplaySetFactory();
            }

            return(studyBuilder);
        }
Exemplo n.º 6
0
// ReSharper disable InconsistentNaming
        public static StudyBuilder CreateCRXRayBuilder
// ReSharper restore InconsistentNaming
        (
            string patientId,
            string patientsName,
            string studyDescription,
            string studyInstanceUid,
            string seriesDescription,
            int startSeriesNumber,
            bool oneSeries,
            bool oneImagePerSeries,
            bool createSingleImageDisplaySets
        )
        {
            if (!oneSeries && !oneImagePerSeries)
            {
                throw new ArgumentException("Multiple Series currently restricted to one image each");
            }

            var studyBuilder = new StudyBuilder
            {
                DisplaySetFactory = new BasicDisplaySetFactory {
                    CreateSingleImageDisplaySets = createSingleImageDisplaySets
                },
                PatientId        = patientId,
                PatientsName     = patientsName,
                StudyDescription = studyDescription,
                StudyInstanceUid = studyInstanceUid
            };

            var image1 = new ImageBuilder
            {
                ImageLaterality = "U",
                ViewPosition    = "AP",
                InstanceNumber  = 1,
                SopClassUid     = SopClass.ComputedRadiographyImageStorageUid
            };

            var image2 = new ImageBuilder
            {
                ImageLaterality = "U",
                ViewPosition    = "LL",
                InstanceNumber  = 1,
                SopClassUid     = SopClass.ComputedRadiographyImageStorageUid
            };

            if (oneSeries)
            {
                var seriesBuilder = new SeriesBuilder
                {
                    Modality          = "CR",
                    SeriesDescription = seriesDescription,
                    SeriesNumber      = startSeriesNumber,
                    Images            = new List <ImageBuilder> {
                        image1
                    }
                };

                if (!oneImagePerSeries)
                {
                    seriesBuilder.Images.Add(image2);
                }

                studyBuilder.Series.Add(seriesBuilder);
            }
            else
            {
                var seriesBuilder = new SeriesBuilder
                {
                    Modality          = "CR",
                    SeriesDescription = seriesDescription,
                    SeriesNumber      = startSeriesNumber,
                    Images            = new List <ImageBuilder> {
                        image1
                    }
                };

                studyBuilder.Series.Add(seriesBuilder);

                seriesBuilder = new SeriesBuilder
                {
                    Modality          = "CR",
                    SeriesDescription = seriesDescription,
                    SeriesNumber      = startSeriesNumber,
                    Images            = new List <ImageBuilder> {
                        image2
                    }
                };

                studyBuilder.Series.Add(seriesBuilder);
            }

            return(studyBuilder);
        }
Exemplo n.º 7
0
        public static StudyBuilder CreateDigitalXRayBuilder
        (
            string patientId,
            string patientsName,
            string studyDescription,
            string studyInstanceUid,
            string seriesDescription,
            int startSeriesNumber,
            bool oneSeries,
            bool oneImagePerSeries,
            bool createSingleImageDisplaySets
        )
        {
            if (!oneSeries && !oneImagePerSeries)
            {
                throw new ArgumentException("Multiple Series currently restricted to one image each");
            }

            var studyBuilder = new StudyBuilder
            {
                DisplaySetFactory = new BasicDisplaySetFactory {
                    CreateSingleImageDisplaySets = createSingleImageDisplaySets
                },
                PatientId        = patientId,
                PatientsName     = patientsName,
                StudyDescription = studyDescription,
                StudyInstanceUid = studyInstanceUid
            };

            var image1 = new ImageBuilder
            {
                ImageLaterality        = "U",
                ViewPosition           = "AP",
                InstanceNumber         = 1,
                SopClassUid            = SopClass.DigitalXRayImageStorageForPresentationUid,
                PresentationIntentType = "FOR PRESENTATION"
            };

            var image2 = new ImageBuilder
            {
                ImageLaterality        = "U",
                ViewPosition           = "LL",
                InstanceNumber         = 1,
                SopClassUid            = SopClass.DigitalXRayImageStorageForPresentationUid,
                PresentationIntentType = "FOR PRESENTATION"
            };


            if (oneSeries)
            {
                var seriesBuilder = new SeriesBuilder
                {
                    Modality          = "DX",
                    SeriesDescription = seriesDescription,
                    SeriesNumber      = startSeriesNumber,
                    Images            = new List <ImageBuilder> {
                        image1
                    }
                };

                if (!oneImagePerSeries)
                {
                    seriesBuilder.Images.Add(image2);
                }

                studyBuilder.Series.Add(seriesBuilder);
            }
            else
            {
                var seriesBuilder = new SeriesBuilder
                {
                    Modality          = "DX",
                    SeriesDescription = seriesDescription,
                    SeriesNumber      = startSeriesNumber,
                    Images            = new List <ImageBuilder> {
                        image1
                    }
                };

                studyBuilder.Series.Add(seriesBuilder);

                seriesBuilder = new SeriesBuilder
                {
                    Modality          = "DX",
                    SeriesDescription = seriesDescription,
                    SeriesNumber      = startSeriesNumber,
                    Images            = new List <ImageBuilder> {
                        image2
                    }
                };

                studyBuilder.Series.Add(seriesBuilder);
            }

            return(studyBuilder);
        }
Exemplo n.º 8
0
        public static StudyBuilder CreateMixedMultiframeUltrasound
        (
            string patientId,
            string patientsName,
            string studyDescription,
            string studyInstanceUid,
            int seriesNumber,
            string seriesDescription,
            int numberSingleImages,
            int numberMultiframes,
            bool createSeriesDisplaySet,
            bool createSingleImageDisplaySets
        )
        {
            var studyBuilder = new StudyBuilder
                       {
                           PatientId = patientId,
                           PatientsName = patientsName,
                           StudyDescription = studyDescription,
                           StudyInstanceUid = studyInstanceUid
                       };

            if (numberMultiframes <= 0 && numberSingleImages <= 0)
                throw new ArgumentException();

            SeriesBuilder seriesBuilder;
            studyBuilder.Series.Add(seriesBuilder = new SeriesBuilder
            {
                SeriesDescription = seriesDescription,
                Modality = "US",
                SeriesNumber = seriesNumber
            });

            int instanceNumber = 1;
            for (int i = 0; i < numberSingleImages; i++, instanceNumber++)
            {
                seriesBuilder.Images.Add(new ImageBuilder
                                             {
                                                 InstanceNumber = instanceNumber,
                                                 SopClassUid = SopClass.UltrasoundImageStorageUid
                                             });
            }

            for (int i = 0; i < numberMultiframes; i++, instanceNumber++)
            {
                seriesBuilder.Images.Add(new ImageBuilder
                {
                    InstanceNumber = instanceNumber,
                    NumberOfFrames = 3,
                    SopClassUid = SopClass.UltrasoundMultiFrameImageStorageUid
                });
            }

            if (createSingleImageDisplaySets)
                studyBuilder.DisplaySetFactory = new BasicDisplaySetFactory{CreateSingleImageDisplaySets = true};
            //Only use the mixed multi-frame factory if it's going to work.
            else if (!createSeriesDisplaySet && (numberMultiframes > 1 || (numberMultiframes > 0 && numberSingleImages > 0)))
                studyBuilder.DisplaySetFactory = new MixedMultiFrameDisplaySetFactory();

            return studyBuilder;
        }
Exemplo n.º 9
0
// ReSharper disable InconsistentNaming
        public static StudyBuilder CreateCRXRayBuilder
// ReSharper restore InconsistentNaming
        (
            string patientId,
            string patientsName,
            string studyDescription,
            string studyInstanceUid,
            string seriesDescription,
            int startSeriesNumber,
            bool oneSeries,
            bool oneImagePerSeries,
            bool createSingleImageDisplaySets
        )
        {
            if (!oneSeries && !oneImagePerSeries)
                throw new ArgumentException("Multiple Series currently restricted to one image each");

            var studyBuilder = new StudyBuilder
            {
                DisplaySetFactory = new BasicDisplaySetFactory { CreateSingleImageDisplaySets = createSingleImageDisplaySets },
                PatientId = patientId,
                PatientsName = patientsName,
                StudyDescription = studyDescription,
                StudyInstanceUid = studyInstanceUid
            };

            var image1 = new ImageBuilder
            {
                ImageLaterality = "U",
                ViewPosition = "AP",
                InstanceNumber = 1,
                SopClassUid = SopClass.ComputedRadiographyImageStorageUid
            };

            var image2 = new ImageBuilder
            {
                ImageLaterality = "U",
                ViewPosition = "LL",
                InstanceNumber = 1,
                SopClassUid = SopClass.ComputedRadiographyImageStorageUid
            };

            if (oneSeries)
            {
                var seriesBuilder = new SeriesBuilder
                                        {
                                            Modality = "CR",
                                            SeriesDescription = seriesDescription,
                                            SeriesNumber = startSeriesNumber,
                                            Images = new List<ImageBuilder> {image1}
                                        };

                if (!oneImagePerSeries)
                    seriesBuilder.Images.Add(image2);

                studyBuilder.Series.Add(seriesBuilder);
            }
            else
            {
                var seriesBuilder = new SeriesBuilder
                {
                    Modality = "CR",
                    SeriesDescription = seriesDescription,
                    SeriesNumber = startSeriesNumber,
                    Images = new List<ImageBuilder> { image1 }
                };

                studyBuilder.Series.Add(seriesBuilder);

                seriesBuilder = new SeriesBuilder
                {
                    Modality = "CR",
                    SeriesDescription = seriesDescription,
                    SeriesNumber = startSeriesNumber,
                    Images = new List<ImageBuilder> { image2 }
                };

                studyBuilder.Series.Add(seriesBuilder);
            }

            return studyBuilder;
        }
Exemplo n.º 10
0
        public static StudyBuilder CreateDigitalXRayBuilder
        (
            string patientId,
            string patientsName,
            string studyDescription,
            string studyInstanceUid,
            string seriesDescription,
            int startSeriesNumber,
            bool oneSeries,
            bool oneImagePerSeries,
            bool createSingleImageDisplaySets
        )
        {
            if (!oneSeries && !oneImagePerSeries)
                throw new ArgumentException("Multiple Series currently restricted to one image each");

            var studyBuilder = new StudyBuilder
            {
                DisplaySetFactory = new BasicDisplaySetFactory { CreateSingleImageDisplaySets = createSingleImageDisplaySets },
                PatientId = patientId,
                PatientsName = patientsName,
                StudyDescription = studyDescription,
                StudyInstanceUid = studyInstanceUid
            };

            var image1 = new ImageBuilder
                             {
                                 ImageLaterality = "U",
                                 ViewPosition = "AP",
                                 InstanceNumber = 1,
                                 SopClassUid = SopClass.DigitalXRayImageStorageForPresentationUid,
                                 PresentationIntentType = "FOR PRESENTATION"
                             };

            var image2 = new ImageBuilder
                             {
                                 ImageLaterality = "U",
                                 ViewPosition = "LL",
                                 InstanceNumber = 1,
                                 SopClassUid = SopClass.DigitalXRayImageStorageForPresentationUid,
                                 PresentationIntentType = "FOR PRESENTATION"
                             };


            if (oneSeries)
            {
                var seriesBuilder = new SeriesBuilder
                                        {
                                            Modality = "DX",
                                            SeriesDescription = seriesDescription,
                                            SeriesNumber = startSeriesNumber,
                                            Images = new List<ImageBuilder> {image1 }
                                        };

                if (!oneImagePerSeries)
                    seriesBuilder.Images.Add(image2);

                studyBuilder.Series.Add(seriesBuilder);
            }
            else
            {
                var seriesBuilder = new SeriesBuilder
                                        {
                                            Modality = "DX",
                                            SeriesDescription = seriesDescription,
                                            SeriesNumber = startSeriesNumber,
                                            Images = new List<ImageBuilder> {image1}
                                        };

                studyBuilder.Series.Add(seriesBuilder);
                
                seriesBuilder = new SeriesBuilder
                                    {
                                        Modality = "DX",
                                        SeriesDescription = seriesDescription,
                                        SeriesNumber = startSeriesNumber,
                                        Images = new List<ImageBuilder> {image2}
                                    };

                studyBuilder.Series.Add(seriesBuilder);
            }

            return studyBuilder;
        }