pydicom / deid

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

Question - Filter rules & intended behavior #192

Open wetzelj opened 2 years ago

wetzelj commented 2 years ago

@vsoch - We came across a possible issue today with how filter rules are applied.

In the sample dicom recipe, there are many filter rules defined such as below: deid.dicom - line 26

LABEL LightSpeed Localizers # (Susan Weber)
  contains ManufacturerModelName LightSpeed VCT
  + contains Modality CT
  + contains ImageType LOCAL || contains SeriesDescription Localizer
  coordinates 0,0,80,85

My expectation was that this rule would be applied as: ManufacturerModelName contains "LightSpeed VCT" and Modality contains "CT" and (ImageType contains LOCAL or SeriesDescription contains Localizer)

Instead it was applied as below (without grouping the or condition): ManufacturerModelName contains "LightSpeed VCT" and Modality contains "CT" and ImageType contains LOCAL or SeriesDescription contains Localizer

As a result of this, we greylisted an MRI that had a SeriesDescription of "Localizer".

I suspect this is a bug - and that lines within a filter rule should be considered "grouped", but wanted to check with you first. If you agree this is a bug, I can work on it (although I won't be able to start for a couple weeks). Since we were deidentifying an MRI, we simply removed the two filter rules which were incorrectly hit to get around the current issue.

vsoch commented 2 years ago

Agree they should be grouped! Please take your time and ping me to chat more!