Skip to content

Commit fffeed7

Browse files
authored
Merge pull request #1514 from poldracklab/oesteban-patch-2
FIX: Make sure ``--cifti-output`` requires at least one of ``fsaverage{5,6}``
2 parents 26b0424 + d417f8f commit fffeed7

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

fmriprep/cli/run.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,12 @@ def build_workflow(opts, retval):
573573
* Run identifier: {uuid}.
574574
""".format
575575

576-
output_spaces = opts.output_space or []
576+
# Reduce to unique space identifiers
577+
output_spaces = sorted(set(opts.output_space))
578+
579+
# If FS is not run, drop all fs* output spaces
580+
if not opts.run_reconall:
581+
output_spaces = [item for item in output_spaces if not item.startswith('fs')]
577582

578583
# Validity of some inputs
579584
# ERROR check if use_aroma was specified, but the correct template was not
@@ -586,14 +591,19 @@ def build_workflow(opts, retval):
586591
'spaces (option "--output-space").'
587592
)
588593

589-
if opts.cifti_output and (opts.template != 'MNI152NLin2009cAsym' or
590-
'template' not in output_spaces):
591-
output_spaces.append('template')
592-
logger.warning(
593-
'Option "--cifti-output" requires functional images to be resampled to MNI space. '
594-
'The argument "template" has been automatically added to the list of output '
595-
'spaces (option "--output-space").'
596-
)
594+
if opts.cifti_output:
595+
if 'template' not in output_spaces:
596+
output_spaces.append('template')
597+
logger.warning(
598+
'Option "--cifti-output" requires functional images to be resampled to MNI '
599+
'space. The argument "template" has been automatically added to the list of '
600+
'output spaces (option "--output-space").')
601+
if not [s for s in output_spaces if s in ('fsaverage5', 'fsaverage6')]:
602+
output_spaces = sorted(output_spaces + ['fsaverage5'])
603+
logger.warning(
604+
'Option "--cifti-output" requires functional images to be resampled to fsaverage '
605+
'space. The argument "fsaverage5" has been automatically added to the list of '
606+
'output spaces (option "--output-space").')
597607

598608
# Check output_space
599609
if 'template' not in output_spaces and (opts.use_syn_sdc or opts.force_syn):

fmriprep/workflows/bold/base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
365365
tr=metadata.get("RepetitionTime")),
366366
name='summary', mem_gb=DEFAULT_MEMORY_MIN_GB, run_without_submitting=True)
367367

368+
# CIfTI output: currently, we only support fsaverage{5,6}
369+
cifti_spaces = [s for s in output_spaces if s in ('fsaverage5', 'fsaverage6')]
370+
cifti_output = cifti_output and cifti_spaces
368371
func_derivatives_wf = init_func_derivatives_wf(output_dir=output_dir,
369372
output_spaces=output_spaces,
370373
template=template,
@@ -798,17 +801,15 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
798801
(bold_surf_wf, outputnode, [('outputnode.surfaces', 'surfaces')]),
799802
])
800803

801-
# CIFTI output
802-
if cifti_output and surface_spaces:
804+
if cifti_output:
803805
bold_surf_wf.__desc__ += """\
804806
*Grayordinates* files [@hcppipelines], which combine surface-sampled
805807
data and volume-sampled data, were also generated.
806808
"""
807809
gen_cifti = pe.MapNode(GenerateCifti(), iterfield=["surface_target", "gifti_files"],
808810
name="gen_cifti")
809811
gen_cifti.inputs.TR = metadata.get("RepetitionTime")
810-
gen_cifti.inputs.surface_target = [s for s in surface_spaces
811-
if s.startswith('fsaverage')]
812+
gen_cifti.inputs.surface_target = cifti_spaces
812813

813814
workflow.connect([
814815
(bold_surf_wf, gen_cifti, [

0 commit comments

Comments
 (0)