Fmriprep: Robust spatial normalization failed

Summary of what happened:

Hi, I am using fmriprep to preprocess my data. I initially downloaded the public dataset (Flanker) online and processed it well using fmriprep. But when I tried to use my own dataset, an error occurred. The code shows ‘Runtime Error: Robust spatial normalization failed after 3 trials.’. Since the Flanker dataset is a normal human dataset and my dataset contains brain lesions, I suspect that this may be the reason for the normalization failure. I added the lesion_roi.nii file to my dataset, but in the end, Robust spatial normalization failed after 3 trials. Does anyone know what’s going on?

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

 fmriprep-docker /my_data_path/ /my_data_path/derivatives/ participant --participant-label sub-001 --fs-license-file /my_data_path/derivatives/license.txt --output-spaces fsLR --cifti-output --stop-on-first-crash

Version:

24.1

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

Docker

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):

Node: fmriprep_24_1_wf.sub_001_wf.anat_fit_wf.register_template_wf.registration
Working directory: /tmp/work/fmriprep_24_1_wf/sub_001_wf/anat_fit_wf/register_template_wf/_template_MNI152NLin2009cAsym/registration

Node inputs:

explicit_masking = True
flavor = precise
float = True
initial_moving_transform = <undefined>
lesion_mask = <undefined>
moving = T1w
moving_image = <undefined>
moving_mask = <undefined>
num_threads = 8
orientation = RAS
reference = T1w
reference_image = <undefined>
reference_mask = <undefined>
settings = <undefined>
template = MNI152NLin2009cAsym
template_resolution = <undefined>
template_spec = <undefined>

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/lib/python3.11/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.11/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/fmriprep/lib/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/fmriprep/lib/python3.11/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.11/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/opt/conda/envs/fmriprep/lib/python3.11/site-packages/niworkflows/interfaces/norm.py", line 245, in _run_interface
	    raise RuntimeError(
	RuntimeError: Robust spatial normalization failed after 3 retries.

Screenshots / relevant information:

recon-all result


Hi @zifan_wang and welcome to neurostars!

Can you show the tree structure of your subject data so we can see if you added the lesion ROI correctly?

Best,
Steven

Hi Steven,

Thanks for your quick reply! This is the sub-001 tree.

Best,
Zifan

Hi @zifan_wang,

It looks like there’s an extra _T1w in the file name for the lesion (should just be sub-001_label-lesion_roi.nii.gz). I’m not fixing that will make a difference, but can you do that and try again? When you rerun, can you specify a working directory (-w argument) so we can inspect those outputs, need be? Also, can you confirm the lesion ROI and T1w are well aligned with each other?

Best,
Steven

Hi Steven,

I will fix the name and add -w, thanks for your suggestion. As for the ROI and T1W alignment. I use ITK-SNAP to create a ROI by semi-supervised. This is the result and I think they align well.
No ROI


add ROI

Best,
Zifan

Hi Steven,

Still stuck in the registration step.

[Node] Error on “fmriprep_24_1_wf.sub_001_wf.anat_fit_wf.register_template_wf.registration” (/scratch/fmriprep_24_1_wf/sub_001_wf/anat_fit_wf/register_template_wf/_template_MNI152NLin2009cAsym/registration)
2024-11-04 06:47:32,509 [ WARNING] [Node] Error on “fmriprep_24_1_wf.sub_001_wf.anat_fit_wf.register_template_wf.registration” (/scratch/fmriprep_24_1_wf/sub_001_wf/anat_fit_wf/register_template_wf/_template_MNI152NLin2009cAsym/registration)
241104-06:47:34,304 nipype.workflow ERROR:
Node registration.a0 failed to run on host 24a586c5a0e1.
2024-11-04 06:47:34,304 [ ERROR] Node registration.a0 failed to run on host 24a586c5a0e1.
241104-06:47:34,324 nipype.workflow ERROR:
Saving crash info to /out/sub-001/log/20241104-055751_b3629f2d-fca4-44f7-bd82-bf46105fe0df/crash-20241104-064734-root-registration.a0-8266b613-26a8-43a6-9baa-02d6eb46cbcd.txt
Traceback (most recent call last):
File “/opt/conda/envs/fmriprep/lib/python3.11/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.11/site-packages/nipype/pipeline/engine/nodes.py”, line 527, in run
result = self._run_interface(execute=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/conda/envs/fmriprep/lib/python3.11/site-packages/nipype/pipeline/engine/nodes.py”, line 645, in _run_interface
return self._run_command(execute)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/conda/envs/fmriprep/lib/python3.11/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.11/site-packages/nipype/interfaces/base/core.py”, line 397, in run
runtime = self._run_interface(runtime)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/conda/envs/fmriprep/lib/python3.11/site-packages/niworkflows/interfaces/norm.py”, line 245, in _run_interface
raise RuntimeError(
RuntimeError: Robust spatial normalization failed after 3 retries.

It shows there is a registration problem from orignal T1 to MIN152, but I do not konw why this happen since if I use Flanker dataset it would run well without error. And this is the report in /scratch/fmriprep_24_1_wf/sub_001_wf/anat_fit_wf/register_template_wf/_template_MNI152NLin2009cAsym/registration

Node: sub_001_wf (anat_fit_wf (register_template_wf (registration (norm)
========================================================================


 Hierarchy : fmriprep_24_1_wf.sub_001_wf.anat_fit_wf.register_template_wf.registration
 Exec ID : registration.a0


Original Inputs
---------------


* explicit_masking : True
* flavor : precise
* float : True
* initial_moving_transform : <undefined>
* lesion_mask : /data/sub-001/anat/sub-001_label-lesion_roi.nii.gz
* moving : T1w
* moving_image : /scratch/fmriprep_24_1_wf/sub_001_wf/anat_fit_wf/register_template_wf/_template_MNI152NLin2009cAsym/trunc_mov/sub-001_T1w_noise_corrected_corrected_xform_maths.nii.gz
* moving_mask : /scratch/fmriprep_24_1_wf/sub_001_wf/anat_fit_wf/refinement_wf/refine/sub-001_T1w_noise_corrected_corrected_xform_rbrainmask.nii.gz
* num_threads : 8
* orientation : RAS
* reference : T1w
* reference_image : <undefined>
* reference_mask : <undefined>
* settings : <undefined>
* template : MNI152NLin2009cAsym
* template_resolution : <undefined>
* template_spec : {}

So I guess fmriprep has identified the lesion_mask. Do you have any suggestion for this problem? Thank you very much.

Best,
Zifan