Example #1
0
        private IEnumerable <Frame> GetAcquisitionTimeTestFrames()
        {
            int i = 0;

            foreach (DateTime dateTime in GetAquisitionDateTimes())
            {
                ImageSop sop   = NewImageSop("123", "123", i++);
                Frame    frame = sop.Frames[1];
                DicomMessageSopDataSource dataSource = ((DicomMessageSopDataSource)frame.ParentImageSop.DataSource);

                if (i % 2 == 0)
                {
                    dataSource.SourceMessage.DataSet[DicomTags.AcquisitionDate].SetStringValue(dateTime.Date.ToString(DateParser.DicomDateFormat));
                    dataSource.SourceMessage.DataSet[DicomTags.AcquisitionTime].SetStringValue(dateTime.ToString(TimeParser.DicomFullTimeFormat));
                }
                else
                {
                    dataSource.SourceMessage.DataSet[DicomTags.AcquisitionDatetime].SetStringValue(dateTime.ToString(DateTimeParser.DicomFullDateTimeFormat));
                }

                yield return(frame);

                sop.Dispose();
            }
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _imageSop.Dispose();
     }
 }
Example #3
0
        protected static IPresentationImage GetImage(ImageKey key)
        {
            string filename = string.Format(_testImagePathFormat, key.ToString().ToLower());

            try
            {
                LocalSopDataSource dataSource = new LocalSopDataSource(filename);
                ImageSop           imageSop   = new ImageSop(dataSource);
                IPresentationImage theOne     = null;
                foreach (IPresentationImage image in PresentationImageFactory.Create(imageSop))
                {
                    if (theOne == null)
                    {
                        theOne = image;
                        continue;
                    }
                    image.Dispose();
                }
                imageSop.Dispose();
                return(theOne);
            }
            catch (Exception ex)
            {
                throw new FileNotFoundException("Unable to load requested test image. Please check that the assembly has been built.", filename, ex);
            }
        }
Example #4
0
        private IEnumerable <PresentationImage> NewDicomImages(string studyUID, string seriesUID, int instanceNumber, int numberOfFrames)
        {
            ImageSop sop = NewImageSop(studyUID, seriesUID, instanceNumber, numberOfFrames);

            for (int i = 1; i <= numberOfFrames; ++i)
            {
                yield return(new DicomGrayscalePresentationImage(sop.Frames[i]));
            }

            sop.Dispose();
        }
Example #5
0
        private void TestSortingDisplaySetsBySeriesNumber(bool reverse)
        {
            DisplaySetCollection orderedCollection    = new DisplaySetCollection();
            DisplaySetCollection nonOrderedCollection = new DisplaySetCollection();

            for (int i = 1; i <= 20; ++i)
            {
                string             id         = i.ToString();
                DisplaySet         displaySet = new DisplaySet(id, id);
                ImageSop           sop        = NewImageSop(id, id, i);
                IPresentationImage image      = new DicomGrayscalePresentationImage(sop.Frames[1]);
                sop.Dispose();
                IImageSopProvider         sopProvider = (IImageSopProvider)image;
                DicomMessageSopDataSource dataSource  = ((DicomMessageSopDataSource)sopProvider.ImageSop.DataSource);
                dataSource.SourceMessage.DataSet[DicomTags.SeriesNumber].SetInt32(0, i);

                displaySet.PresentationImages.Add(image);
                orderedCollection.Add(displaySet);
            }

            Randomize(orderedCollection, nonOrderedCollection);

            Debug.WriteLine("Before Sort\n------------------------\n");
            CollectionUtils.ForEach(nonOrderedCollection, delegate(IDisplaySet displaySet) { Debug.WriteLine(String.Format("name: {0}", displaySet.Name)); });

            nonOrderedCollection.Sort(new SeriesNumberComparer(reverse));

            Debug.WriteLine("\nAfter Sort\n------------------------\n");
            CollectionUtils.ForEach(nonOrderedCollection, delegate(IDisplaySet displaySet) { Debug.WriteLine(String.Format("name: {0}", displaySet.Name)); });

            int j = reverse ? 20 : 1;

            foreach (IDisplaySet set in nonOrderedCollection)
            {
                Assert.AreEqual(j.ToString(), set.Name);
                j += reverse ? -1 : 1;
            }

            foreach (DisplaySet set in nonOrderedCollection)
            {
                set.Dispose();
            }
            foreach (DisplaySet set in orderedCollection)
            {
                set.Dispose();
            }
        }
Example #6
0
        private IImageSet CreateImageSet(string patientId, string description)
        {
            string studyInstanceUid  = DicomUid.GenerateUid().UID;
            string seriesInstanceUid = DicomUid.GenerateUid().UID;
            string sopInstanceUid    = DicomUid.GenerateUid().UID;

            ImageSop sop = CreateImageSop(patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid);
            DicomGrayscalePresentationImage img = new DicomGrayscalePresentationImage(sop.Frames[1]);

            sop.Dispose();

            DisplaySet displaySet = new DisplaySet(patientId, seriesInstanceUid);

            displaySet.PresentationImages.Add(img);
            ImageSet imageSet = new ImageSet();

            imageSet.PatientInfo = description;
            imageSet.DisplaySets.Add(displaySet);

            return(imageSet);
        }