fMRIPREP failing on HPC via singularity

Hello all,
I am trying to get fMRIPREP v 23.1.2 to run on my university’s HPC via singularity (v. 3.10.3). I got it to run ok (though long and resource intensive) on my local machine via docker. I believe it is failing due to a freesurfer or templateflow issue but I can’t tell.

Here is my setup

export SINGULARITYENV_TEMPLATEFLOW_HOME=/templates
export TEMPLATEFLOW_HOME=/home/gshearre/.templateflow
export FS_LICENSE=/project/brainmri/software/freesurfer/license.txt

Here is my command:

singularity run --cleanenv -B /project/brainmri/data/bbc/BIDS:/data -B /home/gshearre/.templateflow:/templates -B /gscratch/gshearre:/work -B /project/brainmri/software/freesurfer/license.txt:/license.txt:ro /project/brainmri/software/fmriprep-latest.simg /data /data/derivatives/fMRIPrep-23.1.2 participant --participant-label 20001 -w /work/ -vv --omp-nthreads 8 --nthreads 12 --mem_mb 30000 --fs-license-file /license.txt

Here is my initial error

Error setting node input:
Node: gen_ref
input: fixed_image
results_file: /work/fmriprep_23_1_wf/single_subject_20001_wf/func_preproc_ses_2_task_resting_wf/bold_std_trans_wf/_std_target_MNI152NLin2009cAsym.resnative/select_tpl/result_select_tpl.pklz
value: /templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_T1w.nii.gz

exception calling callback for <Future at 0x150c4863d000 state=finished raised BrokenProcessPool>

Further error in the crash log

Node: fmriprep_23_1_wf.single_subject_20001_wf.func_preproc_ses_3_task_clamp_wf.bold_std_trans_wf.gen_ref
Working directory: /work/fmriprep_23_1_wf/single_subject_20001_wf/func_preproc_ses_3_task_clamp_wf/bold_std_trans_wf/_std_target_MNI152NLin2009cAsym.resnative/gen_ref

Node inputs:

fixed_image = <undefined>
fov_mask = None
keep_native = True
moving_image = <undefined>
xform_code = None

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 454, in run
    cached, updated = self.is_cached()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 342, in is_cached
    hashed_inputs, hashvalue = self._get_hashval()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 548, in _get_hashval
    self._get_inputs()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 619, in _get_inputs
    self.set_input(key, deepcopy(output_value))
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 312, in set_input
    setattr(self.inputs, parameter, deepcopy(val))
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/traits_extension.py", line 330, in validate
    value = super(File, self).validate(objekt, name, value, return_pathlike=True)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/traits_extension.py", line 135, in validate
    self.error(objekt, name, str(value))
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/traits/base_trait_handler.py", line 74, in error
    raise TraitError(
traits.trait_errors.TraitError: The 'fixed_image' trait of a _GenerateSamplingReferenceInputSpec instance must be a pathlike object or string representing an existing file, but a value of '/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_T1w.nii.gz' <class 'str'> was specified.

Error setting node input:
Node: gen_ref
input: fixed_image
results_file: /work/fmriprep_23_1_wf/single_subject_20001_wf/func_preproc_ses_3_task_clamp_wf/bold_std_trans_wf/_std_target_MNI152NLin2009cAsym.resnative/select_tpl/result_select_tpl.pklz
value: /templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_T1w.nii.gz

Here is what I have tried

Going into the container using shell and checking the paths

They seem to bind correctly

singularity shell --cleanenv -B /project/brainmri/data/bbc/BIDS:/data -B /home/gshearre/.templateflow:/templates:ro -B /gscratch/gshearre:/work -B /project/brainmri/software/freesurfer/license.txt:/license.txt:ro /project/brainmri/software/fmriprep-latest.simg /data /data/derivatives/fMRIPrep-23.1.2 participant --participant-label 20001 -w /work/ -vv --omp-nthreads 8 --nthreads 12 --mem_mb 30000 --verbose  --fs-license-file /license.txt

Following this github issue

I tried checking:

cat /proc/sys/crypto/fips_enabled

it returned 0

TLDR

Can’t get fMRIPREP container to run via singularity, suspect binding or something with freesurfer or template flow but not sure since it looks ok in the container.

Potential next steps?

  • Blood sacrifice to the MRI gods?
  • Crying?

Thanks,
Grace

Hi @Grace_Shearrer,

A blood sacrifice to the MRI gods usually works, but should only be a last resort. Let’s see if we can figure it out before that - no one likes filling out the paperwork required for a sacrifice.

So fmriprep is looking for something in /templateflow folder, which doesn’t seem to exist in the container. I don’t know why it is looking there because it looks like you re-assigned it correctly with

Instead, lets try to work around it by simply rename your templateflow directory as /templateflow when you bind.

singularity run --containall -e -B /project/brainmri/data/bbc/BIDS:/data \
-B /home/gshearre/.templateflow:/templateflow:ro -B /gscratch/gshearre:/work \ 
-B /project/brainmri/software/freesurfer/license.txt:/license.txt:ro \
/project/brainmri/software/fmriprep-latest.simg \
/data /data/derivatives/fMRIPrep-23.1.2 participant --participant-label 20001 \
-w /work/ --omp-nthreads 8 --nthreads 12 --mem_mb 30000 --verbose  --fs-license-file /license.txt \

Try giving it a shot?

Best,
Steven

Hi Steven, thanks for the quick reply. I get a new error :smiley:

What I ran

singularity run --containall -e -B /project/brainmri/data/bbc/BIDS:/data -B /home/gshearre/.templateflow:/templateflow -B /gscratch/gshearre:/work -B /project/brainmri/software/freesurfer/license.txt:/license.txt:ro /project/brainmri/software/fmriprep-latest.simg /data /data/derivatives/fMRIPrep-23.1.2 participant --participant-label 20001 -w /work/ --omp-nthreads 8 --nthreads 12 --mem_mb 30000 --verbose  --fs-license-file /license.txt 

What I got

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/lib/python3.10/pathlib.py", line 1175, in mkdir
    self._accessor.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/gshearre/.cache/templateflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/lib/python3.10/pathlib.py", line 1175, in mkdir
    self._accessor.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/gshearre/.cache'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/bin/fmriprep", line 5, in <module>
    from fmriprep.cli.run import main
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/run.py", line 25, in <module>
    from .. import config
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/config.py", line 114, in <module>
    from templateflow import __version__ as _tf_ver
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/templateflow/__init__.py", line 19, in <module>
    from . import api
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/templateflow/api.py", line 8, in <module>
    from .conf import TF_LAYOUT, TF_S3_ROOT, TF_USE_DATALAD, requires_layout
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/templateflow/conf/__init__.py", line 50, in <module>
    _init_cache()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/templateflow/conf/__init__.py", line 47, in _init_cache
    _update_s3(TF_HOME, local=True, overwrite=True)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/templateflow/conf/_s3.py", line 20, in update
    retval = _update_skeleton(skel_file, dest, overwrite=overwrite, silent=silent)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/templateflow/conf/_s3.py", line 52, in _update_skeleton
    dest.mkdir(exist_ok=True, parents=True)
  File "/opt/conda/envs/fmriprep/lib/python3.10/pathlib.py", line 1179, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/opt/conda/envs/fmriprep/lib/python3.10/pathlib.py", line 1179, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/opt/conda/envs/fmriprep/lib/python3.10/pathlib.py", line 1175, in mkdir
    self._accessor.mkdir(self, mode)
OSError: [Errno 30] Read-only file system: '/home/gshearre'

However, I have a /home/gshearre/.cache/templateflow and I have read-write permission to /home/gshearre

I am grabbing my blood letting tools…

Double update

So I did get this to run when I got more memory on my compute node using the follow command

singularity run --containall -e -B /project/brainmri/data/bbc/BIDS:/data \
-B /home/gshearre/.templateflow:/templateflow:ro -B /gscratch/gshearre:/work \ 
-B /project/brainmri/software/freesurfer/license.txt:/license.txt:ro \
/project/brainmri/software/fmriprep-latest.simg \
/data /data/derivatives/fMRIPrep-23.1.2 participant --participant-label 20001 \
-w /work/ --omp-nthreads 8 --nthreads 12 --mem_mb 30000 --verbose  --fs-license-file /license.txt \

New Error (freesurfer)

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 autorecon3.

Cmdline:
	recon-all -autorecon3 -openmp 8 -subjid sub-20001 -sd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer -nosphere -nosurfreg -nojacobian_white -noavgcurv -nocortparc -nopial -noparcstats -nocortparc2 -noparcstats2 -nocortparc3 -noparcstats3 -nopctsurfcon -nocortribbon -nohyporelabel -noaparc2aseg -noapas2aseg -nosegstats -nowmparc
Stdout:
	fs-check-version --s sub-20001 --o /tmp/tmp.5rKO5F
	Wed Jul 19 12:05:05 MDT 2023

	setenv SUBJECTS_DIR /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer
	cd /work/fmriprep_23_1_wf/single_subject_20001_wf/anat_preproc_wf/surface_recon_wf/autorecon_resume_wf/autorecon3
	/opt/freesurfer/bin/fs-check-version --s sub-20001 --o /tmp/tmp.5rKO5F
	-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 m004 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Thu May 18 10:27:05 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux
	pid 3401329
	Current FS Version freesurfer-linux-ubuntu22_x86_64-7.3.2-20220804-6354275
	bstampfile exists /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/scripts/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 /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer
	Actual FREESURFER_HOME /opt/freesurfer
	-rw-rw-r-- 1 gshearre brainmri 375706 Jul  9 16:16 /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/scripts/recon-all.log
	Linux m004 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Thu May 18 10:27:05 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux
	/data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri/transforms /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001 
	/data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001 
	#--------------------------------------------
	#@# WhiteSurfs lh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --adgws-in ../surf/autodet.gw.stats.lh.dat --seg aseg.presurf.mgz --threads 8 --wm wm.mgz --invol brain.finalsurfs.mgz --lh --i ../surf/lh.white.preaparc --o ../surf/lh.white --white --nsmooth 0 --rip-label ../label/lh.cortex.label --rip-bg --rip-surf ../surf/lh.white.preaparc --aparc ../label/lh.aparc.annot
	   Update not needed
	#--------------------------------------------
	#@# WhiteSurfs rh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --adgws-in ../surf/autodet.gw.stats.rh.dat --seg aseg.presurf.mgz --threads 8 --wm wm.mgz --invol brain.finalsurfs.mgz --rh --i ../surf/rh.white.preaparc --o ../surf/rh.white --white --nsmooth 0 --rip-label ../label/rh.cortex.label --rip-bg --rip-surf ../surf/rh.white.preaparc --aparc ../label/rh.aparc.annot
	   Update not needed
	#@# white curv lh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --curv-map ../surf/lh.white 2 10 ../surf/lh.curv
	   Update not needed
	#@# white area lh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --area-map ../surf/lh.white ../surf/lh.area
	   Update not needed
	#@# pial curv lh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --curv-map ../surf/lh.pial 2 10 ../surf/lh.curv.pial
	   Update not needed
	#@# pial area lh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --area-map ../surf/lh.pial ../surf/lh.area.pial
	   Update not needed
	#@# thickness lh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --thickness ../surf/lh.white ../surf/lh.pial 20 5 ../surf/lh.thickness
	   Update not needed
	#@# area and vertex vol lh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --thickness ../surf/lh.white ../surf/lh.pial 20 5 ../surf/lh.thickness
	   Update not needed
	#@# white curv rh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --curv-map ../surf/rh.white 2 10 ../surf/rh.curv
	   Update not needed
	#@# white area rh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --area-map ../surf/rh.white ../surf/rh.area
	   Update not needed
	#@# pial curv rh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --curv-map ../surf/rh.pial 2 10 ../surf/rh.curv.pial
	   Update not needed
	#@# pial area rh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --area-map ../surf/rh.pial ../surf/rh.area.pial
	   Update not needed
	#@# thickness rh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --thickness ../surf/rh.white ../surf/rh.pial 20 5 ../surf/rh.thickness
	   Update not needed
	#@# area and vertex vol rh Wed Jul 19 12:05:07 MDT 2023
	cd /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/mri
	mris_place_surface --thickness ../surf/rh.white ../surf/rh.pial 20 5 ../surf/rh.thickness
	   Update not needed

	#-----------------------------------------
	#@# Curvature Stats lh Wed Jul 19 12:05:07 MDT 2023
	/data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/surf

	 mris_curvature_stats -m --writeCurvatureFiles -G -o ../stats/lh.curv.stats -F smoothwm sub-20001 lh curv sulc 

	             Toggling save flag on curvature files                       [ ok ]
	                 Outputting results using filestem   [ ../stats/lh.curv.stats ]
	             Toggling save flag on curvature files                       [ ok ]
	                                   Setting surface    [ sub-20001/lh.smoothwm ]
	                                Reading surface...                       [ ok ]
	                                   Setting texture                     [ curv ]
	                                Reading texture...                       [ ok ]
	                                   Setting texture                     [ sulc ]
	                                Reading texture...Gb_filter = 0
	                       [ ok ]
	      Calculating Discrete Principal Curvatures...
	      Determining geometric order for vno faces... [####################] [ ok ]
	                      Determining KH curvatures... [####################] [ ok ]
	                    Determining k1k2 curvatures... [####################] [ ok ]
	                                   deltaViolations                      [ 338 ]
	Gb_filter = 0

	#-----------------------------------------
	#@# Curvature Stats rh Wed Jul 19 12:05:14 MDT 2023
	/data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/surf

	 mris_curvature_stats -m --writeCurvatureFiles -G -o ../stats/rh.curv.stats -F smoothwm sub-20001 rh curv sulc 

	             Toggling save flag on curvature files                       [ ok ]
	                 Outputting results using filestem   [ ../stats/rh.curv.stats ]
	             Toggling save flag on curvature files                       [ ok ]
	                                   Setting surface    [ sub-20001/rh.smoothwm ]
	                                Reading surface...                       [ ok ]
	                                   Setting texture                     [ curv ]
	                                Reading texture...                       [ ok ]
	                                   Setting texture                     [ sulc ]
	                                Reading texture...Gb_filter = 0
	                       [ ok ]
	      Calculating Discrete Principal Curvatures...
	      Determining geometric order for vno faces... [####################] [ ok ]
	                      Determining KH curvatures... [####################] [ ok ]
	                    Determining k1k2 curvatures... [####################] [ ok ]
	                                   deltaViolations                      [ 299 ]
	Gb_filter = 0

	WARN:    S lookup   min:                          -0.034257
	WARN:    S explicit min:                          0.000000	vertex = 162
	/data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/sub-20001/label
	#--------------------------------------------
	#@# BA_exvivo Labels lh Wed Jul 19 12:05:21 MDT 2023
	-------------------------------------------------------------------------
	ERROR: Label BA1_exvivo does not exist in SUBJECTS_DIR fsaverage!
	       The fsaverage link probably points to an older freesurfer version
	-------------------------------------------------------------------------
	Linux m004 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Thu May 18 10:27:05 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux

	recon-all -s sub-20001 exited with ERRORS at Wed Jul 19 12:05:21 MDT 2023

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

Stderr:

Traceback:
	RuntimeError: subprocess exited with code 1.

Hi @Grace_Shearrer,

Can you make sure to rename or delete any FreeSurfer data? I think fMRIPrep will be looking by default in /data/derivatives/fMRIPrep-23.1.2/sourcedata/. And just in case, when running also try a fresh working directory.

Best,
Steven

Hi Steven,
to clarify. Delete the /data/derivatives/fMRIPrep-23.1.2/sourcedata/ ?
Thanks,
Grace

Yes, or if there’s a folder /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer/ rename it to /data/derivatives/fMRIPrep-23.1.2/sourcedata/freesurfer_OLD/ and it will be ignored by fMRIPrep.

Update

It worked :slight_smile: I guess it was the freesurfer file.
Thanks so much!
More questions in the future,
Grace

1 Like

I got the same error as you @Grace_Shearrer . Could you tell me how to resolve it ? And hot to update my code? @Steven @Grace_Shearrer

Here is my error:

/output/sourcedata/freesurfer/sub-023023/label
#--------------------------------------------
#@# BA_exvivo Labels lh Thu Mar 21 08:20:45 EDT 2024
-------------------------------------------------------------------------
ERROR: Label BA1_exvivo does not exist in SUBJECTS_DIR fsaverage!
The fsaverage link probably points to an older freesurfer version
-------------------------------------------------------------------------

Here is my code:

TEMPLATEFLOW_HOST_HOME=$HOME/.cache/templateflow
FMRIPREP_HOST_CACHE=$HOME/.cache/fmriprep

export SINGULARITYENV_TEMPLATEFLOW_HOME="/templateflow"
export SINGULARITYENV_FS_LICENSE="/share/apps/imaging/freesurfer-7.3.2/license.txt"

singularity run \
        --cleanenv \
        -B $PROJECT:/rootdir \
        -B $BIDS_DIR:/data \
        -B $DERIVS_DIR:/output \
        -B $WORK_DIR:/work \
        -B ${TEMPLATEFLOW_HOST_HOME}:${SINGULARITYENV_TEMPLATEFLOW_HOME} \
        -B ${SINGULARITYENV_FS_LICENSE}:/freesurfer_license \
    ${FMRIPREP} /data /output \
    participant --participant_label $subject \
    -w /work \
    -vv \
    --fs-license-file /freesurfer_license \
    --mem-mb 32000 \
    --n-cpus 8 \
    --write-graph \
    --output-spaces MNI152NLin2009cAsym:res-2 \
    --return-all-components

exitcode=$?

Hi @Yunhong_Wang and welcome to neurostars!

The fix to the error was to delete/rename any preexisting freesurfer files to make sure fmriprep was computing them from scratch. Trying a fresh working directory may also help.

Best,
Steven

Hi @Steven thank you for your help!

This is my first time to run fmriprep and no preexisting freesurfer files before running. And the working dir is the new dir for running this work.

I have another problem is that whether should I bind new dirs in singularity. For example, in the first time, -B $WORK_DIR:/work_1; in the second time, -B $WORK_DIR:/work_2.

Cheers,
Yunhong

Hi @Yunhong_Wang

What version fmriprep are you using?

No, that is not what I meant. If you wanted to change working directories you would do something like -B ${NEW_WORK_DIR}/work.

Best,
Steven

Hi @Steven

The version of fmriprep is 23.2.1, which is pulled from docker://nipreps/fmriprep:23.2.1.

I misunderstood what you meant for working dir. But the working dir in host is new for running this work.

Cheers,
Yunhong

Hi @Yunhong_Wang,

Can you return the outputs of tree run on the fsaverage folder?

Best,
Steven

Hi @Steven
8660dc9764e75b891758a92214d45e0

What’s in the fsaverage label folder?

Interesting that it appears the BA1_exvivo label is only for the right hemisphere and not the left… can you ensure that you have read/write permissions in your derivatives folder and try adding --fs-subjects-dir /output/freesurfer into your fmriprep command?

Yeah, it’s weird. In my work this time, only a few subjects completed the process, and many others had this error.

I update my code according your advice, please see it:

singularity run \
        --cleanenv \
        -B $PROJECT:/rootdir \
        -B $BIDS_DIR:/data \
        -B $DERIVS_DIR:/output \
        -B $WORK_DIR:/work \
        -B ${TEMPLATEFLOW_HOST_HOME}:${SINGULARITYENV_TEMPLATEFLOW_HOME}:ro \
        -B ${SINGULARITYENV_FS_LICENSE}:/freesurfer_license:ro \
    ${FMRIPREP} /data /output \
    participant --participant_label $subject \
    -w /work \
    -vv \
    --fs-license-file /freesurfer_license \
    --fs-subjects-dir /output/freesurfer \
    --mem-mb 32000 \
    --n-cpus 8 \
    --write-graph \
    --output-spaces MNI152NLin2009cAsym:res-2 \
    --return-all-components

That doesn’t make sense to me that some subjects would complete and others will error out if the error is still about the missing label file. Can you confirm that the error is still about the missing label file and return the output of tree run on the new fsaverage folder?