Skip to content

Commit

Permalink
Merge pull request #381 from mgxd/fix/cifti-resample
Browse files Browse the repository at this point in the history
FIX: Ensure 2mm template is added when running CIFTI
  • Loading branch information
mgxd authored Aug 26, 2024
2 parents bdf9679 + c63ebb3 commit a01b1c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion nibabies/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,14 @@ def test_config_spaces():
assert [str(s) for s in spaces.get_standard(full_spec=True)] == [
'MNIInfant:cohort-1:res-native', # Default output space
'MNI152NLin6Asym:res-2',
'MNIInfant:cohort-1:res-2', # CIFTI: MNIInfant (2x2x2) -> MNI152NLin6Asym (2x2x2)
]

assert [
format_reference((s.fullname, s.spec))
for s in spaces.references
if s.standard and s.dim == 3
] == ['MNIInfant_cohort-1_res-native', 'MNI152NLin6Asym_res-2', 'MNIInfant_cohort-1']
] == ['MNIInfant_cohort-1_res-native', 'MNI152NLin6Asym_res-2', 'MNIInfant_cohort-1_res-2']
_reset_config()


Expand Down
6 changes: 3 additions & 3 deletions nibabies/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ def init_workflow_spaces(execution_spaces: SpatialReferences, age_months: int):
spaces.add(Reference('MNI152NLin6Asym', {'res': vol_res}))
# Ensure a non-native version of MNIInfant is added as a target
cohort = cohort_by_months('MNIInfant', age_months)
spaces.add(Reference('MNIInfant', {'cohort': cohort}))
spaces.add(Reference('MNIInfant', {'cohort': cohort, 'res': 2}))

return spaces

Expand Down Expand Up @@ -955,10 +955,10 @@ def get_MNIInfant_key(spaces: SpatialReferences) -> str:
key = None
for space in spaces.references:
# str formats as <reference.name>:<reference.spec>
if 'MNIInfant' in str(space) and 'res-native' not in str(space):
if 'MNIInfant' in str(space) and 'res-2' in str(space):
key = str(space)
break

if key is None:
raise KeyError(f'MNIInfant not found in SpatialReferences: {spaces}')
raise KeyError(f'MNIInfant (resolution 2x2x2) not found in SpatialReferences: {spaces}')
return key

0 comments on commit a01b1c8

Please sign in to comment.