Skip to content

Commit 8a22f12

Browse files
committed
add data and bids tests
1 parent 09c9115 commit 8a22f12

6 files changed

+30
-16
lines changed

heudiconv/convert.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def update_multiorient_name(
533533
)
534534
return filename
535535
iop = metadata.get("ImageOrientationPatientDICOM")
536-
iop = [round(x) for x in iop]
536+
# iop = [round(x) for x in iop]
537537
cross_prod = [
538538
iop[1] * iop[5] - iop[2] * iop[4],
539539
iop[2] * iop[3] - iop[0] * iop[5],
@@ -1002,8 +1002,6 @@ def save_converted_files(
10021002
except KeyError:
10031003
pass
10041004

1005-
print(iops)
1006-
10071005
is_multiecho = (
10081006
len(set(filter(bool, echo_times))) > 1
10091007
) # Check for varying echo times

heudiconv/heuristics/bids_ME.py renamed to heudiconv/heuristics/bids_localizer.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,12 @@ def infotodict(
3333
seqitem: run number during scanning
3434
subindex: sub index within group
3535
"""
36-
bold = create_key("sub-{subject}/func/sub-{subject}_task-test_run-{item}_bold")
37-
megre_mag = create_key("sub-{subject}/anat/sub-{subject}_part-mag_MEGRE")
38-
megre_phase = create_key("sub-{subject}/anat/sub-{subject}_part-phase_MEGRE")
36+
localizer = create_key("sub-{subject}/anat/sub-{subject}_localizer")
3937

4038
info: dict[tuple[str, tuple[str, ...], None], list[str]] = {
41-
bold: [],
42-
megre_mag: [],
43-
megre_phase: [],
39+
localizer: [],
4440
}
4541
for s in seqinfo:
46-
if "_ME_" in s.series_description:
47-
info[bold].append(s.series_id)
48-
if "GRE_QSM" in s.series_description:
49-
if s.image_type[2] == "M":
50-
info[megre_mag].append(s.series_id)
51-
elif s.image_type[2] == "P":
52-
info[megre_phase].append(s.series_id)
42+
if "localizer" in s.series_description:
43+
info[localizer].append(s.series_id)
5344
return info

heudiconv/tests/test_bids.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,31 @@ def test_BIDSFile() -> None:
13691369
assert my_bids_file["echo"] == "2"
13701370

13711371

1372+
@pytest.mark.skipif(not have_datalad, reason="no datalad")
1373+
def test_convert_multiorient(
1374+
tmp_path: Path,
1375+
heuristic: str = "bids_localizer.py",
1376+
subID: str = "loc",
1377+
) -> None:
1378+
"""Unit test for the case of multi-orient localizer data.
1379+
The different orientations should be labeled in `acq` entity.
1380+
"""
1381+
datadir = op.join(TESTS_DATA_PATH, "01-localizer_64ch")
1382+
outdir = tmp_path / "out"
1383+
outdir.mkdir()
1384+
args = gen_heudiconv_args(datadir, str(outdir), subID, heuristic)
1385+
runner(args)
1386+
1387+
# Check that the expected files have been extracted.
1388+
# This also checks that the "echo" entity comes before "part":
1389+
for orient in ["sagittal", "coronal", "axial"]:
1390+
for ext in ["nii.gz", "json"]:
1391+
assert op.exists(
1392+
op.join(outdir, "sub-%s", "anat", "sub-%s_acq-%s_localizer.%s")
1393+
% (subID, subID, orient, ext)
1394+
)
1395+
1396+
13721397
@pytest.mark.skipif(not have_datalad, reason="no datalad")
13731398
def test_ME_mag_phase_conversion(
13741399
monkeypatch: pytest.MonkeyPatch,

0 commit comments

Comments
 (0)