rexcardan / Evil-DICOM

A C# DICOM Library
169 stars 98 forks source link

Anonymization fails for RP-files #82

Open Kiragroh opened 3 years ago

Kiragroh commented 3 years ago

Hi Rex,

thanks for EvilDICOM. I love to use it.

Sadly, I run into a problem today. I want to build a standalone DICOM-Anonymizer (inspired by 'Varian-Code-Samples/webinars & workshops/Developer Workshop 2014/guru track projects/DICOM Anonymizer' but without Eclipse).

I used the EvilDicom-Example-Code and it works for CT-, RD- and RS-files but not for RP-files. Can you please assist? I get an enumeration error but it makes no sense. Something strange with the queue.

Here are test files for you: https://www.dropbox.com/sh/9x8x3384jayw4ox/AAAC24b_l1JhGyz3M1y3WD3Na?dl=0

Here is the relevant CodeSnippet: private void AnonymizeButton_Click(object sender, RoutedEventArgs e) {

        //string dir = currentFolderPath;
        string dir = @"C:\Users\m\Desktop\_test";

        string [] toAnonymize = Directory.GetFiles(dir);

        var settings = EvilDICOM.Anonymization.Settings.AnonymizationSettings.Default;
        //Change mapping but keep connections
        settings.DoAnonymizeUIDs = true;
        settings.DoAnonymizeStudyIDs = true;
        settings.DoRemovePrivateTags = true;
        settings.DoAnonymizeNames = true;
        settings.FirstName = "";
        //settings.LastName = LastNameTextBox.Text;
        //settings.Id = patientIdTextBox.Text;

        //Gets a current list of UIDs so it can create new ones 
        var queue = EvilDICOM.Anonymization.AnonymizationQueue.BuildQueue(settings, toAnonymize);

        foreach (string file in toAnonymize)
        {
            //ShowLogMsg("Anonymizing "+ file);
            var dcm = EvilDICOM.Core.DICOMObject.Read(file);
            queue.Anonymize(dcm);
            //Write back to initial location - though this can be a different place
            dcm.Write(file.Replace(dir, @"C:\Users\m\Desktop\_anon"));
        }
    }

Best regards Max

Kiragroh commented 3 years ago

I solved my problem by going back to version 2.0.5.5. All future versions have the problem.