fMRIPrep fails during autorecon1 in multiple subjects

Summary of what happened:

Dear NeuroStars community,

I am using fMRIPrep (version 24.1.0) to preprocess a dataset that includes both adult and pediatric participants. After running all subjects at least once, approximately 30% of them fail — predominantly pediatric, though some adult subjects are also affected. The children range in aged from 6 to 17 years and failures occur across various age groups, although some participants in almost every group process successfully.

The failures appear to occur during the autorecon1 step of FreeSurfer, specifically due to Talairach alignment issues in almost all cases. Based on visual inspection, the overall data quality does not appear to be the primary cause.

When I run some of these problematic participants through FreeSurfer independently, outside of fMRIPrep, they complete successfully.

Is there a recommended way to handle such Talairach alignment failures within fMRIPrep or is there any other workaround?

Thank you very much in advance!

Best
Dustin

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

for sub in sub-134; do
    fmriprep /home/jovyan/data/data/Niftis_for_processing /home/jovyan/data/data/Preprocessing_output_latest participant \
        --skip-bids-validation \
        --participant-label $sub \
        --fs-license-file /home/jovyan/license.txt \
        --output-spaces MNI152NLin2009cAsym T1w fsaverage \
        --cifti-output 91k \
        --nprocs 7 \
        --mem 52000 \
        --work-dir /home/jovyan/data/work
done

Version:

24.1.0

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

Docker

Relevant log outputs (up to 20 lines):

Node: fmriprep_24_1_wf.sub_134_wf.anat_fit_wf.surface_recon_wf.autorecon1
Working directory: /work/fmriprep_24_1_wf/sub_134_wf/anat_fit_wf/surface_recon_wf/autorecon1
Command:
recon-all -autorecon1 -i sub-134_ses-01_T1w_noise_corrected.nii.gz -noskullstrip -noT2pial -noFLAIRpial -openmp 8 -subjid sub-134 -sd /out/sourcedata/freesurfer

# Talairach alignment: Attempt 1
ERROR: talairach_afd: Talairach Transform: transforms/talairach.xfm ***FAILED*** (p=0.0731, pval=0.0034 < threshold=0.0050)

# Talairach alignment: Attempt 2 using 3T atlas
ERROR: talairach_afd: Talairach Transform: transforms/talairach.xfm ***FAILED*** (p=0.0000, pval=0.0000 < threshold=0.0050)

# Talairach alignment: Attempt 3 using MINC (mritotal)
spawn: exec of minc_modify_header failed: No such file or directory
mritotal: crashed while running autocrop (termination status=65280)
ERROR: mritotal failed, see transforms/talairach.log

nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node autorecon1.
RuntimeError: subprocess exited with code 1.

Hi @Dustin and welcome to neurostars!

Usually those errors are related to lower quality T1ws. Is it possible you’re using a different FS version compared to what is in the fmriprep container? In either case you can do all your FS processing separately and then import them to fmriprep with the —fs-subjects-dir argument.

Best,
Steven

Hi Steven,

Thank you very much for the quick reply and the welcome!

Yes, I’m using FreeSurfer version 8.0.0.

If I were to run FreeSurfer separately, would I need to reprocess all participants from scratch to maintain consistency? Or, in your opinion, would it be acceptable to keep the outputs that were successfully generated with fMRIPrep and only use the external FreeSurfer workflow for the subjects that failed (or be able to reuse some parts of the already preprocessed data)?

I also have a related question: my participants have between 1 and 6 scanning sessions. I read that if there are two sessions, fMRIPrep uses both T1w images to build a robust template, but if there are more, only one is selected. Is that correct? If so, is there a good way to replicate this behavior in FreeSurfer, and then feed that output back into fMRIPrep?

I’ve tried running recon-all -all on both sessions independently and then using recon-all -base to create a subject template. Would this base template be compatible as input to fMRIPrep?

Thanks again for your help!

Best,
Dustin

Hi @Dustin,

That would be recommended.

Not quite. From https://neurostars.org/t/what-does-fmriprep-do-with-t1w-with-longitudinal/21184:

See steps fro creating unbiased template in LongitudinalProcessing - Free Surfer Wiki.

Specify the --fs-subjects-dir, and if using the longitudinal freesurfer workflow, also specify --fs-no-resume.

I think that would work, haven’t tried anything like that myself though.

Best,
Steven

Thank you very much for your help! I really appreciate it.