Skip to content

Commit a5ca545

Browse files
committed
fix(--cifti-output): stick with current implementation, select bold_std
Leave for a future PR the implementation of HCP-compatible cifti. Also, run a ``KeySelect`` to extract the appropriate BOLD in standard space resampling.
1 parent 7e1996c commit a5ca545

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

fmriprep/cli/run.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,9 @@ def parse_spaces(opts):
684684
The argument "MNI152NLin6Asym:res-2" has been automatically added to the list of output spaces \
685685
(option ``--output-spaces``).""", file=stderr)
686686

687-
if opts.cifti_output and 'fsLR' not in output_spaces:
688-
if 'MNI152NLin6Asym' not in output_spaces:
689-
output_spaces['MNI152NLin6Asym'] = {'res': 2}
687+
if opts.cifti_output and 'MNI152NLin2009cAsym' not in output_spaces:
688+
if 'MNI152NLin2009cAsym' not in output_spaces:
689+
output_spaces['MNI152NLin2009cAsym'] = {'res': 2}
690690
print("""Option ``--cifti-output`` requires functional images to be resampled to \
691691
``MNI152NLin6Asym`` space. Such template identifier has been automatically added to the list \
692692
of output spaces (option "--output-space").""", file=stderr)

fmriprep/workflows/bold/base.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
32
# vi: set ft=python sts=4 ts=4 sw=4 et:
43
"""
@@ -44,7 +43,13 @@
4443

4544
DEFAULT_MEMORY_MIN_GB = 0.01
4645
LOGGER = logging.getLogger('nipype.workflow')
47-
46+
FSAVERAGE_DENSITY = {
47+
'642': 'fsaverage3',
48+
'2562': 'fsaverage4',
49+
'10k': 'fsaverage5',
50+
'41k': 'fsaverage6',
51+
'164k': 'fsaverage7',
52+
}
4853

4954
def init_func_preproc_wf(
5055
aroma_melodic_dim,
@@ -395,7 +400,10 @@ def init_func_preproc_wf(
395400
name='summary', mem_gb=DEFAULT_MEMORY_MIN_GB, run_without_submitting=True)
396401

397402
# CIfTI output: currently, we only support fsaverage{5,6}
398-
cifti_spaces = [s for s in output_spaces.keys() if s in ('fsaverage5', 'fsaverage6')]
403+
cifti_spaces = set([s for s in output_spaces.keys() if s in ('fsaverage5', 'fsaverage6')])
404+
fsaverage_den = output_spaces.get('fsaverage', {}).get('den')
405+
if fsaverage_den:
406+
cifti_spaces.add(FSAVERAGE_DENSITY[fsaverage_den])
399407
cifti_output = cifti_output and cifti_spaces
400408
func_derivatives_wf = init_func_derivatives_wf(
401409
bids_root=layout.root,
@@ -848,20 +856,28 @@ def init_func_preproc_wf(
848856
])
849857

850858
if cifti_output:
859+
from niworkflows.interfaces.utility import KeySelect
851860
bold_surf_wf.__desc__ += """\
852861
*Grayordinates* files [@hcppipelines], which combine surface-sampled
853862
data and volume-sampled data, were also generated.
854863
"""
864+
select_std = pe.Node(KeySelect(fields=['bold_std']),
865+
name='select_std', run_without_submitting=True)
866+
select_std.inputs.key = 'MNI152NLin2009cAsym'
867+
855868
gen_cifti = pe.MapNode(GenerateCifti(), iterfield=["surface_target", "gifti_files"],
856869
name="gen_cifti")
857870
gen_cifti.inputs.TR = metadata.get("RepetitionTime")
858-
gen_cifti.inputs.surface_target = cifti_spaces
871+
gen_cifti.inputs.surface_target = list(cifti_spaces)
859872

860873
workflow.connect([
874+
(bold_std_trans_wf, select_std, [
875+
('outputnode.templates', 'keys'),
876+
('outputnode.bold_std', 'bold_std')]),
861877
(bold_surf_wf, gen_cifti, [
862878
('outputnode.surfaces', 'gifti_files')]),
863879
(inputnode, gen_cifti, [('subjects_dir', 'subjects_dir')]),
864-
(bold_std_trans_wf, gen_cifti, [('outputnode.bold_std', 'bold_file')]),
880+
(select_std, gen_cifti, [('bold_std', 'bold_file')]),
865881
(gen_cifti, outputnode, [('out_file', 'bold_cifti'),
866882
('variant', 'cifti_variant'),
867883
('variant_key', 'cifti_variant_key')]),

0 commit comments

Comments
 (0)