public void TestSeriesSplittingMREcho()
        {
            const int             numberOfSeries     = 5;
            const int             instancesPerSeries = 10;
            List <TestDataSource> dataSources        = CreateMRStudyDataSources(numberOfSeries, instancesPerSeries, "1.2.3");
            StudyTree             studyTree          = CreateStudyTree(ConvertToSops(dataSources));

            MREchoDisplaySetFactory factory = new MREchoDisplaySetFactory();

            factory.SetStudyTree(studyTree);
            List <IDisplaySet> allDisplaySets = new List <IDisplaySet>();

            try
            {
                Patient patient = studyTree.Patients[0];
                Study   study   = patient.Studies[0];

                Assert.AreEqual(numberOfSeries, study.Series.Count, "There should be exactly {0} series", numberOfSeries);

                Series series2 = study.Series[1];
                Series series3 = study.Series[2];

                MakeEchoSeries(series2);
                MakeEchoSeries(series3);

                foreach (Series series in study.Series)
                {
                    Assert.AreEqual(instancesPerSeries, series.Sops.Count, "There should be exactly {0} sops", instancesPerSeries);
                    List <IDisplaySet> displaySets = factory.CreateDisplaySets(series);
                    allDisplaySets.AddRange(displaySets);

                    if (series == series2 || series == series3)
                    {
                        IDisplaySet displaySet = displaySets[0];
                        Assert.AreEqual(2, displaySets.Count, "There should be exactly 2 display sets");
                        Assert.AreEqual(series.Sops.Count / 2, displaySet.PresentationImages.Count, "#presentation images should be #Sops/2");
                        Assert.AreNotEqual(series.SeriesInstanceUid, displaySet.Descriptor.Uid, "Series UID and Display Set UID don't match");
                        Assert.AreEqual(typeof(MREchoDisplaySetDescriptor), displaySet.Descriptor.GetType(), "Wrong display set descriptor type");
                        Assert.IsTrue(displaySet.Name.Contains("Echo"), "Display Set name not correct");

                        ValidateEchoDisplaySet(displaySets[0], 1);
                        ValidateEchoDisplaySet(displaySets[1], 2);
                    }
                    else
                    {
                        Assert.AreEqual(0, displaySets.Count, "There should be no display sets");
                    }
                }
            }
            finally
            {
                foreach (IDisplaySet displaySet in allDisplaySets)
                {
                    displaySet.Dispose();
                }

                studyTree.Dispose();
            }
        }
Ejemplo n.º 2
0
            public override void SetStudyTree(StudyTree studyTree)
            {
                base.SetStudyTree(studyTree);

                _basicFactory.SetStudyTree(studyTree);

                if (_echoFactory != null)
                {
                    _echoFactory.SetStudyTree(studyTree);
                }

                if (_mixedMultiFrameFactory != null)
                {
                    _mixedMultiFrameFactory.SetStudyTree(studyTree);
                }

                _placeholderDisplaySetFactory.SetStudyTree(studyTree);

                foreach (var factory in _externalFactories)
                {
                    factory.SetStudyTree(studyTree);
                }
            }
Ejemplo n.º 3
0
		public void TestSeriesSplittingMREcho()
		{
			const int numberOfSeries = 5;
			const int instancesPerSeries = 10;
			List<TestDataSource> dataSources = CreateMRStudyDataSources(numberOfSeries, instancesPerSeries, "1.2.3");
			StudyTree studyTree = CreateStudyTree(ConvertToSops(dataSources));

			MREchoDisplaySetFactory factory = new MREchoDisplaySetFactory();
			factory.SetStudyTree(studyTree);
			List<IDisplaySet> allDisplaySets = new List<IDisplaySet>();

			try
			{
				Patient patient = studyTree.Patients[0];
				Study study = patient.Studies[0];

				Assert.AreEqual(numberOfSeries, study.Series.Count, "There should be exactly {0} series", numberOfSeries);

				Series series2 = study.Series[1];
				Series series3 = study.Series[2];

				MakeEchoSeries(series2);
				MakeEchoSeries(series3);

				foreach (Series series in study.Series)
				{
					Assert.AreEqual(instancesPerSeries, series.Sops.Count, "There should be exactly {0} sops", instancesPerSeries);
					List<IDisplaySet> displaySets = factory.CreateDisplaySets(series);
					allDisplaySets.AddRange(displaySets);

					if (series == series2 || series == series3)
					{
						IDisplaySet displaySet = displaySets[0];
						Assert.AreEqual(2, displaySets.Count, "There should be exactly 2 display sets");
						Assert.AreEqual(series.Sops.Count / 2, displaySet.PresentationImages.Count, "#presentation images should be #Sops/2");
						Assert.AreNotEqual(series.SeriesInstanceUid, displaySet.Descriptor.Uid, "Series UID and Display Set UID don't match");
						Assert.AreEqual(typeof(MREchoDisplaySetDescriptor), displaySet.Descriptor.GetType(), "Wrong display set descriptor type");
						Assert.IsTrue(displaySet.Name.Contains("Echo"), "Display Set name not correct");

						ValidateEchoDisplaySet(displaySets[0], 1);
						ValidateEchoDisplaySet(displaySets[1], 2);
					}
					else
					{
						Assert.AreEqual(0, displaySets.Count, "There should be no display sets");
					}
				}
			}
			finally
			{
				foreach (IDisplaySet displaySet in allDisplaySets)
					displaySet.Dispose();

				studyTree.Dispose();
			}
		}
        public void TestSeriesSplittingEnhancedMREcho()
        {
            const int             numberOfSeries     = 2;
            const int             instancesPerSeries = 3;
            const int             framesPerInstance  = 10;
            List <TestDataSource> dataSources        = CreateMRStudyDataSources(numberOfSeries, instancesPerSeries, "1.2.3");

            foreach (var dicomFile in dataSources.Select(d => d.File))
            {
                dicomFile.DataSet[DicomTags.NumberOfFrames].SetInt32(0, framesPerInstance);

                if (dicomFile.DataSet[DicomTags.SeriesNumber].GetInt32(0, 0) != 2)
                {
                    continue;
                }

                var dimUid    = "1.2.3.4.5";
                var mfdModule = new MultiFrameDimensionModuleIod(dicomFile.DataSet);
                mfdModule.DimensionOrganizationSequence = new[] { new DimensionOrganizationSequenceItem {
                                                                      DimensionOrganizationUid = dimUid
                                                                  } };
                mfdModule.DimensionIndexSequence = new[]
                {
                    new DimensionIndexSequenceItem {
                        DimensionIndexPointer = DicomTags.StackId, FunctionalGroupPointer = DicomTags.FrameContentSequence, DimensionOrganizationUid = dimUid
                    },
                    new DimensionIndexSequenceItem {
                        DimensionIndexPointer = DicomTags.InStackPositionNumber, FunctionalGroupPointer = DicomTags.FrameContentSequence, DimensionOrganizationUid = dimUid
                    },
                    new DimensionIndexSequenceItem {
                        DimensionIndexPointer = DicomTags.EffectiveEchoTime, FunctionalGroupPointer = DicomTags.MrEchoSequence, DimensionOrganizationUid = dimUid
                    }
                };
                var mffgModule = new MultiFrameFunctionalGroupsModuleIod(dicomFile.DataSet);
                mffgModule.PerFrameFunctionalGroupsSequence = Enumerable.Range(0, framesPerInstance).Select(i =>
                {
                    var fg = new FunctionalGroupsSequenceItem();
                    ushort inStackPositionNumber = (ushort)(i % 5 + 1);
                    ushort echoNumber            = (ushort)(i / 5 + 1);
                    fg.GetFunctionalGroup <FrameContentFunctionalGroup>().FrameContentSequence = new FrameContentSequenceItem {
                        InStackPositionNumber = inStackPositionNumber, StackId = "1", DimensionIndexValues = new uint[] { 1, inStackPositionNumber, echoNumber }
                    };
                    fg.GetFunctionalGroup <MrEchoFunctionalGroup>().MrEchoSequence = new MrEchoSequenceItem {
                        EffectiveEchoTime = echoNumber + 5 / 1000f
                    };
                    return(fg);
                }).ToArray();
            }

            StudyTree studyTree = CreateStudyTree(ConvertToSops(dataSources));

            MREchoDisplaySetFactory factory = new MREchoDisplaySetFactory();

            factory.SetStudyTree(studyTree);
            List <IDisplaySet> allDisplaySets = new List <IDisplaySet>();

            try
            {
                Patient patient = studyTree.Patients[0];
                Study   study   = patient.Studies[0];

                Assert.AreEqual(numberOfSeries, study.Series.Count, "There should be exactly {0} series", numberOfSeries);

                Series series2 = study.Series[1];

                foreach (Series series in study.Series)
                {
                    Assert.AreEqual(instancesPerSeries, series.Sops.Count, "There should be exactly {0} sops", instancesPerSeries);
                    List <IDisplaySet> displaySets = factory.CreateDisplaySets(series);
                    allDisplaySets.AddRange(displaySets);

                    if (series == series2)
                    {
                        Assert.AreEqual(2, displaySets.Count, "There should be exactly 4 display sets");

                        IDisplaySet displaySet = displaySets[0];
                        Assert.AreEqual(series.Sops.Count * framesPerInstance / 2, displaySet.PresentationImages.Count, "#presentation images should be #Sops/2");
                        Assert.AreNotEqual(series.SeriesInstanceUid, displaySet.Descriptor.Uid, "Series UID and Display Set UID don't match");
                        Assert.AreEqual(typeof(MREchoDisplaySetDescriptor), displaySet.Descriptor.GetType(), "Wrong display set descriptor type");
                        Assert.IsTrue(displaySet.Name.Contains("Echo"), "Display Set name not correct");

                        ValidateMultiframeEchoDisplaySet(displaySets[0], 1);
                        ValidateMultiframeEchoDisplaySet(displaySets[1], 2);
                    }
                    else
                    {
                        //Assert.AreEqual(0, displaySets.Count, "There should be no display sets");
                    }
                }
            }
            finally
            {
                foreach (IDisplaySet displaySet in allDisplaySets)
                {
                    displaySet.Dispose();
                }

                studyTree.Dispose();
            }
        }
		public void TestSeriesSplittingEnhancedMREcho()
		{
			const int numberOfSeries = 2;
			const int instancesPerSeries = 3;
			const int framesPerInstance = 10;
			List<TestDataSource> dataSources = CreateMRStudyDataSources(numberOfSeries, instancesPerSeries, "1.2.3");

			foreach (var dicomFile in dataSources.Select(d => d.File))
			{
				dicomFile.DataSet[DicomTags.NumberOfFrames].SetInt32(0, framesPerInstance);

				if (dicomFile.DataSet[DicomTags.SeriesNumber].GetInt32(0, 0) != 2) continue;

				var dimUid = "1.2.3.4.5";
				var mfdModule = new MultiFrameDimensionModuleIod(dicomFile.DataSet);
				mfdModule.DimensionOrganizationSequence = new[] {new DimensionOrganizationSequenceItem {DimensionOrganizationUid = dimUid}};
				mfdModule.DimensionIndexSequence = new[]
				                                   	{
				                                   		new DimensionIndexSequenceItem {DimensionIndexPointer = DicomTags.StackId, FunctionalGroupPointer = DicomTags.FrameContentSequence, DimensionOrganizationUid = dimUid},
				                                   		new DimensionIndexSequenceItem {DimensionIndexPointer = DicomTags.InStackPositionNumber, FunctionalGroupPointer = DicomTags.FrameContentSequence, DimensionOrganizationUid = dimUid},
				                                   		new DimensionIndexSequenceItem {DimensionIndexPointer = DicomTags.EffectiveEchoTime, FunctionalGroupPointer = DicomTags.MrEchoSequence, DimensionOrganizationUid = dimUid}
				                                   	};
				var mffgModule = new MultiFrameFunctionalGroupsModuleIod(dicomFile.DataSet);
				mffgModule.PerFrameFunctionalGroupsSequence = Enumerable.Range(0, framesPerInstance).Select(i =>
				                                                                                            	{
				                                                                                            		var fg = new FunctionalGroupsSequenceItem();
				                                                                                            		ushort inStackPositionNumber = (ushort) (i%5 + 1);
				                                                                                            		ushort echoNumber = (ushort) (i/5 + 1);
				                                                                                            		fg.GetFunctionalGroup<FrameContentFunctionalGroup>().FrameContentSequence = new FrameContentSequenceItem {InStackPositionNumber = inStackPositionNumber, StackId = "1", DimensionIndexValues = new uint[] {1, inStackPositionNumber, echoNumber}};
				                                                                                            		fg.GetFunctionalGroup<MrEchoFunctionalGroup>().MrEchoSequence = new MrEchoSequenceItem {EffectiveEchoTime = echoNumber + 5/1000f};
				                                                                                            		return fg;
				                                                                                            	}).ToArray();
			}

			StudyTree studyTree = CreateStudyTree(ConvertToSops(dataSources));

			MREchoDisplaySetFactory factory = new MREchoDisplaySetFactory();
			factory.SetStudyTree(studyTree);
			List<IDisplaySet> allDisplaySets = new List<IDisplaySet>();

			try
			{
				Patient patient = studyTree.Patients[0];
				Study study = patient.Studies[0];

				Assert.AreEqual(numberOfSeries, study.Series.Count, "There should be exactly {0} series", numberOfSeries);

				Series series2 = study.Series[1];

				foreach (Series series in study.Series)
				{
					Assert.AreEqual(instancesPerSeries, series.Sops.Count, "There should be exactly {0} sops", instancesPerSeries);
					List<IDisplaySet> displaySets = factory.CreateDisplaySets(series);
					allDisplaySets.AddRange(displaySets);

					if (series == series2)
					{
						Assert.AreEqual(2, displaySets.Count, "There should be exactly 4 display sets");

						IDisplaySet displaySet = displaySets[0];
						Assert.AreEqual(series.Sops.Count*framesPerInstance/2, displaySet.PresentationImages.Count, "#presentation images should be #Sops/2");
						Assert.AreNotEqual(series.SeriesInstanceUid, displaySet.Descriptor.Uid, "Series UID and Display Set UID don't match");
						Assert.AreEqual(typeof (MREchoDisplaySetDescriptor), displaySet.Descriptor.GetType(), "Wrong display set descriptor type");
						Assert.IsTrue(displaySet.Name.Contains("Echo"), "Display Set name not correct");

						ValidateMultiframeEchoDisplaySet(displaySets[0], 1);
						ValidateMultiframeEchoDisplaySet(displaySets[1], 2);
					}
					else
					{
						//Assert.AreEqual(0, displaySets.Count, "There should be no display sets");
					}
				}
			}
			finally
			{
				foreach (IDisplaySet displaySet in allDisplaySets)
					displaySet.Dispose();

				studyTree.Dispose();
			}
		}