Skip to content

Commit c6cf932

Browse files
authored
Merge pull request #1955 from oesteban/patch/fix-outputs
ENH: Refactor of how spatial normalization targets and ``--output-spaces`` are maintained
2 parents 9dc0480 + 249bbe3 commit c6cf932

File tree

15 files changed

+722
-684
lines changed

15 files changed

+722
-684
lines changed

.circleci/config.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
THISVERSION=${CIRCLE_TAG:-$THISVERSION}
8585
DOCKERVERSION=$(docker run --rm -it poldracklab/fmriprep:latest --version)
8686
DOCKERVERSION=${DOCKERVERSION%$'\r'}
87-
DOCKERVERSION=${DOCKERVERSION#*"fmriprep v"}
87+
DOCKERVERSION=${DOCKERVERSION#*"fMRIPrep v"}
8888
echo "VERSION: \"$THISVERSION\""
8989
echo "DOCKERVERSION: \"${DOCKERVERSION}\""
9090
test "$DOCKERVERSION" = "$THISVERSION"
@@ -395,7 +395,7 @@ jobs:
395395
--sloppy --write-graph --use-syn-sdc --mem_mb 4096 \
396396
--use-aroma \
397397
--skull-strip-template OASIS30ANTs:res-1 \
398-
--output-spaces fsLR MNI152NLin2009cAsym fsaverage5 fsnative MNI152NLin6Asym anat \
398+
--output-spaces MNI152NLin2009cAsym fsaverage5 fsnative MNI152NLin6Asym anat \
399399
--use-plugin /home/circleci/src/fmriprep/.circleci/legacy.yml \
400400
--nthreads 2 --cifti-output -vv
401401
- run:
@@ -422,7 +422,7 @@ jobs:
422422
/tmp/data/ds005 /tmp/ds005/derivatives_partial participant \
423423
--fs-subjects-dir /tmp/ds005/freesurfer \
424424
--sloppy --write-graph --use-syn-sdc --mem_mb 4096 \
425-
--output-spaces fsLR MNI152NLin2009cAsym fsaverage5 fsnative MNI152NLin6Asym anat \
425+
--output-spaces MNI152NLin2009cAsym fsaverage5 fsnative MNI152NLin6Asym anat \
426426
--aroma-melodic-dimensionality 2 --use-aroma \
427427
--nthreads 2 --cifti-output -vv
428428
- run:
@@ -520,6 +520,7 @@ jobs:
520520
--config $PWD/nipype.cfg -w /tmp/ds054/work \
521521
/tmp/data/ds054 /tmp/ds054/derivatives participant \
522522
--fs-no-reconall --sloppy --write-graph \
523+
--output-spaces MNI152NLin2009cAsym \
523524
--mem_mb 4096 --nthreads 2 --anat-only -vv
524525
- run:
525526
name: Clean-up after anatomical run
@@ -657,6 +658,7 @@ jobs:
657658
--config $PWD/nipype.cfg -w /tmp/ds210/work \
658659
/tmp/data/ds210 /tmp/ds210/derivatives participant \
659660
--fs-no-reconall --sloppy --write-graph \
661+
--output-spaces MNI152NLin2009cAsym \
660662
--mem_mb 4096 --nthreads 2 --anat-only -vv
661663
- run:
662664
name: Clean-up after anatomical run
@@ -679,6 +681,7 @@ jobs:
679681
/tmp/data/ds210 /tmp/ds210/derivatives participant \
680682
--fs-no-reconall --t2s-coreg --use-syn-sdc \
681683
--dummy-scans 1 --sloppy --write-graph \
684+
--output-spaces MNI152NLin2009cAsym \
682685
--mem_mb 4096 --nthreads 2 -vv
683686
- run:
684687
name: Checking outputs of fMRIPrep
@@ -812,7 +815,7 @@ jobs:
812815
which fmriprep | grep sdist\\/bin
813816
INSTALLED_VERSION=$(fmriprep --version)
814817
INSTALLED_VERSION=${INSTALLED_VERSION%$'\r'}
815-
INSTALLED_VERSION=${INSTALLED_VERSION#*"fmriprep v"}
818+
INSTALLED_VERSION=${INSTALLED_VERSION#*"fMRIPrep v"}
816819
echo "VERSION: \"$THISVERSION\""
817820
echo "INSTALLED: \"$INSTALLED_VERSION\""
818821
test "$INSTALLED_VERSION" = "$THISVERSION"
@@ -829,7 +832,7 @@ jobs:
829832
which fmriprep | grep wheel\\/bin
830833
INSTALLED_VERSION=$(fmriprep --version)
831834
INSTALLED_VERSION=${INSTALLED_VERSION%$'\r'}
832-
INSTALLED_VERSION=${INSTALLED_VERSION#*"fmriprep v"}
835+
INSTALLED_VERSION=${INSTALLED_VERSION#*"fMRIPrep v"}
833836
echo "VERSION: \"$THISVERSION\""
834837
echo "INSTALLED: \"$INSTALLED_VERSION\""
835838
test "$INSTALLED_VERSION" = "$THISVERSION"

.circleci/ds005_outputs.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-confounds_regresso
5656
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-MELODIC_mixing.tsv
5757
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_space-fsaverage5_hemi-L.func.gii
5858
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_space-fsaverage5_hemi-R.func.gii
59-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_space-fsaverage_hemi-L.func.gii
60-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_space-fsaverage_hemi-R.func.gii
61-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_space-fsLR_den-32k_hemi-L.func.gii
62-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_space-fsLR_den-32k_hemi-R.func.gii
6359
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_space-fsLR_den-91k_bold.dtseries.json
6460
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_space-fsLR_den-91k_bold.dtseries.nii
6561
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_space-fsnative_hemi-L.func.gii
@@ -92,10 +88,6 @@ fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-confounds_regresso
9288
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-MELODIC_mixing.tsv
9389
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsaverage5_hemi-L.func.gii
9490
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsaverage5_hemi-R.func.gii
95-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsaverage_hemi-L.func.gii
96-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsaverage_hemi-R.func.gii
97-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsLR_den-32k_hemi-L.func.gii
98-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsLR_den-32k_hemi-R.func.gii
9991
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsLR_den-91k_bold.dtseries.json
10092
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsLR_den-91k_bold.dtseries.nii
10193
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsnative_hemi-L.func.gii

.circleci/ds005_partial_outputs.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-confounds_regresso
5656
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-MELODIC_mixing.tsv
5757
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsaverage5_hemi-L.func.gii
5858
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsaverage5_hemi-R.func.gii
59-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsaverage_hemi-L.func.gii
60-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsaverage_hemi-R.func.gii
61-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsLR_den-32k_hemi-L.func.gii
62-
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsLR_den-32k_hemi-R.func.gii
6359
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsLR_den-91k_bold.dtseries.json
6460
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsLR_den-91k_bold.dtseries.nii
6561
fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-02_space-fsnative_hemi-L.func.gii

.circleci/ds054_outputs.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_desc-confounds_regre
3333
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_desc-confounds_regressors.tsv
3434
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_desc-preproc_bold.json
3535
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_desc-preproc_bold.nii.gz
36-
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-MNI152NLin2009cAsym_boldref.nii.gz
37-
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-MNI152NLin2009cAsym_desc-brain_mask.json
38-
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz
39-
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-MNI152NLin2009cAsym_desc-preproc_bold.json
40-
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz
36+
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-MNI152NLin2009cAsym_res-2_boldref.nii.gz
37+
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.json
38+
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.nii.gz
39+
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.json
40+
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.nii.gz
4141
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-T1w_boldref.nii.gz
4242
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-T1w_desc-brain_mask.json
4343
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_space-T1w_desc-brain_mask.nii.gz
@@ -50,11 +50,11 @@ fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_desc-confounds_regre
5050
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_desc-confounds_regressors.tsv
5151
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_desc-preproc_bold.json
5252
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_desc-preproc_bold.nii.gz
53-
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-MNI152NLin2009cAsym_boldref.nii.gz
54-
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-MNI152NLin2009cAsym_desc-brain_mask.json
55-
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz
56-
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-MNI152NLin2009cAsym_desc-preproc_bold.json
57-
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz
53+
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-MNI152NLin2009cAsym_res-2_boldref.nii.gz
54+
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.json
55+
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.nii.gz
56+
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.json
57+
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.nii.gz
5858
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-T1w_boldref.nii.gz
5959
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-T1w_desc-brain_mask.json
6060
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-02_space-T1w_desc-brain_mask.nii.gz

docs/spaces.rst

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,31 @@
44

55
Defining standard and nonstandard spaces where data will be resampled
66
=====================================================================
7-
8-
The command line interface of fMRIPrep allows resampling the preprocessed data
7+
The command line interface of *fMRIPrep* allows resampling the preprocessed data
98
onto other output spaces.
109
That is achieved using the ``--output-spaces`` argument, where standard and
1110
nonstandard spaces can be inserted.
1211

12+
.. important::
13+
*fMRIPrep* will reduce the amount of output spaces to just spaces listed in ``--output-spaces``,
14+
even if other options require resampling the preprocessed data into intermediary spaces.
15+
1316
Standard spaces
1417
"""""""""""""""
15-
16-
When using fMRIPrep in a workflow that will investigate effects that span across
18+
When using *fMRIPrep* in a workflow that will investigate effects that span across
1719
analytical groupings, neuroimagers typically resample their data on to a standard,
1820
stereotactic coordinate system.
1921
The most extended standard space for fMRI analyses is generally referred to MNI.
20-
For instance, to instruct fMRIPrep to use the MNI template brain distributed with
22+
For instance, to instruct *fMRIPrep* to use the MNI template brain distributed with
2123
FSL as coordinate reference the option will read as follows: ``--output-spaces MNI152NLin6Asym``.
22-
By default, fMRIPrep uses ``MNI152NLin2009cAsym`` as spatial-standardization reference.
24+
By default, *fMRIPrep* uses ``MNI152NLin2009cAsym`` as spatial-standardization reference.
2325
Valid template identifiers (``MNI152NLin6Asym``, ``MNI152NLin2009cAsym``, etc.) come from
2426
the `TemplateFlow project <https://github.com/templateflow/templateflow>`__.
2527

26-
Therefore, fMRIPrep will run nonlinear registration processes against the template
28+
Therefore, *fMRIPrep* will run nonlinear registration processes against the template
2729
T1w image corresponding to all the standard spaces supplied with the argument
2830
``--output-spaces``.
29-
By default, fMRIPrep will resample the preprocessed data on those spaces (labeling the
31+
By default, *fMRIPrep* will resample the preprocessed data on those spaces (labeling the
3032
corresponding outputs with the `space-<template-identifier>` BIDS entity) but keeping
3133
the original resolution of the BOLD data to produce smaller files, more consistent with
3234
the original data gridding.
@@ -39,14 +41,26 @@ preprocessed BOLD 4D files on two standard spaces (``MNI152NLin6Asym``,
3941
and ``MNI152NLin2009cAsym``) with the template's 2mm isotropic resolution for
4042
the data on ``MNI152NLin6Asym`` space and the original BOLD resolution
4143
(say, e.g., 2x2x2.5 [mm]) for the case of ``MNI152NLin2009cAsym``.
44+
This is equivalent to saying
45+
``--output-spaces MNI152NLin6Asym:res-2 MNI152NLin2009cAsym:res-native``.
4246

4347
Other possible modifiers are, for instance, the ``cohort`` selector.
44-
Although currently there is no template in TemplateFlow with several cohorts,
45-
very soon we will integrate pediatric templates, for which ``cohort`` will
46-
function to select the appropriate age range.
47-
Therefore, in upcoming versions of fMRIPrep, it will be possible to run it with
48-
``--output-spaces MNIPediatricAsym:res-2:cohort-2`` where ``cohort-2`` would select
49-
the template instance for the, say, 24-48 months old range.
48+
For instance, ``--output-spaces MNIPediatricAsym:res-1:cohort-2`` selects
49+
the resolution ``1`` of ``cohort-2`` which, for the ``MNIPediatricAsym``
50+
template, corresponds to the `prepuberty phase
51+
<https://github.com/templateflow/tpl-MNIPediatricAsym/blob/bcf77616f547f327ee53c01dadf689ab6518a097/template_description.json#L22-L26>`__
52+
(4.5--8.5 years old).
53+
54+
Space modifiers such as ``res`` are combinatorial:
55+
``--output-spaces MNIPediatricAsym:cohort-1:cohort-2:res-native:res-1`` will
56+
generate conversions for the following combinations:
57+
58+
* cohort ``1`` and "native" resolution (meaning, the original BOLD resolution),
59+
* cohort ``1`` and resolution ``1`` of the template,
60+
* cohort ``2`` and "native" resolution (meaning, the original BOLD resolution), and
61+
* cohort ``2`` and resolution ``1`` of the template.
62+
63+
Please mind that the selected resolutions specified must exist within TemplateFlow.
5064

5165
When specifying surface spaces (e.g., ``fsaverage``), the legacy identifiers from
5266
FreeSurfer will be supported (e.g., ``fsaverage5``) although the use of the density
@@ -55,13 +69,12 @@ selecting ``fsLR`` surface space without a density label, ``fsLR:den-32k`` will
5569

5670
Custom standard spaces
5771
""""""""""""""""""""""
58-
5972
Although the functionality is not available yet, the interface of the
6073
``--output-spaces`` permits providing paths to custom templates that
6174
follow TemplateFlow's naming conventions
6275
(e.g., ``/path/to/custom/templates/tpl-MyCustom:res-2``).
6376
Following the example, at least the following files
64-
must be found under under ``/path/to/custom/templates/tpl-MyCustom``: ::
77+
must be found under under ``/path/to/custom/templates/tpl-MyCustom``::
6578

6679
tpl-MyCustom/
6780
template_description.json
@@ -74,15 +87,14 @@ Although a more comprehensive coverage of standard files would be advised.
7487

7588
Nonstandard spaces
7689
""""""""""""""""""
77-
7890
Additionally, ``--output-spaces`` accepts identifiers of spatial references
7991
that do not generate *standardized* coordinate spaces:
8092

8193
* ``T1w`` or ``anat``: data are resampled into the individual's anatomical
8294
reference generated with the T1w and T2w images available within the
8395
BIDS structure.
8496
* ``fsnative``: similarly to the ``anat`` space for volumetric references,
85-
including the ``fsnative`` space will instruct fMRIPrep to sample the
97+
including the ``fsnative`` space will instruct *fMRIPrep* to sample the
8698
original BOLD data onto FreeSurfer's reconstructed surfaces for this
8799
individual.
88100
* ``func``, ``bold``, ``run``, ``boldref`` or ``sbref`` can be used to
@@ -96,15 +108,14 @@ Modifiers are not allowed when providing nonstandard spaces.
96108

97109
Preprocessing blocks depending on standard templates
98110
""""""""""""""""""""""""""""""""""""""""""""""""""""
99-
100111
Some modules of the pipeline (e.g., the ICA-AROMA denoising, the generation of
101112
HCP compatible *grayordinates* files, or the *fieldmap-less* distortion correction)
102113
operate in specific template spaces.
103114
When selecting those modules to be included (using any of the following flags:
104115
``--use-aroma``, ``--cifti-outputs``, ``--use-syn-sdc``) will modify the list of
105116
output spaces to include the space identifiers they require, should the
106117
identifier not be found within the ``--output-spaces`` list already.
107-
In other words, running fMRIPrep with ``--output-spaces MNI152NLin6Asym:res-2
118+
In other words, running *fMRIPrep* with ``--output-spaces MNI152NLin6Asym:res-2
108119
--use-syn-sdc`` will expand the list of output spaces to be
109120
``MNI152NLin6Asym:res-2 MNI152NLin2009cAsym``.
110121

@@ -143,22 +154,19 @@ To do so, follow the next steps.
143154
1. By default, a mirror of *TemplateFlow* to store the resources will be
144155
created in ``$HOME/.cache/templateflow``.
145156
You can modify such a configuration with the ``TEMPLATEFLOW_HOME``
146-
environment variable, e.g.:
147-
::
148-
157+
environment variable, e.g.::
158+
149159
$ export TEMPLATEFLOW_HOME=$HOME/.templateflow
150-
160+
151161
2. Install the client within your favorite Python 3 environment (this can
152-
be done in your login-node, or in a host with Internet access,
153-
without need for Docker/Singularity):
154-
::
155-
162+
be done in your login-node, or in a host with Internet access,
163+
without need for Docker/Singularity)::
164+
156165
$ python -m pip install -U templateflow
157-
166+
158167
3. Use the ``get()`` utility of the client to pull down all the templates you'll
159-
want to use. For example:
160-
::
161-
168+
want to use. For example::
169+
162170
$ python -c "from templateflow.api import get; get(['MNI152NLin2009cAsym', 'MNI152NLin6Asym', 'OASIS30ANTs', 'MNIPediatricAsym', 'MNIInfant'])"
163171

164172
After pulling down the resources you'll need, you will just need to make sure your

0 commit comments

Comments
 (0)