Skip to content

Commit

Permalink
Bug Fixes and Unit Tests for BLANK & REPLACE Actions & Sequences (#242)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wetzelj authored Dec 7, 2022
1 parent 48057c4 commit bd3994f
Show file tree
Hide file tree
Showing 16 changed files with 2,951 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ jobs:
run: |
export PATH="/usr/share/miniconda/bin:$PATH"
source activate testing
pip install deid-data==0.0.17
pip install deid-data
python -m unittest discover -s deid/tests/ -p '[t|T]est*.py'
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ and **Merged pull requests**. Critical items to know are:
Referenced versions in headers are tagged on Github, in parentheses are for pypi.

## [vxx](https://github.com/pydicom/deid/tree/master) (master)

- Expand BLANK Action to additional VRs [#241](https://github.com/pydicom/deid/issues/241) (0.3.2)
- Correct issues with REPLACE action on numeric VRs [#244](https://github.com/pydicom/deid/issues/244)
- Correct issue with actions on fields within sequences [#243](https://github.com/pydicom/deid/issues/243)
- pre-commit for linting and formatting (0.3.1)
- Add `ctpcoordinates` and `ctpkeepcoordinates` to handle different formats (0.3.0)
- Minimum Python required is 3.7, numpy 1.20
Expand Down
19 changes: 7 additions & 12 deletions deid/dicom/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ def get_nested_field(self, field, return_parent=False):
# Otherwise it's an index into a sequence
else:

# If the parent has been removed, we can't continue
if not int(uid) in parent:
# If the sequence is outside the bounds of the array of items
# within the sequence, we can't continue.
if int(uid) < 0 or int(uid) >= len(parent.value):
return None, desired
parent = parent[int(uid)]

Expand All @@ -186,16 +187,10 @@ def blank_field(self, field):
"""
Blank a field
"""
element = self.get_nested_field(field)

# Assert we have a data element, and can blank a string
if element:
if not isinstance(element, DataElement):
bot.warning("Issue parsing %s as a DataElement, not blanked." % field)
elif element.VR in ["US", "SS"]:
element.value = ""
else:
bot.warning("Unrecognized VR for %s, skipping blank." % field)
# Returns the parent, and a DataElement (indexes into parent by tag)
parent, desired = self.get_nested_field(field, return_parent=True)
if parent and desired in parent:
parent[desired].value = None

def replace_field(self, field, value):
"""
Expand Down
Loading

0 comments on commit bd3994f

Please sign in to comment.