diff --git a/heudiconv/dicoms.py b/heudiconv/dicoms.py index 1d276e39..6210f83d 100644 --- a/heudiconv/dicoms.py +++ b/heudiconv/dicoms.py @@ -92,6 +92,7 @@ def create_seqinfo( image_type = get_typed_attr(dcminfo, "ImageType", tuple, ()) is_moco = "MOCO" in image_type series_desc = get_typed_attr(dcminfo, "SeriesDescription", str, "") + protocol_name = get_typed_attr(dcminfo, "ProtocolName", str, "") if dcminfo.get([0x18, 0x24]): # GE and Philips @@ -99,6 +100,9 @@ def create_seqinfo( 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 else: sequence_name = "" @@ -133,7 +137,7 @@ def create_seqinfo( dim4=size[3], TR=TR, TE=TE, - protocol_name=dcminfo.ProtocolName, + protocol_name=protocol_name, is_motion_corrected=is_moco, is_derived="derived" in [x.lower() for x in image_type], patient_id=dcminfo.get("PatientID"), diff --git a/heudiconv/tests/test_dicoms.py b/heudiconv/tests/test_dicoms.py index 4cb28290..092019b4 100644 --- a/heudiconv/tests/test_dicoms.py +++ b/heudiconv/tests/test_dicoms.py @@ -12,6 +12,8 @@ from heudiconv.cli.run import main as runner from heudiconv.convert import nipype_convert from heudiconv.dicoms import ( + create_seqinfo, + dw, embed_dicom_and_nifti_metadata, get_datetime_from_dcm, get_reproducible_int, @@ -178,6 +180,23 @@ def test_get_datetime_from_dcm_wo_dt() -> None: assert get_datetime_from_dcm(XA30_enhanced_dcm) is None +dicom_test_data = [ + (dw.wrapper_from_file(d_file), [d_file], op.basename(d_file)) + for d_file in glob(op.join(TESTS_DATA_PATH, "*.dcm")) +] + + +@pytest.mark.parametrize("mw,series_files,series_id", dicom_test_data) +def test_create_seqinfo( + mw: dw.Wrapper, + series_files: list[str], + series_id: str, +) -> None: + seqinfo = create_seqinfo(mw, series_files, series_id) + assert seqinfo.sequence_name != "" + pass + + def test_get_reproducible_int() -> None: dcmfile = op.join(TESTS_DATA_PATH, "phantom.dcm")