From 4ce111940af14bdf96d7f1795cac5a135d2c5b76 Mon Sep 17 00:00:00 2001 From: cneuromod_bot Date: Fri, 13 Dec 2024 11:22:56 -0500 Subject: [PATCH] reorder again to improve testcov: clean signatures at the end --- heudiconv/dicoms.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/heudiconv/dicoms.py b/heudiconv/dicoms.py index 1c79c4c7..d8d4ab31 100644 --- a/heudiconv/dicoms.py +++ b/heudiconv/dicoms.py @@ -169,15 +169,6 @@ def validate_dicom( Parse DICOM attributes. Returns None if not valid. """ mw = dw.wrapper_from_file(fl, force=True, stop_before_pixels=True) - if dcmfilter is not None and dcmfilter(mw.dcm_data): - lgr.warning("Ignoring %s because of DICOM filter", fl) - return None - # clean series signature - for sig in ("iop", "ICE_Dims", "SequenceName"): - try: - del mw.series_signature[sig] - except KeyError: - pass # Workaround for protocol name in private siemens csa header if not getattr(mw.dcm_data, "ProtocolName", "").strip(): mw.dcm_data.ProtocolName = ( @@ -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 + # clean series signature + for sig in ("iop", "ICE_Dims", "SequenceName"): + try: + del mw.series_signature[sig] + except KeyError: + pass return mw, series_id, file_studyUID