Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract sequence_name from PulseSequenceName on Siemens XA** data #753

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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