pydicom / deid

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

How to specify Private tags in the recipes #253

Closed howff closed 1 year ago

howff commented 1 year ago

I'm trying to specify a recipe for a specific type of file (from the Ziehm manufacturer) which doesn't fill in the Manufacturer field, only some Private tags. I'm sure that I don't fully understand deid, nor Private tags, but I can't get it to work.

LABEL Ziehm
  contains 0x00190012 ZIEHM_1.0 ImageCaptureData
  ctpcoordinates 0,0,196,148

Am I going about this the wrong way, should I specify Private tags differently?

I can see an easy fix, in filter.py function apply_filter simply

if '0x' in field: field = int(field, 0)
vsoch commented 1 year ago

This could be we are missing that line! Pinging @wetzelj and if you try this out (and it fixed the issue) feel free to open a PR.

wetzelj commented 1 year ago

Interesting. I agree that enabling targeting of private tags in filter sections is something that should be handled and available. While it's not come up as a production use case for us, I could see it happening.

Just glancing at the code, I'm wondering if converting the field to an int will be enough. Does this correctly retrieve the private tag field in all situations? This change would be a great opportunity to add some private tag unit tests to test_filter_detect.py. These tests were initially added focusing on the interplay between two conditions within a rule (#142), but it would be beneficial to add more atomic tests for private/public tags and each of the filter types.

vsoch commented 1 year ago

@howff it sounds like this would be a good addition - would you like to take a shot at the PR? @wetzelj has given direction to the file that we would want to add tests in, and the type of tests to add. Let us know if you have any questions!

howff commented 1 year ago

The rationale for this is that some machines don't fill in the Manufacturer or Model tags so I have to check some Private tags to try and guess what they are. I'm only suggesting adding the ability to specify a tag by number instead of name, in the format 0xGGGGGEEEEE so it could be used to refer to any tag not just private ones. Ideally one could find a private group by name (i.e. the value of a Private Creator) but that I believe is the subject of a different issue #205

I'll see if I can make a PR.

howff commented 1 year ago

Can this issue be closed now?

vsoch commented 1 year ago

yes!