fMRIprep custom template not working (v23.2.1)

Summary of what happened:

I am interested in using the MIITRA 1 mm template for my older adult study. However, my code keeps failing to run. I went through the Template Flow directions as stated in the fmriprep website and tried troubleshooting based on previous forum discussions, but it still fails. I’d appreciate any advice or insight, thank you!

Note: if I take out the line that mounts templateflow and change the output space to T1w, my code runs fine.

Command used (and if a helper script was used, a link to the helper script or the command generated):

docker run -it --rm \
-v [path to data]:/data:ro \
-v [path to freesurfer license]:/opt/freesurfer/license.txt \
-v [path to output folder]/:/out \
-v [path to CustomTemplateFlow]:/home/fmriprep/.cache/templateflow \
nipreps/fmriprep:23.2.1 \
/data /out participant \
--skip_bids_validation \
--fs-no-reconall \
--ignore slicetiming \
--fd-spike-threshold 0.8 \
--dvars-spike-threshold 1.8 \
--nprocs 10 \
--participant_label sub-002 \ 
--output-spaces /tpl-MIITRA1mm 

Version:

23.2.1

Environment (Docker, Singularity / Apptainer, custom installation):

Docker

Relevant log outputs (up to 20 lines):

fmriprep: error: One or more participant labels were not found in the BIDS directory:  .

Note: this log output doesn't make sense to me because my code runs fine when using a pre-existing template, so I don't think it's a BIDS issue. 

Screenshots / relevant information:

My CustomTemplateFlow folder is organized as follows:

CustomTemplateFlow /
tpl-MIITRA1mm /
template_description.json
tpl-MIITRA1mm_desc-brain_mask.nii.gz
tpl-MIITRA1mm_T1w.nii.gz

Trouble-shooting I’ve attempted:

  • Tried different versions of fMRIprep
  • Tried -e TEMPLATEFLOW_HOME=‘/CustomTemplateFlow’
  • Tried specifying my subject as 002 instead of sub-002
  • Tried changing the output space to “/MIITRA1mm” and “MIITRA1mm”

Hi @ari1, and welcome to neurostars!

Try changing this to --output-spaces MIITRA1mm.

Can you also return the outputs of tree on your custom templateflow folder to show us the outputs?

Can you also remove the --skip-bids-validation and tell us the BIDS validation report?

Best,
Steven

Best,
Steven

Hi Steven,

Thanks for the welcome and thank you for your help!
I tried changing it to MIITRA1mm but it still gives the same error.

The outputs of tree on my CustomTemplateFlow folder is very long because it contains all of the other fmriprep tpls so here are screenshot of the CustomTemplateFlow folder contents and the tree outputs of my tpl-MIITRA1mm folder.

CustomTemplateFlow/tpl-MIITRA1mm/
├── template_description.json
├── tpl-MIITRA1mm_desc-brain_mask.nii.gz
├── tpl-MIITRA1mm_res-01_desc-brain_mask.nii.gz
├── tpl-MIITRA1mm_res-01_T1w.nii.gz
└── tpl-MIITRA1mm_T1w.nii.gz

Lastly, I removed —skip-bids-validation and the error is:

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/bin/fmriprep", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/run.py", line 40, in main
    parse_args()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/parser.py", line 828, in parse_args
    validate_input_dir(config.environment.exec_env, opts.bids_dir, opts.participant_label)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/utils/bids.py", line 227, in validate_input_dir
    raise RuntimeError(error_msg % ','.join(bad_labels))
RuntimeError: Data for requested participant(s) label(s) not found. Could not find data for participant(s):  . Please verify the requested participant labels. This error can be caused by the input data not being accessible inside the docker container. Please make sure all volumes are mounted properly (see https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v---read-only)

This is what sub-002’s folder looks like:

temp_input/
├── dataset_description.json
└── sub-002
    ├── anat
    │   ├── sub-002_T1w.json
    │   └── sub-002_T1w.nii.gz
    ├── dwi
    │   ├── sub-002_AP_dwi.bval
    │   ├── sub-002_AP_dwi.bvec
    │   ├── sub-002_AP_dwi.json
    │   ├── sub-002_AP_dwi.nii.gz
    │   ├── sub-002_PA_dwi.json
    │   ├── sub-002_PA_dwi.nii.gz
    │   ├── sub-002_trace_dwi.json
    │   └── sub-002_trace_dwi.nii.gz
    └── func
        ├── sub-002_task-MID_bold.json
        ├── sub-002_task-MID_bold.nii.gz
        ├── sub-002_task-rest_bold.json
        └── sub-002_task-rest_bold.nii.gz

Hi @ari1,

Is temp_input your BIDS directory input for fMRIPrep? I would advise fixing the DWI folder so it is BIDS valid, or at the very least adding a .bidsignore file with the line */dwi/ to ignore the DWI. I guess you also don’t need to specify a subject label if temp_input only has that one subject.

Best,
Steven

Hi Steven,

I changed my custom template folder to be:

tpl-MIITRA/
├── template_description.json
├── tpl-MIITRA_res-01_desc-brain_mask.nii.gz
├── tpl-MIITRA_res-01_T1w.nii.gz
├── tpl-MIITRA_res-02_desc-brain_mask.nii.gz
└── tpl-MIITRA_res-02_T1w.nii.gz

I made the modifications you suggested and my current code is:

docker run -it --rm \
-v [bids path]/temp_input:/data:ro \
-v [license path]/freesurfer/license.txt:/opt/freesurfer/license.txt \
-v [output path]/temp_output/:/out \
-v [template path]/CustomTemplateFlow:/home/fmriprep/.cache/templateflow \
nipreps/fmriprep:23.2.1 \
/data /out participant \
--fs-no-reconall \
--ignore slicetiming \
--fd-spike-threshold 0.8 \
--dvars-spike-threshold 1.8 \
--nprocs 10 \
--output-spaces MIITRA:res-1

and I am now getting a new error:

node[9]: ../../src/node_platform.cc:68:std::unique_ptr<long unsigned int> node::WorkerThreadsTaskRunner::DelayedTaskScheduler::Start(): Assertion `(0) == (uv_thread_create(t.get(), start_thread, this))' failed.
 1: 0x7fc55135a2b9 node::Abort() [/opt/conda/envs/fmriprep/bin/../lib/libnode.so.108]
 2: 0x7fc55135a34b  [/opt/conda/envs/fmriprep/bin/../lib/libnode.so.108]
 3: 0x7fc5513d1fbd node::WorkerThreadsTaskRunner::WorkerThreadsTaskRunner(int) [/opt/conda/envs/fmriprep/bin/../lib/libnode.so.108]
 4: 0x7fc5513d20c7 node::NodePlatform::NodePlatform(int, v8::TracingController*, v8::PageAllocator*) [/opt/conda/envs/fmriprep/bin/../lib/libnode.so.108]
 5: 0x7fc5513153a7  [/opt/conda/envs/fmriprep/bin/../lib/libnode.so.108]
 6: 0x7fc5513178c4 node::InitializeOncePerProcess(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, node::ProcessFlags::Flags) [/opt/conda/envs/fmriprep/bin/../lib/libnode.so.108]
 7: 0x7fc551318093 node::Start(int, char**) [/opt/conda/envs/fmriprep/bin/../lib/libnode.so.108]
 8: 0x7fc5508d4d90  [/usr/lib/x86_64-linux-gnu/libc.so.6]
 9: 0x7fc5508d4e40 __libc_start_main [/usr/lib/x86_64-linux-gnu/libc.so.6]
10: 0x556f0027e07f  [node]
Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/bin/fmriprep", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/run.py", line 40, in main
    parse_args()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/parser.py", line 828, in parse_args
    validate_input_dir(config.environment.exec_env, opts.bids_dir, opts.participant_label)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/utils/bids.py", line 237, in validate_input_dir
    subprocess.check_call(['bids-validator', str(bids_dir), '-c', temp.name])
  File "/opt/conda/envs/fmriprep/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['bids-validator', '/data', '-c', '/tmp/tmpcjqxoocy.json']' died with <Signals.SIGABRT: 6>.

Hi @ari1,

What happens if you skip bids validation now?

Hi Steven,

This is the updated error log with skip bids validation:

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/bin/fmriprep", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/run.py", line 96, in main
    retval = mgr.dict()
  File "/opt/conda/envs/fmriprep/lib/python3.10/multiprocessing/managers.py", line 723, in temp
    token, exp = self._create(typeid, *args, **kwds)
  File "/opt/conda/envs/fmriprep/lib/python3.10/multiprocessing/managers.py", line 606, in _create
    conn = self._Client(self._address, authkey=self._authkey)
  File "/opt/conda/envs/fmriprep/lib/python3.10/multiprocessing/connection.py", line 502, in Client
    c = SocketClient(address)
  File "/opt/conda/envs/fmriprep/lib/python3.10/multiprocessing/connection.py", line 630, in SocketClient
    s.connect(address)
FileNotFoundError: [Errno 2] No such file or directory

Hi @ari1,

Can you try mounting and specifying a working directory for fmriprep (-w argument) that you are sure you have read/write access to? Do not put it in the BIDS directory.

Best,
Steven

Hi Steven,

Here is the updated code with the working dir:

docker run -it --rm \
-v /gaia/duncanlab/mematt/fmriprep_preprocessed/temp_input:/data:ro \
-v /gaia/duncanlab/mematt/freesurfer/license.txt:/opt/freesurfer/license.txt \
-v /gaia/duncanlab/mematt/fmriprep_preprocessed/temp_output/:/out \
-v /gaia/duncanlab/mematt/fmriprep_preprocessed/CustomTemplateFlow:/home/fmriprep/.cache/templateflow \
-v /gaia/duncanlab/mematt/fmriprep_preprocessed//scratch:/scratch \
nipreps/fmriprep:23.2.1 \
/data /out participant \
--fs-no-reconall \
--ignore slicetiming \
--fd-spike-threshold 0.8 \
--dvars-spike-threshold 1.8 \
--skip_bids_validation \
--nprocs 10 \
--output-spaces MIITRA:res-1 \
-w /scratch

However, it seems to still give the same error as before:

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/bin/fmriprep", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/run.py", line 96, in main
    retval = mgr.dict()
  File "/opt/conda/envs/fmriprep/lib/python3.10/multiprocessing/managers.py", line 723, in temp
    token, exp = self._create(typeid, *args, **kwds)
  File "/opt/conda/envs/fmriprep/lib/python3.10/multiprocessing/managers.py", line 606, in _create
    conn = self._Client(self._address, authkey=self._authkey)
  File "/opt/conda/envs/fmriprep/lib/python3.10/multiprocessing/connection.py", line 502, in Client
    c = SocketClient(address)
  File "/opt/conda/envs/fmriprep/lib/python3.10/multiprocessing/connection.py", line 630, in SocketClient
    s.connect(address)
FileNotFoundError: [Errno 2] No such file or directory

This is what’s in the scratch folder:

scratch/
└── 20240322-160244_382d0b04-7a01-42ef-8fbc-f39ccaa33320
    ├── bids_db
    │   └── layout_index.sqlite
    └── config.toml

Is it still the case that you get past this error when not including the templateflow changing lines?

Hi I did create also my custom template with MIITRA and this is my script with singularity:

#!/bin/bash
#SBATCH --mail-type=ALL 			# Mail events (NONE, BEGIN, END, FAIL, ALL)
#SBATCH -p skylake
#SBATCH --mail-user=julien.sein@univ-amu.fr	# Your email address
#SBATCH -A b163
#SBATCH --nodes=1					# OpenMP requires a single node
#SBATCH --mem=64GB
#SBATCH --cpus-per-task=8
#SBATCH --time=50:00:00				# Time limit hh:mm:ss
#SBATCH -o ./log/%x-%A-%a.out
#SBATCH -e ./log/%x-%A-%a.err
#SBATCH -J fmriprep_TOLD_MIITRA

set -eu
# Get arguments from submit_job_array.sh
base=$1
study=$2
args=($@)
subjs=(${args[@]:2})
sub=${subjs[${SLURM_ARRAY_TASK_ID}]}
echo $sub

# Define scratch, derivatives, and container paths for convenience
scratch=/scratch/jsein/BIDS/temp_data_${study}
mkdir -p $scratch

export SINGULARITYENV_TEMPLATEFLOW_HOME=/home/fmriprep/.cache/templateflow

singularity run -B /scratch/jsein/BIDS:/work,$HOME/.templateflow:/home/fmriprep/.cache/templateflow --cleanenv \
 		 /scratch/jsein/my_images/fmriprep-21.0.2.simg \
		 --fs-license-file /work/freesurfer/license.txt /work/$study /work/$study/derivatives/fmriprep_MIITRA  \
		 participant --participant-label $sub \
		 -w /work/temp_dataMIITRA_${study}\
		 --mem-mb 50000 --omp-nthreads 10 --nthreads 12  \
		 --fd-spike-threshold 0.5 --dvars-spike-threshold 2.0 --bold2t1w-dof 9 --skull-strip-template MIITRA   \
		 --output-spaces MNI152NLin2009cAsym MIITRA T1w  --ignore slicetiming --debug compcor \
		 --fs-subjects-dir /work/$study/derivatives/fmriprep_MIITRA/sourcedata/freesurfer 

And the content of the folder tpl-MIITRA:

tree .templateflow/tpl-MIITRA
.templateflow/tpl-MIITRA
|-- template_description.json
|-- tpl-MIITRA_res-01_T1w.nii.gz
|-- tpl-MIITRA_res-01_desc-brain_mask.nii.gz
|-- tpl-MIITRA_res-01_label-CSF_probseg.nii.gz
|-- tpl-MIITRA_res-01_label-GM_probseg.nii.gz
|-- tpl-MIITRA_res-01_label-WM_probseg.nii.gz
|-- tpl-MIITRA_res-01_label-brain_probseg.nii.gz
|-- tpl-MIITRA_res-02_T1w.nii.gz
|-- tpl-MIITRA_res-02_desc-brain_mask.nii.gz
|-- tpl-MIITRA_res-02_label-CSF_probseg.nii.gz
|-- tpl-MIITRA_res-02_label-GM_probseg.nii.gz
|-- tpl-MIITRA_res-02_label-WM_probseg.nii.gz
`-- tpl-MIITRA_res-02_label-brain_probseg.nii.gz

Hi Steven,
Yes, it runs fine when not including the custom template flow.

Hi,

I tried defining the template flow path in the environment as you have,


export TEMPLATEFLOW_HOME=/home/fmriprep/.cache/templateflow

docker run -it --rm \
-v /gaia/duncanlab/mematt/fmriprep_preprocessed/temp_input:/data:ro \
-v /gaia/duncanlab/mematt/freesurfer/license.txt:/opt/freesurfer/license.txt \
-v /gaia/duncanlab/mematt/fmriprep_preprocessed/temp_output/:/out \
-v /gaia/duncanlab/mematt/fmriprep_preprocessed/.templateflow:/home/fmriprep/.cache/templateflow \
-v /gaia/duncanlab/mematt/fmriprep_preprocessed/scratch:/scratch \
-e TEMPLATEFLOW_HOME=/home/fmriprep/.cache/templateflow \
nipreps/fmriprep:21.0.2 \
/data /out participant \
--fs-no-reconall \
--ignore slicetiming \
--fd-spike-threshold 0.8 \
--dvars-spike-threshold 1.8 \
--skip_bids_validation \
--nthreads 10 \
--output-spaces MIITRA \
-w /scratch

and now I am getting a new error which looks promising, but I’m not sure why it’s looking at tpl-OASIS30ANTS when I specified MIITRA in my output-space:

         #################################################################
240322-17:53:00,679 nipype.workflow WARNING:
	 Previous output generated by version 0+unknown found.
240322-17:53:00,701 nipype.workflow IMPORTANT:
	 Building fMRIPrep's workflow:
           * BIDS dataset path: /data.
           * Participant list: ['002'].
           * Run identifier: 20240322-175239_5bbb0cd5-7d83-480f-b1a2-675ea72b92ad.
           * Output spaces: MIITRA:res-native.
           * Pre-run FreeSurfer's SUBJECTS_DIR: /out/sourcedata/freesurfer.
Process Process-2:
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/opt/conda/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/lib/python3.8/site-packages/fmriprep/cli/workflow.py", line 118, in build_workflow
    retval["workflow"] = init_fmriprep_wf()
  File "/opt/conda/lib/python3.8/site-packages/fmriprep/workflows/base.py", line 85, in init_fmriprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/opt/conda/lib/python3.8/site-packages/fmriprep/workflows/base.py", line 259, in init_single_subject_wf
    anat_preproc_wf = init_anat_preproc_wf(
  File "/opt/conda/lib/python3.8/site-packages/smriprep/workflows/anatomical.py", line 376, in init_anat_preproc_wf
    brain_extraction_wf = init_brain_extraction_wf(
  File "/opt/conda/lib/python3.8/site-packages/niworkflows/anat/ants.py", line 198, in init_brain_extraction_wf
    tpl_target_path, common_spec = get_template_specs(
  File "/opt/conda/lib/python3.8/site-packages/niworkflows/utils/misc.py", line 90, in get_template_specs
    raise RuntimeError(
RuntimeError: The available template modifiers ({'suffix': 'T1w', 'desc': None, 'atlas': None, 'resolution': 1}) did not select a unique template (got "/home/fmriprep/.cache/templateflow/.templateflow/tpl-OASIS30ANTs/tpl-OASIS30ANTs_res-01_T1w.nii.gz, /home/fmriprep/.cache/templateflow/tpl-OASIS30ANTs/tpl-OASIS30ANTs_res-01_T1w.nii.gz"). Please revise your template argument.

Hi @ari1,

The OASIS template is used for skull stripping. It looks like fmriprep has identified two templateflow directories.

/home/fmriprep/.cache/templateflow/.templateflow/
/home/fmriprep/.cache/templateflow/

Did you change CustomTemplateFlow to .templateflow on your local system?

What if you do -v /gaia/duncanlab/mematt/fmriprep_preprocessed/.templateflow:/templateflow \ and -e TEMPLATEFLOW_HOME=/templateflow instead?

Best,
Steven

Hi Steven,

Yes, I had tried renaming it as @jsein had it - I tried your suggestion of mounting it as /templateflow but it’s still giving me the same type of error.

I tried adding the MIITRA as the skull-strip-template and reverting my folder back to my old naming convention of CustomTemplate Flow (and deleting the hidden folder .templateflow/) but I am getting the following error:

    Spatial References: MIITRA

240322-18:39:56,940 nipype.utils WARNING:
	 Could not check for version updates:
Connection to server could not be made
240322-18:39:57,889 nipype.workflow IMPORTANT:
	 Creating bold processing workflow for "/data/sub-002/func/sub-002_task-MID_bold.nii.gz" (0.11 GB / 296 TRs). Memory resampled/largemem=0.42/0.74 GB.
240322-18:39:57,898 nipype.workflow IMPORTANT:
	 No single-band-reference found for sub-002_task-MID_bold.nii.gz
Process Process-2:
Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py", line 693, in build_workflow
    bids_filters=bids_filters,
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/base.py", line 274, in init_fmriprep_wf
    bids_filters=bids_filters,
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/base.py", line 638, in init_single_subject_wf
    use_syn=use_syn,
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/bold/base.py", line 460, in init_func_preproc_wf
    bold_reference_wf = init_bold_reference_wf(omp_nthreads=omp_nthreads)
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/func/util.py", line 117, in init_bold_reference_wf
    omp_nthreads=omp_nthreads, pre_mask=pre_mask)
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/func/util.py", line 303, in init_enhance_and_skullstrip_bold_wf
    verbose=True),
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/ants/base.py", line 75, in __init__
    super(ANTSCommand, self).__init__(**inputs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 673, in __init__
    super(CommandLine, self).__init__(**inputs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 183, in __init__
    self.inputs = self.input_spec(**inputs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/specs.py", line 66, in __init__
    super(BaseTraitedSpec, self).__init__(**kwargs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/traits/trait_types.py", line 1493, in validate
    self.error( object, name, value )
  File "/usr/local/miniconda/lib/python3.7/site-packages/traits/trait_handlers.py", line 172, in error
    value )
traits.trait_errors.TraitError: The 'fixed_image' trait of a _AIInputSpec instance must be a file name, but a value of "[PosixPath('/home/fmriprep/.cache/templateflow/.templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-fMRIPrep_boldref.nii.gz'), PosixPath('/home/fmriprep/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-fMRIPrep_boldref.nii.gz')]" <class 'str'> was specified.

Are you on a system that doesn’t have internet? E.g., a computing cluster? Templateflow is a datalad repository, which means files are pulled from the internet as they are needed. That last error could be due to not having template files downloaded.

Actually on second thought it looks like that error is still from two templateflow directories being found.

Hi Steven,

I am running it on my server which should have access to the Internet - also it runs fine with the T1w as the output space, so I’m not sure what to make of this error message :frowning:

docker run -it --rm \
-v [bids path]/temp_input:/data:ro \
-v [license path]/freesurfer/license.txt:/opt/freesurfer/license.txt \
-v [output path]/temp_output/:/out \
-v /gaia/duncanlab/mematt/fmriprep/scratch:/scratch \
nipreps/fmriprep:23.2.1 \
/data /out participant \
--fs-no-reconall \
--ignore slicetiming \
--fd-spike-threshold 0.8 \
--dvars-spike-threshold 1.8 \
--skip_bids_validation \
--output-spaces T1w \
-w /scratch

Hi @ari1,

What if you, rather than make a new templateflow directory, just copy/paste the tpl-MIITRA folder in to where fmriprep looks for templates by default? For me, (mac / linux) it is at $HOME/.cache/templateflow. Then in your fmriprep command, just change the --output-space argument.

Hi Steven,

I finally got it to work! What was halting the code was:

  1. A hidden folder (.templateflow) got created when the empty template folders were copied over into CustomTemplate Flow that I had to delete
  2. It still needed tpl-MNI152NLin2009cAsym/ to run even though my output space is MIITRA so I downloaded that from OSF

The final code that worked:

    docker run --rm \
    -v [bids path]/bids:/data:ro \
    -v [license path]/freesurfer/license.txt:/opt/freesurfer/license.txt \
    -v [output path]/derivatives:/out \
    -v [custom template path]/CustomTemplateFlow:/home/fmriprep/.cache/templateflow \
    -v [working dir path]/scratch:/scratch \
    nipreps/fmriprep:23.2.1 \
    /data /out participant \
    --participant_label $1 \
    --fs-no-reconall \
    --ignore slicetiming \
    --fd-spike-threshold 0.8 \
    --dvars-spike-threshold 1.8 \
    --skip_bids_validation \
    --output-spaces MIITRA:res-1 \
    -w /scratch

Thank you for all your help! I really appreciate it :slight_smile: