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
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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==0.0.19
wetzelj marked this conversation as resolved.
Show resolved Hide resolved
python -m unittest discover -s deid/tests/ -p '[t|T]est*.py'
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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)
- 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
13 changes: 8 additions & 5 deletions deid/dicom/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,19 @@ def blank_field(self, field):
"""
Blank a field
"""
element = self.get_nested_field(field)
tag = self.get_nested_field(field)
if tag in self.dicom:
element = self.dicom[tag]
else:
element = None
bot.warning(f"Field {field} not found in DICOM header.")

# 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 = ""
bot.warning(f"Issue parsing {field} as a DataElement, not blanked.")
else:
bot.warning("Unrecognized VR for %s, skipping blank." % field)
element.value = None

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