Custom template fMRIPrep 20.0.1

Hi,

I am using fMRIPrep (v20.0.1) and would have liked to use a custom template for normalization (not uploaded to the templateflow repository). I have followed the steps described in https://fmriprep.readthedocs.io/en/stable/spaces.html#custom-standard-spaces. When I run the code (using a custom template that is structured according to the templateflow structure) I get an error which says that the name of the template (here: ‘tpl-MyCustom’) is not a valid identifier - since it’s not part of a list of predefined templates (the exact error is: ValueError: space identifier “/imports/tpl-MyCustom” is invalid; Valid identifiers are: […]). However, I understood from the documentation that the use of a custom template is already a feature that is available in fMRIPrep 20.0.0. Did I misunderstand the documentation, and is the use of a custom template not yet available in fMRIPrep 20.0.1? If so, when do you think it might be available?

Thanks in advance.

Hi @halmgren - are you running fMRIPrep through a container? If so, is your TemplateFlow directory (where your custom template should be) mounted?

Hi, yes I am running fmriprep through a container (using the fmriprep-docker command), and the templateflow directory is mounted (tried with different directories to be sure).

This is the command I use:

fmriprep-docker [path_to_BIDS_folder] [path_to_output_folder] participant --work-dir [path_to_work_dir] --participant-label 1 --output-spaces [path_to_templateflow_folder]/tpl-MyCustom --fs-license-file [path_to_freesurfer_folder]/license.txt --nthreads 12 --fs-no-reconall

This is the how my templateflow directory looks like:

tpl-MyCustom/
template_description.json
tpl-MyCustom_res-1_T1w.nii.gz
tpl-MyCustom_res-1_desc-brain_mask.nii.gz

This is the response I get:

RUNNING: docker run --rm -it -e DOCKER_VERSION_xxx=18.04.0-ce -v [path_to_freesurfer_folder]/license.txt:/opt/freesurfer/license.txt:ro -v [path_to_BIDS_folder]:/data:ro -v [path_to_output_folder]:/out -v [path_to_work_dir]:/scratch -v [path_to_templateflow_folder]/tpl-MyCustom:/imports/tpl-MyCustom:ro poldracklab/fmriprep:20.0.1 /data /out participant --participant-label 1 --nthreads 12 --fs-no-reconall -w /scratch --output-spaces /imports/tpl-MyCustom

And this is the line at which the error occurs:

File “/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/utils/spaces.py”, line 220, in _check_name
‘identifiers are: %s’ % (value, ', '.join(valid)))

I have checked the code as well (i.e. spaces.py), but didn’t find where it allows to include custom templates.

Thanks for the detailed response, the problem is due to a bug in the fmriprep-docker wrapper and will be fixed in an upcoming release.

Ok, thanks for the help.:slight_smile:

@halmgren a new version (20.0.2) is out that should fix the issue

Great, it indeed works now.:slight_smile:

Thanks a lot!

MANAGED BY INCF