-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for python 3.12, pyproject.toml, minor naming cleanups #57
Conversation
README.md
Outdated
# Create a list of tags object that should contains id, type and value | ||
fields = [ | ||
{ # Replaced by Anonymized | ||
'id': (0x0040, 0xA123), | ||
'type': 'LO', | ||
'value': 'Annie de la Fontaine', | ||
}, | ||
{ # Replaced with empty value | ||
'id': (0x0008, 0x0050), | ||
'type': 'TM', | ||
'value': 'bar', | ||
}, | ||
{ # Deleted | ||
'id': (0x0018, 0x4000), | ||
'type': 'VR', | ||
'value': 'foo', | ||
} | ||
] | ||
|
||
# Create a readable dataset for pydicom | ||
data = pydicom.Dataset() | ||
|
||
# Add each field into the dataset | ||
for field in fields: | ||
data.add_new(field['id'], field['type'], field['value']) | ||
|
||
anonymize_dataset(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you delete this example ? This can be useful.
Why not moving it in the examples folder you created ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this example and could not get it to work. I can fix the first warning about 'bar' not being valid for TM
, but have no idea how to fix the error of missing file_meta
for the dataset. I took the easier route of using an existing DICOM data file!
Here is the output:
C:\Users\smjoshi\.virtualenvs\examples-gxyY8XxM\Lib\site-packages\pydicom\valuerep.py:443: UserWarning: Invalid value for VR TM: 'bar'.
warnings.warn(msg)
Traceback (most recent call last):
File "C:\development\dicom-anonymizer\examples\anonymize_fields.py", line 33, in <module>
main()
File "C:\development\dicom-anonymizer\examples\anonymize_fields.py", line 30, in main
anonymize_dataset(data)
File "C:\development\dicom-anonymizer\dicomanonymizer\simpledicomanonymizer.py", line 436, in anonymize_dataset
action(dataset.file_meta, tag)
^^^^^^^^^^^^^^^^^
File "C:\Users\smjoshi\.virtualenvs\examples-gxyY8XxM\Lib\site-packages\pydicom\dataset.py", line 908, in __getattr__
return object.__getattribute__(self, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Dataset' object has no attribute 'file_meta'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be fixed with #61
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I will pull in the changes into my branch and that should clean up this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have restored the example in README.md
(actually, I copy-pasted your code, so the white-space differences are showing up!). Please re-review.
pyproject.toml
Outdated
] | ||
description = "Program to anonymize dicom files with default and custom rules" | ||
readme = "README.md" | ||
requires-python = ">=3.10" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why restrict to 3.10 and higher ? I tested with Python 3.9 and 3.8 and it seems to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my confusion. Per importlib.metadata documentation, it was "provisional" until 3.10, so I thought it was not available for versions 3.8 and 3.9. Since these worked, I will update this minimum requirement to 3.8.
Thank you for testing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit b3dc158
Thank you very much for your work ! |
Merge from upstream
Merge from base repo
This pull request brings in these changes:
setup.cfg
andsetup.py
withpyproject.toml
. See issue Strategy for Python version compatibility? #54 .README.md
changesanonymize
. The API requiresdelete_private_tags
argument,anonymize_dataset
. The previous one was throwing exception from pydicomexamples
directory to ensure they workanonymizer.py
Changespkg_resources
withimportlib
delete_private_tags
to sync up with the same argument foranonymize_dataset
and PEP 8 style guide