Custom output space in fmriprep

Summary of what happened:

Hello,

I would like to run fmriprep (version: 23.2.1) on a group of subjects with the 3mm version of the MNI152NLin2009cAsym standardized space as one of my output spaces. Given that (to my understanding) this is not an available option in template flow, I created a new folder under ~/.cache/templateflow/ called tpl-MNI152NLin2009cAsym3mm, under which I created the three files: template_description.json, tpl-MNI152NLin2009cAsym3mm_res-01_T1w.nii.gz corresponding to the tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz file found under ~/.cache/templateflow/tpl-MNI152NLin2009cAsym/ resampled to 3mm isotropic space, and its skull extracted version tpl-MNI152NLin2009cAsym3mm_res-01_desc-brain_T1w.nii.gz.

I tried to run fmriprep on a given subject, which unfortunately exited with an error. As a note, fmriprep runs perfectly fine with this command with any other output space available with templateflow.

Would you happen to know what is causing this issue? Should I be doing something else to indicate to templateflow that I would like to use this custom space? Btw if the 3mm version of the MNI152NLin2009cAsym standardized output space is actually available on templateflow and I haven’t realized it, please do let me know!

Thank you,
Panos

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

I then ran the command:

singularity run --cleanenv --writable-tmpfs \
    -B $FREESURFER_HOME -B $templateflow_path \
    $fmriprep      \
    $bids_dir $output_dir participant \
    --fs-license-file $FREESURFER_HOME/license.txt \
    --fs-subjects-dir $freesurfer_dir \
    --participant-label $subj \
    --skip-bids-validation \
    --force-no-bbr \
    --output-spaces anat MNI152NLin2009cAsym3mm:res-01 \
    -w $work_dir

Version:

23.2.1

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

Singularity

Data formatted according to a validatable standard? Please provide the output of the validator:

PASTE VALIDATOR OUTPUT HERE

Relevant log outputs (up to 20 lines):

The last pertinent lines from my output file after running the above command are:

250529-10:56:47,238 nipype.workflow INFO:
	 [Node] Cached "_msmsulc1" - collecting precomputed outputs
250529-10:56:47,238 nipype.workflow INFO:
	 [Node] "_msmsulc1" found cached.
250529-10:56:55,24 nipype.workflow ERROR:
	 could not run node: fmriprep_23_2_wf.sub_02_wf.anat_fit_wf.register_template_wf.registration.a0
250529-10:56:55,332 nipype.workflow CRITICAL:
	 fMRIPrep failed: Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node registration.

Traceback:
	Traceback (most recent call last):
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nibabel/loadsave.py", line 100, in load
	    stat_result = os.stat(filename)
	FileNotFoundError: [Errno 2] No such file or directory: '[]'

	During handling of the above exception, another exception occurred:

	Traceback (most recent call last):
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/niworkflows/interfaces/norm.py", line 182, in _run_interface
	    ants_args = self._get_ants_args()
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/niworkflows/interfaces/norm.py", line 457, in _get_ants_args
	    args["fixed_image"] = mask(
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/niworkflows/interfaces/norm.py", line 504, in mask
	    mask_nii = nb.load(mask_file)
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nibabel/loadsave.py", line 102, in load
	    raise FileNotFoundError(f"No such file or no access: '{filename}'")
	FileNotFoundError: No such file or no access: '[]'

And then from the error file:

250529-10:57:05,622 cli ERROR:
	 Preprocessing did not finish successfully. Errors occurred while processing data from participants: 02 (4). Check the HTML reports for details.

-----------------------------------------------------------------

and from the **error** file:

-----------------------------------------------------------------
...

[WARNING] Citeproc: citation mni152nlin2009casym3mm not found

-----------------------------------------------------------------

Screenshots / relevant information:

Hi @pfotiad,

In the future please use the Software Support post category and template. You can see I edited in for you this time.

A few things:

  1. Perhaps in your singularity command, specify the TEMPLATEFLOW_HOME environment variable with the --env flag. Otherwise it might be pulling from some other one you are unaware of.
  2. Please return the tree structure of your templateflow folder.
  3. Perhaps it would work better if you make these files under the regular tpl-MNI152NLin2009cAsym with a different res-<> modifier.
  4. Always worth trying up-to-date software (25.1.1 at this time).

Best,
Steven

Hi Steven,

Will do – thank you so much for the really helpful suggestions. Adding the new files under the regular tpl-MNI152NLin2009cAsym with a different res-<> modifier did the trick!

Best,
Panos

1 Like