Skip to content

Commit 34c1b41

Browse files
committed
Add 'Force' as matching_parameter option for fmap matching
1 parent b72ecd8 commit 34c1b41

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

docs/heuristics.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ The parameters that can be specified and the allowed options are defined in ``bi
117117
* ``'ImagingVolume'``: both ``fmaps`` and images will need to have the same the imaging
118118
volume (the header affine transformation: position, orientation and voxel size, as well
119119
as number of voxels along each dimensions).
120+
* ``'Force'``: forces ``heudiconv`` to consider any ``fmaps`` in the session to be
121+
suitable for any image, no matter what the imaging parameters are.
120122

121123

122124
- ``'criterion'``: Criterion to decide which of the candidate ``fmaps`` will be assigned to

heudiconv/bids.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ class BIDSError(Exception):
5555
AllowedFmapParameterMatching = [
5656
'Shims',
5757
'ImagingVolume',
58+
'Force',
5859
]
60+
# Key info returned by get_key_info_for_fmap_assignment when
61+
# matching_parameter = "Force"
62+
KeyInfoForForce = "Forced"
5963
# List defining allowed criteria to assign a given fmap to a non-fmap run
6064
# among the different fmaps with matching parameters:
6165
AllowedCriteriaForFmapAssignment = [
@@ -616,6 +620,10 @@ def get_key_info_for_fmap_assignment(json_file, matching_parameter='ImagingVolum
616620
nifti_file = glob(remove_suffix(json_file, '.json') + '.nii*')
617621
nifti_header = nb_load(nifti_file).header
618622
key_info = [nifti_header.affine, nifti_header.dim[1:3]]
623+
elif matching_parameter == 'Force':
624+
# We want to force the matching, so just return some string
625+
# regardless of the image
626+
key_info = [KeyInfoForForce]
619627

620628
return key_info
621629

heudiconv/tests/test_bids.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
select_fmap_from_compatible_groups,
3333
SHIM_KEY,
3434
AllowedCriteriaForFmapAssignment,
35+
KeyInfoForForce,
3536
)
3637

3738
import pytest
@@ -128,7 +129,13 @@ def mock_nibabel_load(file):
128129
)
129130
assert key_info == [MY_AFFINE, MY_DIM[1:3]]
130131

131-
# 4) invalid matching_parameters:
132+
# 4) matching_parameters = 'Force'
133+
key_info = get_key_info_for_fmap_assignment(
134+
json_name, matching_parameter='Force'
135+
)
136+
assert key_info == [KeyInfoForForce]
137+
138+
# Finally: invalid matching_parameters:
132139
with pytest.raises(ValueError):
133140
assert get_key_info_for_fmap_assignment(
134141
json_name, matching_parameter='Invalid'

0 commit comments

Comments
 (0)