Fmriprep fsnative2t1w registration error in some scans

Hi,

I am getting the below error for some scans, but not all, when running fmriprep 23.0.2. The file ‘T1_robustreg.lta’ is indeed not present but should be created by the fmriprep run. There is still enough storage space on the server. Any idea what is causing this error?
Thanks!

Command used

singularity run --cleanenv --bind "/projects/lab/shared/:"/projects/lab/shared/" \
    /projects/lab/shared/BIDS/SingularityContainers/fmriprep-23.0.2.simg \
    /projects/lab/shared/study/bids_data_sep_wave /projects/lab/shared/study/fmriprep_23.0.2 \
	participant --participant_label ${SUBJ} -w /projects/lab/shared/study/working -t SVC \
	--output-spaces T1w MNI152NLin2009cAsym \
	--fs-license-file /projects/lab/shared/study/BIDS/license.txt --skip_bids_validation --ignore slicetiming 

Version:

fmriprep 23.0.2

Environment (Docker, Singularity, custom installation):

singularity container

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

Data in bids format, only one T1w scan per fMRI scan

Relevant log outputs

230713-23:04:31,805 nipype.workflow CRITICAL:
	 fMRIPrep failed: Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/opt/conda/lib/python3.9/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 fsnative2t1w_xfm.

Cmdline:
	mri_robust_register --satit --iscale --lta /projects/lab/shared/study/fmriprep_23.0.2/working/fmriprep_23_0_wf/single_subject_Xw02_wf/anat_preproc_wf/surface_recon_wf/fsnative2t1w_xfm/T1_robustreg.lta --mov /projects/lab/shared/study/fmriprep_23.0.2/sourcedata/freesurfer/sub-Xw02/mri/T1.mgz --dst /projects/lab/shared/study/fmriprep_23.0.2/working/fmriprep_23_0_wf/single_subject_Xw02_wf/anat_preproc_wf/anat_validate/sub-Xw02_ses-wave2_T1w_ras_valid.nii.gz
Stdout:
	7.3.2

	--satit: Will iterate with different SAT to ensure outliers below wlimit!
	--iscale: Enabling intensity scaling!
	--lta: Output transform as /projects/lab/shared/study/fmriprep_23.0.2/working/fmriprep_23_0_wf/single_subject_Xw02_wf/anat_preproc_wf/surface_recon_wf/fsnative2t1w_xfm/T1_robustreg.lta . 
	--mov: Using /projects/lab/shared/study/fmriprep_23.0.2/sourcedata/freesurfer/sub-Xw02/mri/T1.mgz as movable/source volume.
	--dst: Using /projects/lab/shared/study/fmriprep_23.0.2/working/fmriprep_23_0_wf/single_subject_Xw02_wf/anat_preproc_wf/anat_validate/sub-Xw02_ses-wave2_T1w_ras_valid.nii.gz as target volume.

	reading source '/projects/lab/shared/study/fmriprep_23.0.2/sourcedata/freesurfer/sub-Xw02/mri/T1.mgz'...
	reading target '/projects/lab/shared/study/fmriprep_23.0.2/working/fmriprep_23_0_wf/single_subject_Xw02_wf/anat_preproc_wf/anat_validate/sub-Xw02_ses-wave2_T1w_ras_valid.nii.gz'...
	INFO: This is an unsigined short.

	Registration::setSourceAndTarget(MRI s, MRI t, keeptype = TRUE )
	   Type Source : 0  Type Target : 10  ensure both FLOAT (3)
	   Reordering axes in mov to better fit dst... ( -1 -3 2 )
	 Determinant after swap : 1.0001
	   Mov: (1, 1, 1)mm  and dim (256, 256, 256)
	   Dst: (0.9999, 1, 1)mm  and dim (176, 256, 256)
	   Asserting both images: 1mm isotropic 
	    - reslicing Mov ...
	       -- changing data type from 0 to 3 (noscale = 0)...
	    - reslicing Dst ...
	       -- changing data type from 10 to 3 (noscale = 0)...
	MRIchangeType: Building histogram 0 888 1000, flo=0, fhi=0.999, dest_type=3
	       -- Original : (0.9999, 1, 1)mm and (176, 256, 256) voxels.
	       -- Resampled: (1, 1, 1)mm and (256, 256, 256) voxels.
	       -- Reslicing using cubic bspline 
	MRItoBSpline degree 3


	 Registration::findSaturation 
	   - computing centroids 
Stderr:
	makeIsotropic WARNING: not different enough, won't reslice!
	CostFunctions::centroid is NAN (empty image? n = 0 )
Traceback:
	Traceback (most recent call last):
	  File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 398, in run
	    runtime = self._post_run_hook(runtime)
	  File "/opt/conda/lib/python3.9/site-packages/niworkflows/interfaces/freesurfer.py", line 248, in _post_run_hook
	    fix_lta_length(lta_file)
	  File "/opt/conda/lib/python3.9/site-packages/niworkflows/interfaces/freesurfer.py", line 399, in fix_lta_length
	    lines = Path(lta_file).read_text().splitlines(keepends=True)
	  File "/opt/conda/lib/python3.9/pathlib.py", line 1266, in read_text
	    with self.open(mode='r', encoding=encoding, errors=errors) as f:
	  File "/opt/conda/lib/python3.9/pathlib.py", line 1252, in open
	    return io.open(self, mode, buffering, encoding, errors, newline,
	  File "/opt/conda/lib/python3.9/pathlib.py", line 1120, in _opener
	    return self._accessor.open(self, flags, mode)
	FileNotFoundError: [Errno 2] No such file or directory: '/projects/lab/shared/study/fmriprep_23.0.2/working/fmriprep_23_0_wf/single_subject_Xw02_wf/anat_preproc_wf/surface_recon_wf/fsnative2t1w_xfm/T1_robustreg.lta'

Hi @mar1588, and welcome to neurostars!

Does this error persist with a fresh working directory and updating to the most recent release (23.2.0)? Also, what is the output of the BIDS validator report? Do you get this error with all subjects or is specific to sub-Xw02?

Best,
Steven

With BIDS validation on, it only warns about slice timing ([WARN] You should define ‘SliceTiming’ for this file.) but I don’t do slice time correction anyway.
I will try release 23.2 with a fresh working directory and will let you know

The FileNotFoundError is downstream of the NodeExecutionError, which results from mri_robust_register failing. Looking at the text of the error:

So it’s saying that the cost function is not calculable, and that this might mean one of the images is all zero. It would be good to look at the two images in a viewer (mricron, freeview, fsleyes, etc) to see if that is indeed the case. If so, then look at your input image; does it have the same problem? If your BIDS input was good but the input to this node is bad, you need to walk backwards to find where it transitioned. For example, to see how /projects/lab/shared/study/fmriprep_23.0.2/working/fmriprep_23_0_wf/single_subject_Xw02_wf/anat_preproc_wf/anat_validate/sub-Xw02_ses-wave2_T1w_ras_valid.nii.gz was created, look in /projects/lab/shared/study/fmriprep_23.0.2/working/fmriprep_23_0_wf/single_subject_Xw02_wf/anat_preproc_wf/anat_validate/_report/report.rst. In that report, you should find its inputs, which you can examine, and then check the corresponding report until you’ve traced back to the raw data.

If they both look fine, then I would look at them overlaid on one another; is there something obvious (e.g., the two images do not overlap at all) causing a problem?

If things overall look sensible, then I would rerun the command, outside the container, if possible. It’s listed under Cmdline in the output. You might get additional output that would be useful to pass along to the FreeSurfer team to debug the issue.