Skip to content

Conversation

bpinsard
Copy link
Contributor

see nipy/nibabel#1392 (comment)

Apparently some of the validation of the dicom triggers nibabel.nicom that crashes on ill-formed dicoms.
Moving the dicom filter a bit before, allow to easily filter these with the heuristics filter_dicom.
I should not change anything to the results.

Copy link

codecov bot commented Dec 13, 2024

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.84%. Comparing base (5b1718b) to head (b31d13e).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
heudiconv/heuristics/reproin.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #806   +/-   ##
=======================================
  Coverage   82.84%   82.84%           
=======================================
  Files          42       42           
  Lines        4313     4313           
=======================================
  Hits         3573     3573           
  Misses        740      740           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dangom
Copy link

dangom commented Aug 22, 2025

Affected by this as well. Any change this could be merged?!

@hbraunDSP
Copy link
Contributor

I am also affected by this; adding my voice to the merge requests.

Are we waiting on test coverage?

Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Sorry it takes awhile to get to them.

I left some questions to clarify the changes. Also I wonder if there is an easy way for a test, even if it would just be a smoke test to show that it crashed before and no longer? ;)

@@ -226,7 +226,7 @@ def _delete_chars(from_str: str, deletechars: str) -> str:

def filter_dicom(dcmdata: dcm.dataset.Dataset) -> bool:
"""Return True if a DICOM dataset should be filtered out, else False"""
return True if dcmdata.StudyInstanceUID in dicoms2skip else False
return True if dcmdata.get("StudyInstanceUID") in dicoms2skip else False
Copy link
Member

Choose a reason for hiding this comment

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

why this change was necessary? (the others in the file are just formatting, and should not be needed)

@@ -203,6 +194,15 @@ def validate_dicom(
except AttributeError:
lgr.info("File {} is missing any StudyInstanceUID".format(fl))
file_studyUID = None
if dcmfilter is not None and dcmfilter(mw.dcm_data):
lgr.warning("Ignoring %s because of DICOM filter", fl)
return None
Copy link
Member

Choose a reason for hiding this comment

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

I am a little confused -- it seems that you moved filtering later not earlier!

I do see that you made it so it clears/deletes signatures now later than filtering is done, so would that suffice -- just to move deletion of signatures and keeping the rest of the code as is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right, the main issue was while deleting signature on malformed dicoms. I reset the position of the call to filter dicoms and reverted the heuristics change that was no longer required.

@bpinsard bpinsard force-pushed the enh/filter_dicom_earlier branch from 4ce1119 to b31d13e Compare September 2, 2025 15:23
@yarikoptic yarikoptic added the patch Increment the patch version when merged label Sep 2, 2025
@yarikoptic yarikoptic merged commit a1f35d4 into nipy:master Sep 2, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants