public void AnonymizeInPlace_Dataset_PatientDataEmpty() { #if NETFX_CORE var dataset = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync(@"Data/CT1_J2KI").Result.Dataset; #else var dataset = DicomFile.Open(@"./Test Data/CT1_J2KI").Dataset; #endif var anonymizer = new DicomAnonymizer(); anonymizer.AnonymizeInPlace(dataset); Assert.Empty(dataset.GetValues <string>(DicomTag.PatientName)); Assert.Empty(dataset.GetValues <string>(DicomTag.PatientID)); Assert.Empty(dataset.GetValues <string>(DicomTag.PatientSex)); }
public void AnonymizeInPlace_File_ImplementationVersionNameMaintained() { #if NETFX_CORE var file = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync(@"Data/CT1_J2KI").Result; #else var file = DicomFile.Open(@"./Test Data/CT1_J2KI"); #endif var expected = file.FileMetaInfo.ImplementationVersionName; Assert.False(string.IsNullOrEmpty(expected)); var anonymizer = new DicomAnonymizer(); anonymizer.AnonymizeInPlace(file); var actual = file.FileMetaInfo.ImplementationVersionName; Assert.Equal(expected, actual); }
public void AnonymizeInPlace_File_SopInstanceUidTransferredToMetaInfo() { #if NETFX_CORE var file = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync(@"Data/CT1_J2KI").Result; #else var file = DicomFile.Open(@"./Test Data/CT1_J2KI"); #endif var old = file.Dataset.GetSingleValue <DicomUID>(DicomTag.SOPInstanceUID); var anonymizer = new DicomAnonymizer(); anonymizer.AnonymizeInPlace(file); var expected = file.Dataset.GetSingleValue <DicomUID>(DicomTag.SOPInstanceUID); var actual = file.FileMetaInfo.MediaStorageSOPInstanceUID; Assert.NotEqual(expected, old); Assert.Equal(expected, actual); }
public void AnonymizeInPlace_RemovableSequence_ShouldBeRemoved() { const string fileName = "GH610.dcm"; var tag = DicomTag.OriginalAttributesSequence; #if NETFX_CORE var dataset = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync($"Data/{fileName}").Result.Dataset; #else var dataset = DicomFile.Open($"./Test Data/{fileName}").Dataset; #endif Assert.True(dataset.Contains(tag)); var anonymizer = new DicomAnonymizer(); anonymizer.AnonymizeInPlace(dataset); Assert.False(dataset.Contains(tag)); }
public void AnonymizeInPlace_SeriesDate_ShouldBeRemoved() { const string fileName = "CT1_J2KI"; var tag = DicomTag.SeriesDate; #if NETFX_CORE var dataset = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync($"Data/{fileName}").Result.Dataset; #else var dataset = DicomFile.Open($"./Test Data/{fileName}").Dataset; #endif Assert.True(dataset.GetSingleValue <string>(tag).Length > 0); var anonymizer = new DicomAnonymizer(); anonymizer.AnonymizeInPlace(dataset); var contains = dataset.Contains(tag); Assert.False(contains); }
public void AnonymizeInPlace_StudyDate_ShouldBeEmpty() { const string fileName = "CT1_J2KI"; var tag = DicomTag.StudyDate; #if NETFX_CORE var dataset = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync($"Data/{fileName}").Result.Dataset; #else var dataset = DicomFile.Open($"./Test Data/{fileName}").Dataset; #endif Assert.True(dataset.GetSingleValue <string>(tag).Length > 0); var anonymizer = new DicomAnonymizer(); anonymizer.AnonymizeInPlace(dataset); var expected = new string[0]; var actual = dataset.GetValues <string>(tag); Assert.Equal(expected, actual); }
public void AnonymizeInPlace_SequenceToKeep_NestedDatasetsShouldBeParsed() { const string fileName = "GH610.dcm"; var tag1 = DicomTag.ROIContourSequence; var tag2 = DicomTag.ContourSequence; var tag3 = DicomTag.ContourImageSequence; var generatedUid1 = DicomUIDGenerator.GenerateNew(); var generatedUid2 = DicomUIDGenerator.GenerateNew(); #if NETFX_CORE var dataset = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync($"Data/{fileName}").Result.Dataset; #else var dataset = DicomFile.Open($"./Test Data/{fileName}").Dataset; #endif dataset.Add(new DicomSequence(tag1, new DicomDataset( new DicomSequence(tag2, new DicomDataset( new DicomSequence(tag3, new DicomDataset( new DicomUniqueIdentifier(DicomTag.ReferencedSOPInstanceUID, generatedUid1.UID), new DicomIntegerString(DicomTag.ReferencedFrameNumber, 1) ), new DicomDataset( new DicomUniqueIdentifier(DicomTag.ReferencedSOPInstanceUID, generatedUid2.UID), new DicomIntegerString(DicomTag.ReferencedFrameNumber, 2) ) )) )) )); var anonymizer = new DicomAnonymizer(); anonymizer.AnonymizeInPlace(dataset); Assert.True(dataset.Contains(tag1)); var sequence1 = dataset.Get <DicomSequence>(tag1); var sequence2 = sequence1.Items[0].Get <DicomSequence>(tag2); var sequence3 = sequence2.Items[0].Get <DicomSequence>(tag3); Assert.NotEqual(sequence3.Items[0].Get <DicomUID>(DicomTag.ReferencedSOPInstanceUID), sequence3.Items[1].Get <DicomUID>(DicomTag.ReferencedSOPInstanceUID)); Assert.NotEqual(generatedUid1, sequence3.Items[0].Get <DicomUID>(DicomTag.ReferencedSOPInstanceUID)); Assert.NotEqual(generatedUid2, sequence3.Items[1].Get <DicomUID>(DicomTag.ReferencedSOPInstanceUID)); Assert.Equal(1, sequence3.Items[0].Get <int>(DicomTag.ReferencedFrameNumber)); Assert.Equal(2, sequence3.Items[1].Get <int>(DicomTag.ReferencedFrameNumber)); }
public void AnonymizeInPlace_ClearableSequence_ShouldBeCleared() { const string fileName = "GH610.dcm"; var tag = DicomTag.PersonIdentificationCodeSequence; #if NETFX_CORE var dataset = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync($"Data/{fileName}").Result.Dataset; #else var dataset = DicomFile.Open($"./Test Data/{fileName}").Dataset; #endif dataset.Add(new DicomSequence(tag, new DicomDataset(new DicomLongString(DicomTag.CodeMeaning, "SOME MEANING")))); var anonymizer = new DicomAnonymizer(); anonymizer.AnonymizeInPlace(dataset); Assert.True(dataset.Contains(tag)); var sequence = dataset.Get <DicomSequence>(tag); Assert.Equal(0, sequence.Items.Count); }