Skip to content

Commit

Permalink
Parse CIFTI space names.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Aug 6, 2024
1 parent 0d11df8 commit b8e292d
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions fmriprep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,25 +815,34 @@ def init_spaces(checkpoint=True):
# Ensure user-defined spatial references for outputs are correctly parsed.
# Certain options require normalization to a space not explicitly defined by users.
# These spaces will not be included in the final outputs.
if cifti_output == '91k':
spaces.add(
Reference('fsLR', {'den': '32k', 'volspace': 'MNI152NLin6Asym', 'volres': '2'})
)
elif cifti_output == '170k':
spaces.add(
Reference('fsLR', {'den': '32k', 'volspace': 'MNI152NLin6Asym', 'volres': '1'})
)
cifti_output = workflow.cifti_output
if cifti_output:
# CIFTI grayordinates to corresponding FSL-MNI resolutions.
res = '2' if cifti_output == '91k' else '1'
den = '32k' if cifti_output == '91k' else '59k'
spaces.add(Reference('fsLR', {'den': den, 'volspace': 'MNI152NLin6Asym', 'volres': res}))

if spaces.get_spaces(cifti=(True,)):
# Figure out the surface spaces and volume spaces we need
cifti_spaces = spaces.get_standard(cifti=(True,))
cifti_spaces = spaces.get_standard(cifti=(True,)) + spaces.get_nonstandard(cifti=(True,))
for cifti_space in cifti_spaces:
surface_space = cifti_space
volume_space = cifti_space

# CIFTI grayordinates to corresponding FSL-MNI resolutions.
vol_res = '2' if cifti_output == '91k' else '1'
spaces.add(Reference('MNI152NLin6Asym', {'res': vol_res}))
# The surface space
spaces.add(
Reference(
cifti_space.space,
{k: v for k, v in cifti_space.spec.items() if not k.startswith('vol')},
),
)
# The volume space
spaces.add(
Reference(
cifti_space.spec['volspace'],
{
k: v for k, v in cifti_space.spec.items()
if (k.startswith('vol') and k != 'volspace')
},
),
)

# Make the SpatialReferences object available
workflow.spaces = spaces

0 comments on commit b8e292d

Please sign in to comment.