Skip to content

Commit

Permalink
make repronim dicom filter more robust, due to filtering earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
bpinsard committed Dec 13, 2024
1 parent 5493d65 commit 357c109
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions heudiconv/heuristics/reproin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


def filter_files(_fn: str) -> bool:
Expand Down Expand Up @@ -406,7 +406,11 @@ def infotodict(
# XXX: skip derived sequences, we don't store them to avoid polluting
# the directory, unless it is the motion corrected ones
# (will get _rec-moco suffix)
if skip_derived and curr_seqinfo.is_derived and not curr_seqinfo.is_motion_corrected:
if (
skip_derived
and curr_seqinfo.is_derived
and not curr_seqinfo.is_motion_corrected
):
skipped.append(curr_seqinfo.series_id)
lgr.debug("Ignoring derived data %s", curr_seqinfo.series_id)
continue
Expand Down Expand Up @@ -552,7 +556,10 @@ def infotodict(
# XXX if we have a known earlier study, we need to always
# increase the run counter for phasediff because magnitudes
# were not acquired
if get_study_hash([curr_seqinfo]) == "9d148e2a05f782273f6343507733309d":
if (

Check warning on line 559 in heudiconv/heuristics/reproin.py

View check run for this annotation

Codecov / codecov/patch

heudiconv/heuristics/reproin.py#L559

Added line #L559 was not covered by tests
get_study_hash([curr_seqinfo])
== "9d148e2a05f782273f6343507733309d"
):
current_run += 1
else:
raise RuntimeError(
Expand Down

0 comments on commit 357c109

Please sign in to comment.