-
-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Description
Hello,
Thank you for this great project.
While using it in our codebase, I have found the following issue.
anonymize_dataset fails if dataset contains RawDataElement
anonymize_dataset fails if the dataset contains RawDataElement:
- element children of a dataset can be either DataElement or RawDataElement: it do not understand the details of pydicom which trigger this.
- RawDataElement are not mutable. This means that the anoymization code:
element.value = new_valuefails. In my case, it's in replace_element_UID (https://github.com/KitwareMedical/dicom-anonymizer/blob/master/dicomanonymizer/simpledicomanonymizer.py#L96) but I believe that all other rules have the same issue. - In our code, I have fixed this by sanitizing the input dataset before calling anonymize_dataset. I iterate through it and replace all RawDataElement with DataElement (there is a pydicom built-in for this: https://pydicom.github.io/pydicom/dev/reference/generated/pydicom.dataelem.DataElement_from_raw.html)
Proposed solution
I would be happy to create a PR to fix this issue here too.
I see two possibilities:
- Sanitize dataset as part of anonymize_dataset:
- iterate over the dataset and replace RawDataElements,
- continue with the current code of anonymize_dataset.
- Modify current replace_element code to handle the RawDataElement case.
I'm partial to solution 1.:
- it's simple and easy to understand and review.
- it makes it easier for the user to add custom-rules since they are able to assume that all elements are RawDataElement, and they can use the simpler: element.value = new_value syntax.
- however, it also means that input dataset are walked-through twice. I feel that this price is worth paying.
Best
Guillaume
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels