Skip to content

Commit 7c2101b

Browse files
authored
Merge pull request #768 from MPIB/enh/populate_plainacqlabel
[ENH] add PlainAcquisitionLabel IntendedFor method
2 parents 4c2c2c0 + 08c144f commit 7c2101b

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

docs/heuristics.rst

+3
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ The parameters that can be specified and the allowed options are defined in ``bi
173173
- the corresponding modality image ``_acq-`` label for modalities other than ``func``
174174
(e.g. ``_acq-XYZ42`` for ``dwi`` images)
175175
- the corresponding image ``_task-`` label for the ``func`` modality (e.g. ``_task-XYZ42``)
176+
* ``'PlainAcquisitionLabel'``: similar to ``'CustomAcquisitionLabel'``, but does not change
177+
behavior for ``func`` modality and always bases decision on the ``_acq-`` label. Helps in
178+
cases when there are multiple tasks and a shared ``fmap`` for some of them.
176179
* ``'Force'``: forces ``heudiconv`` to consider any ``fmaps`` in the session to be
177180
suitable for any image, no matter what the imaging parameters are.
178181

heudiconv/bids.py

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class BIDSError(Exception):
7777
"ImagingVolume",
7878
"ModalityAcquisitionLabel",
7979
"CustomAcquisitionLabel",
80+
"PlainAcquisitionLabel",
8081
"Force",
8182
]
8283
# Key info returned by get_key_info_for_fmap_assignment when
@@ -755,6 +756,10 @@ def get_key_info_for_fmap_assignment(
755756
custom_label = BIDSFile.parse(op.basename(json_file))["acq"]
756757
# Get the custom acquisition label, acq_label is None if no custom field found
757758
key_info = [custom_label]
759+
elif matching_parameter == "PlainAcquisitionLabel":
760+
# always base the decision on <acq> label
761+
plain_label = BIDSFile.parse(op.basename(json_file))["acq"]
762+
key_info = [plain_label]
758763
elif matching_parameter == "Force":
759764
# We want to force the matching, so just return some string
760765
# regardless of the image

heudiconv/tests/test_bids.py

+18
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,24 @@ def test_get_key_info_for_fmap_assignment(
179179
json_name, matching_parameter="CustomAcquisitionLabel"
180180
)
181181

182+
# 7) matching_parameter = 'PlainAcquisitionLabel'
183+
A_LABEL = gen_rand_label(label_size, label_seed)
184+
for d in ["fmap", "func", "dwi", "anat"]:
185+
(tmp_path / d).mkdir(parents=True, exist_ok=True)
186+
187+
for dirname, fname, expected_key_info in [
188+
("fmap", f"sub-foo_acq-{A_LABEL}_epi.json", A_LABEL),
189+
("func", f"sub-foo_task-foo_acq-{A_LABEL}_bold.json", A_LABEL),
190+
("func", f"sub-foo_task-bar_acq-{A_LABEL}_bold.json", A_LABEL),
191+
("dwi", f"sub-foo_acq-{A_LABEL}_dwi.json", A_LABEL),
192+
("anat", f"sub-foo_acq-{A_LABEL}_T1w.json", A_LABEL),
193+
]:
194+
json_name = op.join(tmp_path, dirname, fname)
195+
save_json(json_name, {SHIM_KEY: A_SHIM})
196+
assert [expected_key_info] == get_key_info_for_fmap_assignment(
197+
json_name, matching_parameter="PlainAcquisitionLabel"
198+
)
199+
182200
# Finally: invalid matching_parameters:
183201
assert (
184202
get_key_info_for_fmap_assignment(json_name, matching_parameter="Invalid") == []

0 commit comments

Comments
 (0)