Skip to content

Commit

Permalink
Merge pull request nipy#753 from UNFmontreal/fix/xa_pulse_seq_name
Browse files Browse the repository at this point in the history
extract sequence_name from PulseSequenceName on Siemens XA** data
  • Loading branch information
yarikoptic authored Sep 16, 2024
2 parents 8e2c81b + 9afeae9 commit 383525d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion heudiconv/dicoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ 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
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
else:
sequence_name = ""

Expand Down Expand Up @@ -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"),
Expand Down
19 changes: 19 additions & 0 deletions heudiconv/tests/test_dicoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit 383525d

Please sign in to comment.