diff --git a/fmriprep/config.py b/fmriprep/config.py index 31107991..cc0363a0 100644 --- a/fmriprep/config.py +++ b/fmriprep/config.py @@ -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