fMRIPrep fails on 1 subject amongst 3 in my dataset (T1w) - Node Name: fmriprep_25_0_wf.sub_02_wf.anat_fit_wf.surface_recon_wf.autorecon1

Summary of what happened:

I am usinf fMRIprep v25.0 to preprocess my data. My dataset is organised as BIDS, and sub-02, sub-03 and sub-04 are strictly similar in terms of data organisation. Surprisingly, sub-03 and sub-04 are preprocessed just well by fMRIprep, while sub-02 encountered an error: Node Name: fmriprep_25_0_wf.sub_02_wf.anat_fit_wf.surface_recon_wf.autorecon1

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

#!/bin/bash

# variable settings
root_dir=${PWD}
bids_dir=${root_dir}/bids
out_dir1=${root_dir}/fmriprep
work_dir=${out_dir1}/work
nthreads=28
mem=200 #gb
mem=`echo "${mem//[!0-9]/}"` #remove gb at end
mem_mb=`echo $((mem*1000))` 
echo 'export PATH=$PATH:~/.local/bin' >> ~/.bash_profile
source ~/.bash_profile
export FS_LICENSE=/home/touhara/freesurfer/license.txt


# fmriprep
for sub in $@;do
subnum=`printf %02d $sub`
start_time=`date "+%Y-%m-%d %H:%M:%S"`
fmriprep-docker $bids_dir $out_dir1 \
    participant \
    --participant-label $subnum \
    --md-only-boilerplate \
    --fs-license-file ${FS_LICENSE} \
    --nthreads $nthreads \
    --stop-on-first-crash \
    --mem_mb $mem_mb \
    --low-mem \
    --dummy-scans 7 \
    
end_time=`date "+%Y-%m-%d %H:%M:%S"`
echo start, $start_time
echo finish,$end_time
done

That I call with

su - touhara
cd /mnt/{path_to_rootdir}
./fmriprep.sh {subjects ID}

Version:

25.0.0

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

Docker

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

According to BIDS Validator , the only ERROR I got is

ERROR: SIDECAR_KEY_REQUIRED (SKULLSTRIPPED)
A data file's JSON sidecar is missing a key listed as required.
- /sub-04/fmap/sub-04_dir-PA_epi.nii.gz (Field description: Whether the volume was skull stripped (non-brain voxels set to zero) or not. )
- /sub-04/fmap/sub-04_dir-AP_epi.nii.gz (Field description: Whether the volume was skull stripped (non-brain voxels set to zero) or not. )
- /sub-04/anat/sub-04_T1w.nii.gz (Field description: Whether the volume was skull stripped (non-brain voxels set to zero) or not. )
- /sub-04/func/sub-04_task-odor_run-09_echo-1_bold.nii.gz (Field description: Whether the volume was skull stripped (non-brain voxels set to zero) or not. )
(and so on for all my sub fmap, anat and func)

But again, I face the issue with sub-02, not sub-03 nor 04.

Relevant log outputs (up to 20 lines):

File: <workdir>/sub-02/log/20250331-125334_87940b73-a1fa-4a76-91a1-c315d4bc53e3/crash-20250331-125948-root-autorecon1-7d5fc784-4e1c-4cd6-a992-9c7b78c9aa32.txt
Working Directory: /tmp/work/fmriprep_25_0_wf/sub_02_wf/anat_fit_wf/surface_recon_wf/autorecon1
(...)
 mri_info /out/sourcedata/freesurfer/sub-02/mri/rawavg.mgz 

	rawavg.mgz ========================================
	Volume information for /out/sourcedata/freesurfer/sub-02/mri/rawavg.mgz
	          type: MGH
	    dimensions: 208 x 300 x 320
	   voxel sizes: 0.800000, 0.809375, 0.809375
	          type: FLOAT (3)
	           fov: 259.000
	           dof: 1
	        xstart: -83.2, xend: 83.2
	        ystart: -121.4, yend: 121.4
	        zstart: -129.5, zend: 129.5
	            TR: 0.00 msec, TE: 0.00 msec, TI: 0.00 msec, flip angle: 0.00 degrees
	       nframes: 1
	       PhEncDir: UNKNOWN
	       FieldStrength: 0.000000
	ras xform present
	    xform info: x_r =   1.0000, y_r =   0.0000, z_r =  -0.0000, c_r =     0.2651
	              : x_a =   0.0000, y_a =   1.0000, z_a =  -0.0000, c_a =    23.5953
	              : x_s =   0.0000, y_s =   0.0000, z_s =   1.0000, c_s =     3.7655

	talairach xfm : 
	Orientation   : RAS
	Primary Slice Direction: axial

	voxel to ras transform:
	                0.8000   0.0000  -0.0000   -82.9349
	                0.0000   0.8094  -0.0000   -97.8109
	                0.0000   0.0000   0.8094  -125.7345
	                0.0000   0.0000   0.0000     1.0000

	voxel-to-ras determinant 0.52407

	ras to voxel transform:
	                1.2500   0.0000   0.0000   103.6686
	                0.0000   1.2355   0.0000   120.8475
	                0.0000   0.0000   1.2355   155.3477
	                0.0000   0.0000   0.0000     1.0000
	/out/sourcedata/freesurfer/sub-02

	 mri_convert /out/sourcedata/freesurfer/sub-02/mri/rawavg.mgz /out/sourcedata/freesurfer/sub-02/mri/orig.mgz --conform_min 

	mri_convert /out/sourcedata/freesurfer/sub-02/mri/rawavg.mgz /out/sourcedata/freesurfer/sub-02/mri/orig.mgz --conform_min 
	reading from /out/sourcedata/freesurfer/sub-02/mri/rawavg.mgz...
	TR=0.00, TE=0.00, TI=0.00, flip angle=0.00
	i_ras = (1, 0, 0)
	j_ras = (0, 1, 0)
	k_ras = (-0, -0, 1)
	changing data type from float to uchar (noscale = 0)...
	MRIchangeType: Building histogram -0.00440979 4095 1000, flo=0, fhi=0.999, dest_type=0
	Reslicing using trilinear interpolation 
	writing to /out/sourcedata/freesurfer/sub-02/mri/orig.mgz...

	 mri_add_xform_to_header -c /out/sourcedata/freesurfer/sub-02/mri/transforms/talairach.xfm /out/sourcedata/freesurfer/sub-02/mri/orig.mgz /out/sourcedata/freesurfer/sub-02/mri/orig.mgz 

	INFO: extension is mgz

	 mri_info /out/sourcedata/freesurfer/sub-02/mri/orig.mgz 

	orig.mgz ========================================
	Volume information for /out/sourcedata/freesurfer/sub-02/mri/orig.mgz
	          type: MGH
	    dimensions: 323 x 323 x 323
	   voxel sizes: 0.800000, 0.800000, 0.800000
	          type: UCHAR (0)
	           fov: 258.400
	           dof: 1
	        xstart: -129.2, xend: 129.2
	        ystart: -129.2, yend: 129.2
	        zstart: -129.2, zend: 129.2
	            TR: 0.00 msec, TE: 0.00 msec, TI: 0.00 msec, flip angle: 0.00 degrees
	       nframes: 1
	       PhEncDir: UNKNOWN
	       FieldStrength: 0.000000
	ras xform present
	    xform info: x_r =  -1.0000, y_r =   0.0000, z_r =   0.0000, c_r =     0.2651
	              : x_a =   0.0000, y_a =   0.0000, z_a =   1.0000, c_a =    23.5953
	              : x_s =   0.0000, y_s =  -1.0000, z_s =   0.0000, c_s =     3.7655

	talairach xfm : /out/sourcedata/freesurfer/sub-02/mri/transforms/talairach.xfm
	Orientation   : LIA
	Primary Slice Direction: coronal

	voxel to ras transform:
	               -0.8000   0.0000   0.0000   129.4651
	                0.0000   0.0000   0.8000  -105.6047
	                0.0000  -0.8000   0.0000   132.9655
	                0.0000   0.0000   0.0000     1.0000

	voxel-to-ras determinant -0.512

	ras to voxel transform:
	               -1.2500  -0.0000  -0.0000   161.8314
	               -0.0000  -0.0000  -1.2500   166.2069
	               -0.0000   1.2500  -0.0000   132.0059
	               -0.0000  -0.0000  -0.0000     1.0000

	****************************************
	ERROR! FOV=258.400 > 256
	Include the flag -cw256 with recon-all!
	Inspect orig.mgz to ensure the head is fully visible.
	****************************************

	Linux 5d965cd3d4b8 5.15.0-134-generic #145~20.04.1-Ubuntu SMP Mon Feb 17 13:27:16 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

	recon-all -s sub-02 exited with ERRORS at Mon Mar 31 12:59:48 UTC 2025

	For more details, see the log file /out/sourcedata/freesurfer/sub-02/scripts/recon-all.log
	To report a problem, see http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting

Sorry it’s a bit long, but I included all FOV occurrence. I can provide any additional from the log if it’s of any help.

Screenshots / relevant information:


Here is my bids/sub-02/anat/sub-02_T1w.nii.gz (defaced) that looks perfectly fine.

Thank you!


Hi @MatthieuGG,

You may want to consider running recon-all separately for that subject with the -cw256 flag, and then importing that into fmriprep.

Best,
Steven

Thank you @Steven for your answer.

It looks like the -cw256 flag is by default applied by fMRIprep. In my case, it is correctly applied:

Cmdline:
	recon-all -autorecon1 -i /tmp/work/fmriprep_25_0_wf/sub_02_wf/anat_fit_wf/anat_template_wf/denoise/mapflow/_denoise0/sub-02_T1w_noise_corrected.nii.gz -noskullstrip -noT2pial -noFLAIRpial -cw256 -hires -openmp 8 -subjid sub-02 -sd /out/sourcedata/freesurfer -expert /tmp/work/fmriprep_25_0_wf/sub_02_wf/anat_fit_wf/surface_recon_wf/autorecon1/expert.opts
Stdout:
	INFO: hi-res volumes are conformed to the min voxel size
	fs-check-version --s sub-02 --o /tmp/tmp.VEilH3
	Mon Mar 31 12:59:24 UTC 2025

	setenv SUBJECTS_DIR /out/sourcedata/freesurfer
	cd /tmp/work/fmriprep_25_0_wf/sub_02_wf/anat_fit_wf/surface_recon_wf/autorecon1
	/opt/freesurfer/bin/fs-check-version --s sub-02 --o /tmp/tmp.VEilH3
	-rwxrwxr-x 1 root root 18565 Aug  4  2022 /opt/freesurfer/bin/fs-check-version

	freesurfer-linux-ubuntu22_x86_64-7.3.2-20220804-6354275
	$Id$
	Linux 5d965cd3d4b8 5.15.0-134-generic #145~20.04.1-Ubuntu SMP Mon Feb 17 13:27:16 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
	pid 1027
	Current FS Version freesurfer-linux-ubuntu22_x86_64-7.3.2-20220804-6354275
	Subject does not have a bstampfile, copying /opt/freesurfer/build-stamp.txt
	Subject FS Version: freesurfer-linux-ubuntu22_x86_64-7.3.2-20220804-6354275
	No constraints on version because REQ=UnSet and FsVerFile=NotThere
	#@#% fs-check-version match = 1
	fs-check-version Done
	INFO: SUBJECTS_DIR is /out/sourcedata/freesurfer
	Actual FREESURFER_HOME /opt/freesurfer
	Linux 5d965cd3d4b8 5.15.0-134-generic #145~20.04.1-Ubuntu SMP Mon Feb 17 13:27:16 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
	-cw256 option is now persistent (remove with -clean-cw256)
	/out/sourcedata/freesurfer/sub-02

According to this answer, there may be a conflict between -cw256 and -hires.
It is then advised in this answer to crop the images with tools such as fslroi, so they are conform to 256x256x256 1mm isotropic.

In my case, MRIcroGL says my T1w.nii.gz (bids\sub-XX\anat\sub-XX_T1w.nii.gz) and my orig.mgz (fmriprep\sourcedata\freesurfer\sub-XX\mri\orig.mgz) are

  • sub-02 : T1w (104 x 121 x 155) = 2734 // orig (160 x 132 x 156) = 179
  • sub-03 : T1w (104 x 132 x 171) = 2934 // orig (159 x 142 x 170) = 240
  • sub-04 : T1w (104 x 125 x 170) = 2678 // orig (159 x 135 x 169) = 192

which makes me doubt about the ERROR! FOV=258.400 > 256 issue, because I see no particular size issue in sub-02. Maybe I am not refering to the correct values in MRIcroGL.

All in, how to correct the specific FOV issue for that subject?
Also, how can I optimise the FOV prescription in my protocol, so this doesn’t occur again in the future?

Thank you.