From 24f4d88eccb53b996dc20dbfb979c8c3d09e9bd8 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 8 Feb 2023 11:37:35 -0500 Subject: [PATCH] Also tollerate IndexError while trying to delete a field in mw Closes #633 Somewhat of a blind fix without looking to deep why we get IndexError instead of KeyError --- heudiconv/dicoms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/heudiconv/dicoms.py b/heudiconv/dicoms.py index 1a5c2b95..88ac907e 100644 --- a/heudiconv/dicoms.py +++ b/heudiconv/dicoms.py @@ -104,7 +104,9 @@ def validate_dicom(fl, dcmfilter): for sig in ('iop', 'ICE_Dims', 'SequenceName'): try: del mw.series_signature[sig] - except KeyError: + except (KeyError, IndexError): + # index error can come deep within nibabel/dicom + # https://github.com/nipy/heudiconv/issues/633 pass # Workaround for protocol name in private siemens csa header if not getattr(mw.dcm_data, 'ProtocolName', '').strip():