pydicom / deid

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

Deidentification Exception in Filters #256

Open wetzelj opened 1 year ago

wetzelj commented 1 year ago

When adding a filter rule which targeted a non-string field (DICOM VR - DS) the empty() function in filter.py throws an exception - "'DSfloat' object has no attribute 'value'".

Filter rule:

LABEL Check for Empty RepetitionTime
  empty RepetitionTime

Root cause: Currently in filter.py - line 155 we assume that if the content (returned from pydicom.DataSet.get()) is not a string, it's a DataElement. With this assumption we then attempt to get the value property of the content object. Depending on the parameter passed into get(), the returned value will either be the value from the tag or a DataElement. In the case of our filter rule above, the value returned from get() was of type DSfloat (not string), and threw an exception/

Proposed fix (Pull request coming shortly) Instead of checking content is not string, reverse the logic and instead explicitly check for content being an instance of DataElement.