pydicom / deid

best effort anonymization for medical images using python
https://pydicom.github.io/deid/
MIT License
140 stars 43 forks source link

Saving `replace_identifiers` output : Request #161

Closed vpapaioannou closed 3 years ago

vpapaioannou commented 3 years ago

When running replace_identfiers with save = True, output_folder = myoutput and overwrite = False it seems that file e.g. /a/b/c.dcm is saved as myoutput/c.dcm. However, if there is another file a/d/c.dcm then there is a conflict and error ERROR image1.dcm already exists, overwrite set to False. Not writing. is thrown.

Then, the feature request is to be able to save the files as myoutput/b/c.dcm and myoutput/d/c.dcm especially when the absolute path of the files is known.

Could that be possible? Would you like me to do that?

vsoch commented 3 years ago

@vpapaioannou the purpose of the overwrite argument is that, when set to True, if the file already exists it will write over it, exactly as you've specified. The default is set to False, as a protection to the user that might be writing over an existing file they didn't know about.

vpapaioannou commented 3 years ago

I want to have both files e.g. same file name from two different sources saved in a way reflecting the different origin.

vsoch commented 3 years ago

The organization of your output folders is up to you. If you want to save reflecting a different origin, then I'd just call the function twice with two output folders with different roots.

replace_identifiers(files_subject1, save=True, output_folder="/tmp/subject1")
replace_identifiers(files_subject1, save=True, output_folder="/tmp/subject2")

You can also just change the input file names to reflect what you need.