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

Bug Fixes and Unit Tests for BLANK & REPLACE Actions & Sequences #242

Merged
merged 21 commits into from
Dec 7, 2022

Conversation

wetzelj
Copy link
Contributor

@wetzelj wetzelj commented Nov 30, 2022

Description

  1. Updated BLANK action to function on all VRs.
  2. Added unit tests to ensure BLANK functions on all newly added VRs.
  3. Added unit tests to validate multiple actions on a single field. Added documentation which describes the current interactions.
  4. Corrected issue with REPLACE on numeric VRs (and URI as well).
  5. Added unit tests to validate REPLACE on all (applicable?) VRs. Currently SQ, and the O* VRs are excluded.
  6. Corrected issue preventing actions from executing on fields within sequences.

Related issues:

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • My code follows the style guidelines of this project

Open questions

  1. For the interaction unit tests and documentation, I simply test and document what the library currently does as of v0.3.1. I would appreciate a closer review of this. As I was building these tests, some of the interactions were not what I expected... but that may just be my mind working a little differently than others! :)

1. Expanded BLANK Action to other VRs.
2. Added unit tests for validating action interaction.
3. Added table of action interactions to help docs.
@wetzelj
Copy link
Contributor Author

wetzelj commented Nov 30, 2022

The testing is failing due to the changes that were merged into deid-data. The CI testing is still using the old image.

@vsoch
Copy link
Member

vsoch commented Nov 30, 2022

Old image == old release?

@vsoch
Copy link
Member

vsoch commented Nov 30, 2022

@wetzelj if you can do a PR to bump the version / changelog over there, I can make a new release!

@wetzelj
Copy link
Contributor Author

wetzelj commented Nov 30, 2022

Yeah... sorry about that. I just realized I didn't bump the version of deid-data. Will do it now.

Correcting bad test method names.
@vsoch
Copy link
Member

vsoch commented Dec 1, 2022

okay sorry for delay - went into meetings and just coming out! I just merged/released deid-data and did a re-run of the test.

deid/dicom/parser.py Outdated Show resolved Hide resolved
Reverted expand_field_expression to always return desired as a Tag.  Instead convert to DataElement in blank_field.
Updating BLANK test coverage to all VRs.
Updating unit tests failing due to field count changes in test image.
Restructured blank_action unit tests.
@vsoch
Copy link
Member

vsoch commented Dec 2, 2022

Woot! passing now, and these tests are fantastic! @wetzelj when you are ready for merge, it shall be so.

@wetzelj
Copy link
Contributor Author

wetzelj commented Dec 2, 2022

Thanks! I'm working on a fix for #244 as well that I'd like to get included in this PR (along with some new tests for REPLACE which mirror what I did for BLANK).

@vsoch
Copy link
Member

vsoch commented Dec 2, 2022

@wetzelj you're amazing!!

@wetzelj wetzelj changed the title Expand BLANK Action to Additional VRs Bug Fixes and Unit Tests for BLANK & REPLACE Dec 2, 2022
@wetzelj
Copy link
Contributor Author

wetzelj commented Dec 2, 2022

@vsoch - I think I'm set on what I'd like to get in this PR, but am interested in your feedback if there's anything that you'd like done differently.

.github/workflows/main.yaml Outdated Show resolved Hide resolved
deid/utils/actions.py Outdated Show resolved Hide resolved
deid/utils/actions.py Show resolved Hide resolved
deid/utils/actions.py Outdated Show resolved Hide resolved
deid/utils/actions.py Outdated Show resolved Hide resolved
wetzelj and others added 3 commits December 2, 2022 16:38
Removing deid-data pin.
Co-authored-by: Vanessasaurus <814322+vsoch@users.noreply.github.com>
Committing review suggestions.
@wetzelj
Copy link
Contributor Author

wetzelj commented Dec 6, 2022

Adding #243 to this PR as well. Please hold off merging. New commits will arrive tomorrow.

Corrected issue pydicom#243 which prevented tags within sequences from being acted upon.   Added unit tests for sequence processing.
@wetzelj wetzelj changed the title Bug Fixes and Unit Tests for BLANK & REPLACE Bug Fixes and Unit Tests for BLANK & REPLACE Actions & Sequences Dec 7, 2022
Updated test_replace_identifiers to target ctbrain1.dcm by name.
Updated test_user_provided_func to target ctbrain1.dcm
@@ -160,8 +160,9 @@ def get_nested_field(self, field, return_parent=False):
# Otherwise it's an index into a sequence
else:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an explanation of the change below:

If we fall into the else, the uid is a sequence. We don't want to check for it's presence in a dictionary, but instead want to check to ensure that the uid (index) is within the bounds of the array of items in the SQ DataElements value which is a Sequence - an iterable. If the index is outside the bounds we return None as the parent. If the index is within the bounds of the array, we want to return the DataElement at that index (the specific occurrence of the
sequence element) for update.

@@ -118,16 +118,12 @@ def test_replace_with_constant(self):
]
recipe = create_recipe(actions)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation of the change below:

After implementing the change for sequence processing, this unit test was failing with an index out of bounds exception. This exception was occurring because the DicomParser object was applying the stock deid.dicom recipe which was causing the Accession Number field to be removed. I did not dig into why the sequence change affected this unittest in this manner, but since it was only impacting the check for getting the "before" values and all other unit tests passed, I didn't feel that it warranted further investigation. Instead I just updated this to red the file and directly retrieve the "before" values

@wetzelj
Copy link
Contributor Author

wetzelj commented Dec 7, 2022

@vsoch - This wraps up what I'm intending (plus a little more) for this PR. Once you're good with the inclusions, please go ahead with the merge at your convenience.

@vsoch vsoch merged commit bd3994f into pydicom:master Dec 7, 2022
@vsoch
Copy link
Member

vsoch commented Dec 7, 2022

Woohoo! Well done. https://pypi.org/project/deid/0.3.2/

@wetzelj
Copy link
Contributor Author

wetzelj commented Dec 7, 2022

Woohoo! Well done. https://pypi.org/project/deid/0.3.2/

Thank you! Speedy merge as always! :)

@vsoch
Copy link
Member

vsoch commented Dec 7, 2022

I just happen to be up since 6am debugging registry authentication for another OSS project - trying to squeeze in before the workday. Hashtag, maintainer life! 😆

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

Successfully merging this pull request may close these issues.

2 participants