public void Anonymize_Dataset_OriginalDatasetNotModified() { #if NETFX_CORE var dataset = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync(@"Data/CT-MONO2-16-ankle").Result.Dataset; #else var dataset = DicomFile.Open(@"./Test Data/CT-MONO2-16-ankle").Dataset; #endif var expected = dataset.GetSingleValue <DicomUID>(DicomTag.StudyInstanceUID); var anonymizer = new DicomAnonymizer(); var newDataset = anonymizer.Anonymize(dataset); var actual = dataset.GetSingleValue <DicomUID>(DicomTag.StudyInstanceUID); var actualNew = newDataset.GetSingleValue <DicomUID>(DicomTag.StudyInstanceUID); Assert.Equal(expected, actual); Assert.NotEqual(expected, actualNew); }
public void AnonymizeInPlace_BasicProfile() { const string fileName = "CT1_J2KI"; #if NETFX_CORE var dataset = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync($"Data/{fileName}").Result.Dataset; #else var dataset = DicomFile.Open($"./Test Data/{fileName}").Dataset; #endif var profile = DicomAnonymizer.SecurityProfile.LoadProfile(null, DicomAnonymizer.SecurityProfileOptions.BasicProfile); var anony = new DicomAnonymizer(profile); var anonymized = anony.Anonymize(dataset); Assert.NotEqual(dataset.GetString(DicomTag.PatientName), anonymized.GetString(DicomTag.PatientName)); Assert.NotEqual(dataset.GetString(DicomTag.PatientAge), anonymized.GetSingleValueOrDefault(DicomTag.PatientAge, string.Empty)); Assert.NotEqual(dataset.GetString(DicomTag.PatientID), anonymized.GetSingleValueOrDefault(DicomTag.PatientID, string.Empty)); }
public void Anonymize_UsePredefinedPatientNameAndId_ShouldBeSetInAnonymizedDataset() { const string fileName = "CT1_J2KI"; #if NETFX_CORE var dataset = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync($"Data/{fileName}").Result.Dataset; #else var dataset = DicomFile.Open($"./Test Data/{fileName}").Dataset; #endif const string expectedName = "fo-dicom"; const string expectedId = "GH-575"; var anonymizer = new DicomAnonymizer(); anonymizer.Profile.PatientName = expectedName; anonymizer.Profile.PatientID = expectedId; var newDataset = anonymizer.Anonymize(dataset); var actualName = newDataset.GetSingleValue <string>(DicomTag.PatientName); var actualId = newDataset.GetSingleValue <string>(DicomTag.PatientID); Assert.Equal(expectedName, actualName); Assert.Equal(expectedId, actualId); }