From f113da1f10f9c991f8143faaa8dfdea9b95fc76d Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 16 Sep 2024 13:17:34 -0400 Subject: [PATCH] RF: reduce duplication and log at DEBUG what was our assumption when we extracted sequence_name --- heudiconv/dicoms.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/heudiconv/dicoms.py b/heudiconv/dicoms.py index 6210f83d..cf4a84fd 100644 --- a/heudiconv/dicoms.py +++ b/heudiconv/dicoms.py @@ -94,15 +94,19 @@ def create_seqinfo( series_desc = get_typed_attr(dcminfo, "SeriesDescription", str, "") protocol_name = get_typed_attr(dcminfo, "ProtocolName", str, "") - if dcminfo.get([0x18, 0x24]): - # GE and Philips - sequence_name = dcminfo[0x18, 0x24].value - elif dcminfo.get([0x19, 0x109C]): - # Siemens - sequence_name = dcminfo[0x19, 0x109C].value - elif dcminfo.get([0x18, 0x9005]): - # Siemens XA - sequence_name = dcminfo[0x18, 0x9005].value + for k, m in ( + ([0x18, 0x24], "GE and Philips"), + ([0x19, 0x109C], "Siemens"), + ([0x18, 0x9005], "Siemens XA"), + ): + if v := dcminfo.get(k): + sequence_name = v.value + lgr.debug( + "Identified sequence name as %s coming from the %r family of MR scanners", + sequence_name, + m, + ) + break else: sequence_name = ""