Skip to content

Commit a1f35d4

Browse files
authored
Merge pull request #806 from UNFmontreal/enh/filter_dicom_earlier
[ENH] filter dicoms earlier to avoid nibabel crash with XA ill-formed mutli-planar localizer dicoms
2 parents 5b1718b + b31d13e commit a1f35d4

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

heudiconv/dicoms.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ def validate_dicom(
169169
Parse DICOM attributes. Returns None if not valid.
170170
"""
171171
mw = dw.wrapper_from_file(fl, force=True, stop_before_pixels=True)
172-
# clean series signature
173-
for sig in ("iop", "ICE_Dims", "SequenceName"):
174-
try:
175-
del mw.series_signature[sig]
176-
except KeyError:
177-
pass
178172
# Workaround for protocol name in private siemens csa header
179173
if not getattr(mw.dcm_data, "ProtocolName", "").strip():
180174
mw.dcm_data.ProtocolName = (
@@ -203,6 +197,12 @@ def validate_dicom(
203197
except AttributeError:
204198
lgr.info("File {} is missing any StudyInstanceUID".format(fl))
205199
file_studyUID = None
200+
# clean series signature
201+
for sig in ("iop", "ICE_Dims", "SequenceName"):
202+
try:
203+
del mw.series_signature[sig]
204+
except KeyError:
205+
pass
206206
return mw, series_id, file_studyUID
207207

208208

heudiconv/heuristics/reproin.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,11 @@ def infotodict(
406406
# XXX: skip derived sequences, we don't store them to avoid polluting
407407
# the directory, unless it is the motion corrected ones
408408
# (will get _rec-moco suffix)
409-
if skip_derived and curr_seqinfo.is_derived and not curr_seqinfo.is_motion_corrected:
409+
if (
410+
skip_derived
411+
and curr_seqinfo.is_derived
412+
and not curr_seqinfo.is_motion_corrected
413+
):
410414
skipped.append(curr_seqinfo.series_id)
411415
lgr.debug("Ignoring derived data %s", curr_seqinfo.series_id)
412416
continue
@@ -552,7 +556,10 @@ def infotodict(
552556
# XXX if we have a known earlier study, we need to always
553557
# increase the run counter for phasediff because magnitudes
554558
# were not acquired
555-
if get_study_hash([curr_seqinfo]) == "9d148e2a05f782273f6343507733309d":
559+
if (
560+
get_study_hash([curr_seqinfo])
561+
== "9d148e2a05f782273f6343507733309d"
562+
):
556563
current_run += 1
557564
else:
558565
raise RuntimeError(

0 commit comments

Comments
 (0)