pydicom / deid

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

Fix/remove sequences #138

Closed wetzelj closed 4 years ago

wetzelj commented 4 years ago

Description

Related issues: #137 Added additional check in tags.py to ensure that the element exists prior to attempting the element deletion in the remove_sequences function. Nested sequences will be removed when the parent sequence is removed, and therefore, when the child is attempted to be removed (as a result of being in the initial dicom.iterall()), it will not be present, previously resulting in a KeyError. This fix, checks to ensure that the sequence being deleted still exists in the header prior to attempting the deletion.

Checklist

Open questions

Questions that require more discussion or to be addressed in future development: To keep this PR tightly scoped, this is limited to just the strip_sequences functionality with replace_identifiers. This is not intended to evaluate or test specific actions against tags that exist as top-level tags and child tags within a sequence.

vsoch commented 4 years ago

Looks great! Sorry for the delayed response, GitHub pages has been coughing and I've been trying to release the RSE Stories podcast episode - it finally went through. I've already reviewed this and you added a great docstring to explain the test, so I'm good to merge!