示例#1
0
        public void TestGetPixelAspectRatioString()
        {
            using (var dataset = CreateMockDataset("CR", SopClass.ComputedRadiographyImageStorage, null, new SizeF(0.6f, 0.5f), "FIDUCIAL", "details", null))
                using (var sop = (ImageSop)Sop.Create(dataset))
                {
                    var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
                    Assert.AreEqual(@"5\6", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.33333331, 0.3333333);
                    Assert.AreEqual(@"1\1", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.7074200013, 0.7074200009);
                    Assert.AreEqual(@"1\1", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.3, 0.4);
                    Assert.AreEqual(@"3\4", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.4, 0.3000001);
                    Assert.AreEqual(@"4\3", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.55, 0.4);
                    Assert.AreEqual(@"11\8", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.7777777, 0.3333333);
                    Assert.AreEqual(@"7\3", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");
                }
        }
示例#2
0
            private void LoadSop(string file)
            {
                try
                {
                    Sop sop = Sop.Create(file);
                    try
                    {
                        _viewer.StudyTree.AddSop(sop);
                    }
                    catch (SopValidationException)
                    {
                        sop.Dispose();
                        throw;
                    }
                }
                catch (Exception e)
                {
                    // Things that could go wrong in which an exception will be thrown:
                    // 1) file is not a valid DICOM image
                    // 2) file is a valid DICOM image, but its image parameters are invalid
                    // 3) file is a valid DICOM image, but we can't handle this type of DICOM image

                    _failed++;
                    Platform.Log(LogLevel.Error, e);
                }

                _total++;
            }
        public void TestAgentCodeSequence()
        {
            var agent1 = new CodeSequenceMacro {
                CodeMeaning = "Contrastinol", CodeValue = "123", CodingSchemeDesignator = "ABC"
            };
            var agent2 = new CodeSequenceMacro {
                CodeMeaning = "Bolusinate", CodeValue = "456", CodingSchemeDesignator = "DEF"
            };

            var dataset = TestDataSource.CreateImageSopDataSource();

            dataset[DicomTags.ContrastBolusAgent].SetStringValue(@"Contrastinol and Bolusinate");
            dataset[DicomTags.ContrastBolusAgentSequence].AddSequenceItem(agent1.DicomSequenceItem);

            using (var sop = (ImageSop)Sop.Create(dataset))
                using (var images = new DisposableList <IPresentationImage>(PresentationImageFactory.Create(sop)))
                {
                    Assert.AreEqual(@"Contrastinol", _annotationItems[_cbAgent].GetAnnotationText(images[0]));

                    dataset[DicomTags.ContrastBolusAgentSequence].AddSequenceItem(agent2.DicomSequenceItem);
                    Assert.AreEqual(@"Contrastinol\Bolusinate", _annotationItems[_cbAgent].GetAnnotationText(images[0]));

                    agent1.CodeMeaning = string.Empty;
                    Assert.AreEqual(@"123 (ABC)\Bolusinate", _annotationItems[_cbAgent].GetAnnotationText(images[0]));

                    agent2.CodeMeaning = string.Empty;
                    Assert.AreEqual(@"Contrastinol and Bolusinate", _annotationItems[_cbAgent].GetAnnotationText(images[0]));

                    dataset[DicomTags.ContrastBolusAgent].SetNullValue();
                    Assert.AreEqual(@"123 (ABC)\456 (DEF)", _annotationItems[_cbAgent].GetAnnotationText(images[0]));
                }
        }
        public void TestNil()
        {
            var dataset = TestDataSource.CreateImageSopDataSource();

            using (var sop = (ImageSop)Sop.Create(dataset))
                using (var images = new DisposableList <IPresentationImage>(PresentationImageFactory.Create(sop)))
                {
                    Assert.IsEmpty(_annotationItems[_cbAgent].GetAnnotationText(images[0]));
                }
        }
        public void TestAgentDescriptorOnly()
        {
            var dataset = TestDataSource.CreateImageSopDataSource();

            dataset[DicomTags.ContrastBolusAgent].SetStringValue(@"Contrastinol and Bolusinate");

            using (var sop = (ImageSop)Sop.Create(dataset))
                using (var images = new DisposableList <IPresentationImage>(PresentationImageFactory.Create(sop)))
                {
                    Assert.AreEqual(@"Contrastinol and Bolusinate", _annotationItems[_cbAgent].GetAnnotationText(images[0]));
                }
        }
示例#6
0
        public VtkTestPresentationImage()
            : base(100, 100, 100)
        {
            var dcf = new DicomFile();

            FillDicomDataSet(dcf.MetaInfo, dcf.DataSet);

            using (var dataSource = new TestDataSource(dcf))
                using (var sop = (ImageSop)Sop.Create(dataSource))
                {
                    _frameReference = sop.Frames[1].CreateTransientReference();
                }
        }
示例#7
0
        public void TestDisposal()
        {
            IList <DicomAttributeCollection> collections = base.SetupMRSeries(1, 1, "test");
            DicomFile      file       = new DicomFile(null, new DicomAttributeCollection(), collections[0]);
            TestDataSource dataSource = new TestDataSource(file);
            Sop            sop        = Sop.Create(dataSource);

            Assert.IsFalse(dataSource.IsDisposed);
            Assert.IsFalse(SopDataCache.ItemCount == 0, "The Sop data cache is empty.");

            sop.Dispose();

            Assert.IsTrue(dataSource.IsDisposed);
            Assert.IsTrue(SopDataCache.ItemCount == 0, "The Sop data cache is NOT empty.");
        }
示例#8
0
        private static IPresentationImage CreateResultImage(Bitmap bitmap, ColorMode colorMode, string filePath)
        {
            DicomFile file = new DicomFile();

            file.DataSet[DicomTags.BitsAllocated].SetInt32(0, 8);
            file.DataSet[DicomTags.BitsStored].SetInt32(0, 8);
            file.DataSet[DicomTags.HighBit].SetInt32(0, 7);
            file.DataSet.RemoveAttribute(DicomTags.WindowCenter);
            file.DataSet.RemoveAttribute(DicomTags.WindowWidth);
            file.DataSet[DicomTags.PixelSpacing].SetInt32(0, 0);
            file.DataSet[DicomTags.RescaleIntercept].SetInt32(0, 0);
            file.DataSet[DicomTags.RescaleSlope].SetInt32(0, 1);
            file.DataSet[DicomTags.Rows].SetInt32(0, bitmap.Height);
            file.DataSet[DicomTags.Columns].SetInt32(0, bitmap.Width);
            file.DataSet[DicomTags.PixelRepresentation].SetInt32(0, 0);
            file.DataSet[DicomTags.NumberOfFrames].SetInt32(0, 1);
            file.DataSet[DicomTags.PhotometricInterpretation].SetStringValue("MONOCHROME2");
            file.DataSet[DicomTags.SopClassUid].SetStringValue("1.2.840.10008.5.1.4.1.1.7");
            file.DataSet[DicomTags.Modality].SetStringValue("OT");
            file.DataSet[DicomTags.TransferSyntaxUid].SetStringValue("1.2.840.10008.1.2");
            file.DataSet[DicomTags.StudyId].SetStringValue("1");
            file.DataSet[DicomTags.StudyInstanceUid].SetStringValue("1.2.276.0.7230010.3.1.2.2866517296.296.1377417571.2");
            file.DataSet[DicomTags.SeriesNumber].SetInt32(0, 1);
            file.DataSet[DicomTags.SamplesPerPixel].SetInt32(0, 1);
            file.DataSet[DicomTags.SeriesInstanceUid].SetStringValue(" 1.2.276.0.7230010.3.1.3.2866517296.296.1377417571.3");
            file.DataSet[DicomTags.SopInstanceUid].SetStringValue(DicomUid.GenerateUid().UID);
            file.DataSet[DicomTags.PixelData].Values = null;
            byte[] pixelData = BitMapUtility.GetBitmap(bitmap, colorMode);
            file.DataSet[DicomTags.PixelData].Values = pixelData;
            file.MediaStorageSopClassUid             = file.DataSet[DicomTags.SopClassUid];
            file.MediaStorageSopInstanceUid          = file.DataSet[DicomTags.SopInstanceUid];
            string fileName = string.Format("{0}\\{1}", filePath, DateTime.Now.Ticks.ToString());

            file.Save(fileName);
            var dataSource = new LocalSopDataSource(file);
            Sop dstSop     = Sop.Create(dataSource);
            IPresentationImage presentation = (PresentationImageFactory.Create((ImageSop)dstSop))[0];

            if (presentation is IAnnotationLayoutProvider)
            {
                foreach (AnnotationBox box in ((IAnnotationLayoutProvider)presentation).AnnotationLayout.AnnotationBoxes)
                {
                    box.Visible = false;
                }
            }

            return(presentation);
        }
示例#9
0
 public void TestCTCalibratedWithRogueImagerPixelSpacing()
 {
     using (var dataset = CreateMockDataset("CT", SopClass.CtImageStorage, new SizeF(1f, 2f), new SizeF(0.4f, 0.3f), "GEOMETRY", "garbage", null))
     {
         using (var sop = (ImageSop)Sop.Create(dataset))
         {
             var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
             Console.WriteLine(GetPixelSpacingAttributeInfo(dataset));
             Assert.AreEqual(false, normalizedPixelSpacing.IsNull, "IsNull property");
             Assert.AreEqual(0.3, normalizedPixelSpacing.Row, _tolerance, "Row property");
             Assert.AreEqual(0.4, normalizedPixelSpacing.Column, _tolerance, "Column property");
             Assert.AreEqual(NormalizedPixelSpacingCalibrationType.CrossSectionalSpacing, normalizedPixelSpacing.CalibrationType, "CalibrationType property");
             Assert.AreEqual(string.Empty, normalizedPixelSpacing.CalibrationDetails, "CalibrationDetails property");
         }
     }
 }
示例#10
0
 public void TestCRCalibratedUsingFiducialWithoutImagerPixelSpacing()
 {
     using (var dataset = CreateMockDataset("CR", SopClass.ComputedRadiographyImageStorage, null, new SizeF(0.4f, 0.3f), "FIDUCIAL", "details", null))
     {
         using (var sop = (ImageSop)Sop.Create(dataset))
         {
             var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
             Console.WriteLine(GetPixelSpacingAttributeInfo(dataset));
             Assert.AreEqual(false, normalizedPixelSpacing.IsNull, "IsNull property");
             Assert.AreEqual(0.3, normalizedPixelSpacing.Row, _tolerance, "Row property");
             Assert.AreEqual(0.4, normalizedPixelSpacing.Column, _tolerance, "Column property");
             Assert.AreEqual(NormalizedPixelSpacingCalibrationType.Fiducial, normalizedPixelSpacing.CalibrationType, "CalibrationType property");
             Assert.AreEqual("details", normalizedPixelSpacing.CalibrationDetails, "CalibrationDetails property");
         }
     }
 }
示例#11
0
 public void TestCRCalibrationUnspecified()
 {
     using (var dataset = CreateMockDataset("CR", SopClass.ComputedRadiographyImageStorage, new SizeF(0.6f, 0.5f), new SizeF(0.4f, 0.3f), null, null, null))
     {
         using (var sop = (ImageSop)Sop.Create(dataset))
         {
             var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
             Console.WriteLine(GetPixelSpacingAttributeInfo(dataset));
             Assert.AreEqual(false, normalizedPixelSpacing.IsNull, "IsNull property");
             Assert.AreEqual(0.3, normalizedPixelSpacing.Row, _tolerance, "Row property");
             Assert.AreEqual(0.4, normalizedPixelSpacing.Column, _tolerance, "Column property");
             Assert.AreEqual(NormalizedPixelSpacingCalibrationType.Unknown, normalizedPixelSpacing.CalibrationType, "CalibrationType property");
             Assert.AreEqual(string.Empty, normalizedPixelSpacing.CalibrationDetails, "CalibrationDetails property");
         }
     }
 }
示例#12
0
 public void TestCTUncalibrated()
 {
     using (var dataset = CreateMockDataset("CT", SopClass.CtImageStorage, null, null, null, null, null))
     {
         using (var sop = (ImageSop)Sop.Create(dataset))
         {
             var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
             Console.WriteLine(GetPixelSpacingAttributeInfo(dataset));
             Assert.AreEqual(true, normalizedPixelSpacing.IsNull, "IsNull property");
             Assert.AreEqual(0, normalizedPixelSpacing.Row, _tolerance, "Row property");
             Assert.AreEqual(0, normalizedPixelSpacing.Column, _tolerance, "Column property");
             Assert.AreEqual(NormalizedPixelSpacingCalibrationType.None, normalizedPixelSpacing.CalibrationType, "CalibrationType property");
             Assert.AreEqual(string.Empty, normalizedPixelSpacing.CalibrationDetails, "CalibrationDetails property");
         }
     }
 }
示例#13
0
 public void TestMGCalibratedUsingGeometry()
 {
     using (var dataset = CreateMockDataset("MG", SopClass.DigitalMammographyXRayImageStorageForPresentation, new SizeF(0.6f, 0.5f), new SizeF(0.4f, 0.3f), "GEOMETRY", null, null))
     {
         using (var sop = (ImageSop)Sop.Create(dataset))
         {
             var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
             Console.WriteLine(GetPixelSpacingAttributeInfo(dataset));
             Assert.AreEqual(false, normalizedPixelSpacing.IsNull, "IsNull property");
             Assert.AreEqual(0.3, normalizedPixelSpacing.Row, _tolerance, "Row property");
             Assert.AreEqual(0.4, normalizedPixelSpacing.Column, _tolerance, "Column property");
             Assert.AreEqual(NormalizedPixelSpacingCalibrationType.Geometry, normalizedPixelSpacing.CalibrationType, "CalibrationType property");
             Assert.AreEqual(string.Empty, normalizedPixelSpacing.CalibrationDetails, "CalibrationDetails property");
         }
     }
 }
示例#14
0
 public void TestMGCalibratedUsingGeometryWithMagnificationFactor()
 {
     // we don't yet support the IHE Mammo profile requirement to use Imager Pixel Spacing corrected by Estimated Radiographic Magnification Factor
     using (var dataset = CreateMockDataset("MG", SopClass.DigitalMammographyXRayImageStorageForPresentation, new SizeF(0.6f, 0.5f), new SizeF(0.4f, 0.3f), "GEOMETRY", null, 1.5))
     {
         using (var sop = (ImageSop)Sop.Create(dataset))
         {
             var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
             Console.WriteLine(GetPixelSpacingAttributeInfo(dataset));
             Assert.AreEqual(false, normalizedPixelSpacing.IsNull, "IsNull property");
             Assert.AreEqual(0.3, normalizedPixelSpacing.Row, _tolerance, "Row property");
             Assert.AreEqual(0.4, normalizedPixelSpacing.Column, _tolerance, "Column property");
             Assert.AreEqual(NormalizedPixelSpacingCalibrationType.Geometry, normalizedPixelSpacing.CalibrationType, "CalibrationType property");
             Assert.AreEqual(string.Empty, normalizedPixelSpacing.CalibrationDetails, "CalibrationDetails property");
         }
     }
 }
示例#15
0
 public void TestDXUncalibratedWithDetectorSpacing()
 {
     using (var dataset = CreateMockDataset("DX", SopClass.DigitalXRayImageStorageForPresentation, new SizeF(0.4f, 0.3f), null, null, null, null))
     {
         using (var sop = (ImageSop)Sop.Create(dataset))
         {
             var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
             Console.WriteLine(GetPixelSpacingAttributeInfo(dataset));
             Assert.AreEqual(false, normalizedPixelSpacing.IsNull, "IsNull property");
             Assert.AreEqual(0.3, normalizedPixelSpacing.Row, _tolerance, "Row property");
             Assert.AreEqual(0.4, normalizedPixelSpacing.Column, _tolerance, "Column property");
             Assert.AreEqual(NormalizedPixelSpacingCalibrationType.Detector, normalizedPixelSpacing.CalibrationType, "CalibrationType property");
             Assert.AreEqual(string.Empty, normalizedPixelSpacing.CalibrationDetails, "CalibrationDetails property");
             Assert.AreEqual(@"3\4", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");
         }
     }
 }
示例#16
0
 public void TestMGUncalibrated()
 {
     using (var dataset = CreateMockDataset("MG", SopClass.DigitalMammographyXRayImageStorageForPresentation, null, null, null, null, null))
     {
         using (var sop = (ImageSop)Sop.Create(dataset))
         {
             var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
             Console.WriteLine(GetPixelSpacingAttributeInfo(dataset));
             Assert.AreEqual(true, normalizedPixelSpacing.IsNull, "IsNull property");
             Assert.AreEqual(0, normalizedPixelSpacing.Row, _tolerance, "Row property");
             Assert.AreEqual(0, normalizedPixelSpacing.Column, _tolerance, "Column property");
             Assert.AreEqual(NormalizedPixelSpacingCalibrationType.None, normalizedPixelSpacing.CalibrationType, "CalibrationType property");
             Assert.AreEqual(string.Empty, normalizedPixelSpacing.CalibrationDetails, "CalibrationDetails property");
             Assert.AreEqual(string.Empty, normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");
         }
     }
 }
示例#17
0
 public void TestCRCalibratedUsingGeometry()
 {
     using (var dataset = CreateMockDataset("CR", SopClass.ComputedRadiographyImageStorage, new SizeF(0.6f, 0.5f), new SizeF(0.4f, 0.3f), "GEOMETRY", "details", null))
     {
         using (var sop = (ImageSop)Sop.Create(dataset))
         {
             var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
             Console.WriteLine(GetPixelSpacingAttributeInfo(dataset));
             Assert.AreEqual(false, normalizedPixelSpacing.IsNull, "IsNull property");
             Assert.AreEqual(0.3, normalizedPixelSpacing.Row, _tolerance, "Row property");
             Assert.AreEqual(0.4, normalizedPixelSpacing.Column, _tolerance, "Column property");
             Assert.AreEqual(NormalizedPixelSpacingCalibrationType.Geometry, normalizedPixelSpacing.CalibrationType, "CalibrationType property");
             Assert.AreEqual("details", normalizedPixelSpacing.CalibrationDetails, "CalibrationDetails property");
             Assert.AreEqual(@"3\4", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");
         }
     }
 }
示例#18
0
        public void TestCaching()
        {
            IList <DicomAttributeCollection> collections = base.SetupMRSeries(1, 1, "test");
            DicomFile file1 = new DicomFile(null, new DicomAttributeCollection(), collections[0].Copy());
            DicomFile file2 = new DicomFile(null, new DicomAttributeCollection(), collections[0].Copy());

            TestDataSource dataSource1 = new TestDataSource(file1);
            TestDataSource dataSource2 = new TestDataSource(file2);

            Sop sop1 = Sop.Create(dataSource1);

            Assert.IsTrue(SopDataCache.ItemCount == 1, "The Sop data cache should have 1 entry.");

            Sop sop2 = Sop.Create(dataSource2);

            Assert.IsTrue(SopDataCache.ItemCount == 1, "The Sop data cache should have 1 entry.");
            Assert.IsTrue(dataSource2.IsDisposed, "The data source has not been disposed.");
            Assert.IsFalse(dataSource1.IsDisposed, "The data source should not be disposed.");

            sop1.Dispose();
            Assert.IsTrue(SopDataCache.ItemCount == 1, "The Sop data cache should have 1 entry.");

            ISopReference reference21 = sop2.CreateTransientReference();
            ISopReference reference22 = sop2.CreateTransientReference();

            reference21.Dispose();
            Assert.IsFalse(dataSource1.IsDisposed, "The data source has been disposed.");
            Assert.IsTrue(SopDataCache.ItemCount == 1, "The Sop data cache should have 1 entry.");

            sop2.Dispose();
            Assert.IsFalse(dataSource1.IsDisposed, "The data source has been disposed.");
            Assert.IsTrue(SopDataCache.ItemCount == 1, "The Sop data cache should have 1 entry.");

            reference22.Dispose();
            Assert.IsTrue(dataSource1.IsDisposed, "The data source has not been disposed.");
            Assert.IsTrue(SopDataCache.ItemCount == 0, "The Sop data cache is NOT empty.");
        }
示例#19
0
 public List <Sop> BuildSops()
 {
     return(BuildFiles().ConvertAll(f => Sop.Create(new TestDataSource(f))));
 }
        public void TestEnhancedAgentCodeSequence()
        {
            var agent1 = new CodeSequenceMacro {
                CodeMeaning = "Contrastinol", CodeValue = "123", CodingSchemeDesignator = "ABC"
            };
            var agent2 = new CodeSequenceMacro {
                CodeMeaning = "Bolusinate", CodeValue = "456", CodingSchemeDesignator = "DEF"
            };
            var agent3 = new CodeSequenceMacro {
                CodeMeaning = "Dilithium", CodeValue = "789", CodingSchemeDesignator = "GHI"
            };

            var usageFrame1 = new ContrastBolusUsageFunctionalGroup
            {
                ContrastBolusUsageSequence = new[]
                {
                    new ContrastBolusUsageSequenceItem {
                        ContrastBolusAgentNumber = 1
                    },
                    new ContrastBolusUsageSequenceItem {
                        ContrastBolusAgentNumber = 3
                    }
                }
            };
            var usageFrame2 = new ContrastBolusUsageFunctionalGroup
            {
                ContrastBolusUsageSequence = new[]
                {
                    new ContrastBolusUsageSequenceItem {
                        ContrastBolusAgentNumber = 2
                    }
                }
            };
            var usageFrame3 = new ContrastBolusUsageFunctionalGroup(new DicomSequenceItem())
            {
                ContrastBolusUsageSequence = new[]
                {
                    new ContrastBolusUsageSequenceItem {
                        ContrastBolusAgentNumber = 999
                    },
                    new ContrastBolusUsageSequenceItem {
                        ContrastBolusAgentNumber = 2
                    }
                }
            };
            var usageFrame4 = new ContrastBolusUsageFunctionalGroup(new DicomSequenceItem());

            var dataset = TestDataSource.CreateImageSopDataSource(4);

            dataset[DicomTags.ContrastBolusAgent].SetStringValue(@"Contrastinol and Bolusinate");
            dataset[DicomTags.ContrastBolusAgentSequence].AddSequenceItem(agent1.DicomSequenceItem);
            dataset[DicomTags.ContrastBolusAgentSequence].AddSequenceItem(agent2.DicomSequenceItem);
            dataset[DicomTags.ContrastBolusAgentSequence].AddSequenceItem(agent3.DicomSequenceItem);
            dataset[DicomTags.PerFrameFunctionalGroupsSequence].AddSequenceItem(usageFrame1.DicomSequenceItem);
            dataset[DicomTags.PerFrameFunctionalGroupsSequence].AddSequenceItem(usageFrame2.DicomSequenceItem);
            dataset[DicomTags.PerFrameFunctionalGroupsSequence].AddSequenceItem(usageFrame3.DicomSequenceItem);
            dataset[DicomTags.PerFrameFunctionalGroupsSequence].AddSequenceItem(usageFrame4.DicomSequenceItem);

            agent1.DicomSequenceItem[DicomTags.ContrastBolusAgentNumber].SetInt32(0, 1);
            agent2.DicomSequenceItem[DicomTags.ContrastBolusAgentNumber].SetInt32(0, 2);
            agent3.DicomSequenceItem[DicomTags.ContrastBolusAgentNumber].SetInt32(0, 3);

            using (var sop = (ImageSop)Sop.Create(dataset))
                using (var images = new DisposableList <IPresentationImage>(PresentationImageFactory.Create(sop)))
                {
                    Assert.AreEqual(@"Contrastinol\Dilithium", _annotationItems[_cbAgent].GetAnnotationText(images[0]), "Frame 1");
                    Assert.AreEqual(@"Bolusinate", _annotationItems[_cbAgent].GetAnnotationText(images[1]), "Frame 2");
                    Assert.AreEqual(@"Bolusinate", _annotationItems[_cbAgent].GetAnnotationText(images[2]), "Frame 3");
                    Assert.IsEmpty(_annotationItems[_cbAgent].GetAnnotationText(images[3]), "Frame 4");

                    agent1.CodeMeaning = string.Empty;
                    agent2.CodeMeaning = string.Empty;
                    Assert.AreEqual(@"123 (ABC)\Dilithium", _annotationItems[_cbAgent].GetAnnotationText(images[0]), "Frame 1");
                    Assert.AreEqual(@"456 (DEF)", _annotationItems[_cbAgent].GetAnnotationText(images[1]), "Frame 2");
                    Assert.AreEqual(@"456 (DEF)", _annotationItems[_cbAgent].GetAnnotationText(images[2]), "Frame 3");
                    Assert.IsEmpty(_annotationItems[_cbAgent].GetAnnotationText(images[3]), "Frame 4");

                    agent3.CodeMeaning = string.Empty;
                    Assert.AreEqual(@"123 (ABC)\789 (GHI)", _annotationItems[_cbAgent].GetAnnotationText(images[0]));
                    Assert.AreEqual(@"456 (DEF)", _annotationItems[_cbAgent].GetAnnotationText(images[1]), "Frame 2");
                    Assert.AreEqual(@"456 (DEF)", _annotationItems[_cbAgent].GetAnnotationText(images[2]), "Frame 3");
                    Assert.IsEmpty(_annotationItems[_cbAgent].GetAnnotationText(images[3]), "Frame 4");
                }
        }