Questions about adding a custom standard template


I am using fmriprep1.4.0 and trying to use a pediatric template for my toddler data preprocessing. The --output-spaces option allows for providing paths to custom templates that follow TemplateFlow’s naming conventions (e.g., /path/to/custom/templates/tpl-MyCustom:res-2). As I understand, the template should be in BIDS format with a corresponding .json file. However, the toddler template I am using is in NIFTI format already ( Is there a way to convert it to BIDS format and generate .json file simultaneously? If I provide the path to the template in --output-spaces option, would this template be used throughout the preprocessing? What would be the voxel size of preprocessed images? Would it be the same as the voxel size of the template?

Thank you very much.


Hi @Yaqiong,

We are trying to add that particular template to TemplateFlow (and hence, fMRIPrep). At this point, fMRIPrep can’t read custom templates (everything is in place to allow it, but we still need a little bit of coding).

Since reading the template to provide it as custom and adding it to TemplateFlow would be equivalent, would you like to add it directly to TemplateFlow?


Hi @oesteban, thanks for your response. Glad to know this function is almost there. I am not quite sure how to add it directly to TemplateFlow, if I have the template folder (in a similar format as one here: Could you walk me through it? Thank you.


I think the bottleneck is just organizing the files and writing the metadata. Once that is done, it is fairly easy for me to upload the template.


Great. I am also working on a cohort of child fMRI data and hoping to use an age-matched pediatric template (; 7.5-13.5 years) or Haskins pediatric template (7-12 years) in AFNI. Could you please also upload these two templates to the TemplateFlow? It would be great if you can keep me updated when these templates are ready to use.

Thank you.


Hi @oesteban, just wanted to follow up on the topic of adding the pediatric templates to TemplateFlow. Are there any updates?
Thank you.


Hi @Yaqiong,

Could you try the new pediatric templates of TemplateFlow? We are testing this new feature on fMRIPrep version 1.4.1rc2

In principle, it should be as easy as adding the following arguments:

--skull-strip-template MNIInfant:cohort-3 --output-spaces MNIInfant:cohort-3:res-2 <other-spaces>

Please replace MNIInfant with MNIPediatricAsym if those fit better your age range (MNIInfant is 0-4.5yr and MNIPediatricAsym goes from 4.5yo through 18yo).

Please replace cohort-3 with the age range that better approximates your application (MNIInfant, MNIPediatricAsym)


Hi @oesteban,

Thank you very much for the updates. I have tried the new pediatric template of Template Flow using the command that you provided but ran into some errors (see below). I have several questions regarding the errors. First, I have specified output --output-spaces MNIInfant:cohort-9:res-2, but why did it download tpl-MNIInfant_cohort-9_res-1_T1w.nii.gz instead? Second, for Freesurfer, how can I specify the output space (default fsaverage5")? Third, how to add the output space for --use-aroma? It is not using the one I specified but using “MNI152NLin6Asym:res-2” instead. Thanks.

The whole command I am using is as following:
singularity run
–home /scratch/YX_data_analysis:/asd/apps/software
/asd/apps/software/Converted_BIDs /asd/apps/software/RESTvsTASK participant
–participant-label ${subj}
–skull-strip-template MNIInfant:cohort-9 --output-spaces MNIInfant:cohort-9:res-2
–use-aroma --output-spaces MNIInfant:cohort-9:res-2
–nthreads 6 --n_cpus 12 --omp-nthreads 12
–mem-mb 16000
–fs-license-file /asd/apps/software/license.txt I have several questions for that

Error report:
Although --fs-no-reconall was not set (i.e., FreeSurfer is to be run), no FreeSurfer output space (valid values are: fsaverage, fsaverage6, fsnative, fsaverage5) was selected. Adding default “fsaverage5” to the list of output spaces.
Option “–use-aroma” requires functional images to be resampled to MNI152NLin6Asym space. The argument “MNI152NLin6Asym:res-2” has been automatically added to the list of output spaces (option --output-spaces).
190609-07:50:42,606 nipype.workflow IMPORTANT:

Running fMRIPREP version 1.4.1rc2:
  * BIDS dataset path: /asd/apps/software/Converted_BIDs.
  * Participant list: ['AACE54614A'].
  * Run identifier: 20190609-075042_f3cd8a79-11cf-4049-8d45-919c48a89aeb.

Process Process-2:
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.7/multiprocessing/”, line 297, in _bootstrap
File “/usr/local/miniconda/lib/python3.7/multiprocessing/”, line 99, in run
self._target(*self._args, **self._kwargs)
File “/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/”, line 608, in build_workflow
File “/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/”, line 259, in init_fmriprep_wf
File “/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/”, line 551, in init_single_subject_wf
File “/usr/local/miniconda/lib/python3.7/site-packages/smriprep/workflows/”, line 230, in init_anat_preproc_wf
normalization_quality=‘precise’ if not debug else ‘testing’)
File “/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/anat/”, line 188, in init_brain_extraction_wf
tpl_target_path = get_template(in_template, **template_spec)
File “/usr/local/miniconda/lib/python3.7/site-packages/templateflow/”, line 39, in get
File “/usr/local/miniconda/lib/python3.7/site-packages/templateflow/”, line 139, in _s3_get
with‘wb’) as f:
File “/usr/local/miniconda/lib/python3.7/”, line 1176, in open
File “/usr/local/miniconda/lib/python3.7/”, line 1030, in _opener
return, flags, mode)
OSError: [Errno 30] Read-only file system: ‘/opt/templateflow/tpl-MNIInfant/cohort-9/tpl-MNIInfant_cohort-9_res-1_T1w.nii.gz’


We are currently looking into this and some other related issues ATM. Thanks for your patience.

--output-spaces should understand both volumetric and surface outputs - placing fsnative and/or fsaverageX should work out. Please note the ‘s’ at the end of --output-spaces because the command line still accepts the deprecated --output-space argument.

ICA-AROMA was trained on MNI152NLin6Asym:res-2 and thus, it can only operate correctly on that space. You could maybe discuss with @mmennes et al. whether it makes sense to also train the noisy components on some infant/pediatric template space. If that happened, we would allow swapping the ICA-AROMA template.

We are currently working on this, simultaneously to Q1.

Thanks very much