Skip to content
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

REPLACE action fails on numeric VR #244

Closed
wetzelj opened this issue Dec 2, 2022 · 1 comment
Closed

REPLACE action fails on numeric VR #244

wetzelj opened this issue Dec 2, 2022 · 1 comment

Comments

@wetzelj
Copy link
Contributor

wetzelj commented Dec 2, 2022

When specifying a recipe action on header fields which are defined by numeric VRs, the action fails with an exception from pydicom during the file write operation.

./test_replace_action.py::TestReplaceAction::test_replace_FD Failed with Error: With tag (0018, 9306) got exception: required argument is not a float
for data_element:
(0018, 9306) Single Collimation Width            FD: '1.3'
Traceback (most recent call last):
  File "C:\Users\wetzelj\.conda\envs\deid-core-py38\lib\site-packages\pydicom\filewriter.py", line 269, in write_numbers
    value.append
AttributeError: 'str' object has no attribute 'append'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\wetzelj\.conda\envs\deid-core-py38\lib\site-packages\pydicom\filewriter.py", line 271, in write_numbers
    fp.write(pack(format_string, value))
struct.error: required argument is not a float

All values are currently read in from the recipe file as string. To write the file appropriately, pydicom requires that numeric VRs be added with values that are the correct type (due to usage of struct.pack() in filewriter.py.
Full details of the python types which can be used to set VRs can be seen here.

This issue currently impacts the following VRs:

  • FD - float expected
  • FL - float expected
  • SL - integer expected
  • SS - integer expected
  • SV - integer expected
  • UL - integer expected
  • UN - bytes-like object expected
  • US - integer expected
  • UV - integer expected

This was discovered while working on #242.

wetzelj added a commit to wetzelj/deid that referenced this issue Dec 2, 2022
vsoch pushed a commit that referenced this issue Dec 7, 2022
* Expand BLANK Action to other VRs

1. Expanded BLANK Action to other VRs.
2. Added unit tests for validating action interaction.
3. Added table of action interactions to help docs.

* Update recipe-headers.md
* Update test_action_interaction.py
Correcting bad test method names.
* Update deid-data install version
* Update parser.py

Reverted expand_field_expression to always return desired as a Tag.  Instead convert to DataElement in blank_field.

* Expanding blank to all VRs
Updating BLANK test coverage to all VRs.
* Updating field counts in unit tests.
Updating unit tests failing due to field count changes in test image.
* Update test_blank_action.py
Restructured blank_action unit tests.
* Fix for #244 - Replace fails for numeric VR
Removing deid-data pin.
* Update actions.py
Committing review suggestions.
* Header Sequence Updates
Corrected issue #243 which prevented tags within sequences from being acted upon.   Added unit tests for sequence processing

* Update test_replace_identifiers.py
Updated test_replace_identifiers to target ctbrain1.dcm by name.
* Update test_dicom_funcs.py

Updated test_user_provided_func to target ctbrain1.dcm
@vsoch
Copy link
Member

vsoch commented Dec 7, 2022

Closed with #242

@vsoch vsoch closed this as completed Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants