Example #1
0
        //[Test]
        public void TestOverlappingSequencePreviousFailure()
        {
            SqId[] test;

            //many of the tests failed because sequence items were not of type InstanceXmlDicomSequenceItem on
            //deserialization and hence can't have any excluded tags.  (InstanceXmlDicomSequenceItem was
            //missing some copy functionality).
            test = new SqId[] { SqId.A, SqId.A, SqId.B };
            TestOverlappingSequence(test, true);
        }
Example #2
0
        public void TestOverlappingSequence()
        {
            string[] symbols   = new string[] { "A", "B", "X" };
            SqId[]   allValues = new SqId[] { SqId.A, SqId.B, SqId.X };

            for (int i = 0; i < allValues.Length; ++i)
            {
                for (int j = 0; j < allValues.Length; ++j)
                {
                    for (int k = 0; k < allValues.Length; ++k)
                    {
                        //NOTE: some tests effectively get duplicated here, but it's much easier this way.
                        SqId[] test = new SqId[] { allValues[i], allValues[j], allValues[k] };

                        try
                        {
                            TestOverlappingSequence(test, false);                             //no exclusion
                        }
                        catch
                        {
                            Trace.WriteLine(String.Format("Test {0}{1}{2} (NO exclusion) failed!", symbols[i], symbols[j], symbols[k]));
                            throw;
                        }

                        try
                        {
                            TestOverlappingSequence(test, true);                             //no exclusion
                        }
                        catch
                        {
                            Trace.WriteLine(String.Format("Test {0}{1}{2} (WITH exclusion) failed!", symbols[i], symbols[j], symbols[k]));
                            throw;
                        }
                    }
                }
            }
        }
Example #3
0
		private void TestOverlappingSequence(SqId[] sequenceIds, bool setMaxTagLength)
		{
			List<DicomFile> images = SetupImagesWithVoiLutSequenceA(sequenceIds.Length);

			for (int i = 0; i < sequenceIds.Length; ++i)
			{
				DicomFile image = images[i];
				SqId sequenceId = sequenceIds[i];
				if (sequenceId == SqId.X)
					image.DataSet[DicomTags.VoiLutSequence] = null;
				else if (sequenceId == SqId.B)
					MakeVoiLutSequenceB(image.DataSet);
			}

			StudyXml newStudyXml;
			StudyXmlOutputSettings settings = new StudyXmlOutputSettings();
			if (setMaxTagLength)
				settings.MaxTagLength = 1024;

			List<InstanceXmlDicomAttributeCollection> dataSets = GetInstanceXmlDataSets(images, out newStudyXml, settings);

			for (int i = 0; i < dataSets.Count; ++i)
			{
				InstanceXmlDicomAttributeCollection dataSet = dataSets[i];
				SqId sequenceId = sequenceIds[i];

				DicomAttribute sequence = dataSets[i][DicomTags.VoiLutSequence];
				DicomSequenceItem[] items = (DicomSequenceItem[])sequence.Values;

				if (sequenceId == SqId.X)
				{
					Assert.IsTrue(sequence.IsEmpty, "Tag should be empty.");
					Assert.IsFalse(dataSet.HasExcludedTags(true), "There should be no excluded tags.");
				}
				else
				{
					Assert.IsFalse(sequence.IsEmpty, "Tag should NOT be empty.");
					if (!setMaxTagLength)
					{
						Assert.AreEqual(sequence, images[i].DataSet[DicomTags.VoiLutSequence], "Tag doesn't match original.");
						Assert.IsFalse(dataSet.HasExcludedTags(true), "There should be no excluded tags.");
					}
					else
					{
						foreach (InstanceXmlDicomSequenceItem item in items)
							Assert.IsTrue(item.IsTagExcluded(DicomTags.LutData), "Tag should be excluded.");
					}

					if (sequenceId == SqId.B)
						Assert.AreEqual(items.Length, 2, "Sequence length should be 2.");
					else
						Assert.AreEqual(items.Length, 3, "Sequence length should be 3.");
				}
			}
		}
Example #4
0
		//[Test]
		public void TestOverlappingSequencePreviousFailure()
		{
			SqId[] test;

			//many of the tests failed because sequence items were not of type InstanceXmlDicomSequenceItem on
			//deserialization and hence can't have any excluded tags.  (InstanceXmlDicomSequenceItem was
			//missing some copy functionality).
			test = new SqId[] { SqId.A, SqId.A, SqId.B };
			TestOverlappingSequence(test, true);
		}
Example #5
0
		public void TestOverlappingSequence()
		{
			string[] symbols = new string[] { "A", "B", "X" };
			SqId[] allValues = new SqId[] { SqId.A, SqId.B, SqId.X };

			for (int i = 0; i < allValues.Length; ++i)
			{
				for (int j = 0; j < allValues.Length; ++j)
				{
					for (int k = 0; k < allValues.Length; ++k)
					{
						//NOTE: some tests effectively get duplicated here, but it's much easier this way.
						SqId[] test = new SqId[] { allValues[i], allValues[j], allValues[k] };

						try
						{
							TestOverlappingSequence(test, false); //no exclusion
						}
						catch
						{
							Trace.WriteLine(String.Format("Test {0}{1}{2} (NO exclusion) failed!", symbols[i], symbols[j], symbols[k]));
							throw;
						}

						try
						{
							TestOverlappingSequence(test, true); //no exclusion
						}
						catch
						{
							Trace.WriteLine(String.Format("Test {0}{1}{2} (WITH exclusion) failed!", symbols[i], symbols[j], symbols[k]));
							throw;
						}
					}
				}
			}
		}
Example #6
0
        private void TestOverlappingSequence(SqId[] sequenceIds, bool setMaxTagLength)
        {
            List <DicomFile> images = SetupImagesWithVoiLutSequenceA(sequenceIds.Length);

            for (int i = 0; i < sequenceIds.Length; ++i)
            {
                DicomFile image      = images[i];
                SqId      sequenceId = sequenceIds[i];
                if (sequenceId == SqId.X)
                {
                    image.DataSet[DicomTags.VoiLutSequence] = null;
                }
                else if (sequenceId == SqId.B)
                {
                    MakeVoiLutSequenceB(image.DataSet);
                }
            }

            StudyXml newStudyXml;
            StudyXmlOutputSettings settings = new StudyXmlOutputSettings();

            if (setMaxTagLength)
            {
                settings.MaxTagLength = 1024;
            }

            List <InstanceXmlDicomAttributeCollection> dataSets = GetInstanceXmlDataSets(images, out newStudyXml, settings);

            for (int i = 0; i < dataSets.Count; ++i)
            {
                InstanceXmlDicomAttributeCollection dataSet = dataSets[i];
                SqId sequenceId = sequenceIds[i];

                DicomAttribute      sequence = dataSets[i][DicomTags.VoiLutSequence];
                DicomSequenceItem[] items    = (DicomSequenceItem[])sequence.Values;

                if (sequenceId == SqId.X)
                {
                    Assert.IsTrue(sequence.IsEmpty, "Tag should be empty.");
                    Assert.IsFalse(dataSet.HasExcludedTags(true), "There should be no excluded tags.");
                }
                else
                {
                    Assert.IsFalse(sequence.IsEmpty, "Tag should NOT be empty.");
                    if (!setMaxTagLength)
                    {
                        Assert.AreEqual(sequence, images[i].DataSet[DicomTags.VoiLutSequence], "Tag doesn't match original.");
                        Assert.IsFalse(dataSet.HasExcludedTags(true), "There should be no excluded tags.");
                    }
                    else
                    {
                        foreach (InstanceXmlDicomSequenceItem item in items)
                        {
                            Assert.IsTrue(item.IsTagExcluded(DicomTags.LutData), "Tag should be excluded.");
                        }
                    }

                    if (sequenceId == SqId.B)
                    {
                        Assert.AreEqual(items.Length, 2, "Sequence length should be 2.");
                    }
                    else
                    {
                        Assert.AreEqual(items.Length, 3, "Sequence length should be 3.");
                    }
                }
            }
        }