Summary of what happened:
Trying to run fmriprep on a dataset on my institution’s HPC cluster. It seems to crash at the brain extraction stage where it doesn’t write a T1w_template_maths_corrected.nii.gz and the remaining processes thus can’t run.
Command used (and if a helper script was used, a link to the helper script or the command generated):
Slurm file
#!/bin/bash
# Run from BIDS code/preprocessing directory: sbatch slurm_fmriprep.sh
# Name of job?
#SBATCH --job-name=fmriprep
# Set partition
#SBATCH --partition=amd
# How long is job?
#SBATCH -t 14:00:00
# Where to output log files? The log file will be in the format of the job ID_array number
# make sure this logs directory exists!! otherwise the script won't run
#SBATCH --output='../../data/bids/derivatives/fmriprep/logs/fmriprep-%A_%a.log'
# How much memory to allocate (in MB)?
#SBATCH --cpus-per-task=8 --mem-per-cpu=20000
# Update with your email
#SBATCH --mail-user=YOURID@pomona.edu
#SBATCH --mail-type=BEGIN,END,FAIL
# Remove modules because Singularity shouldn't need them
echo "Purging modules"
module purge
# Print job submission info
echo "Slurm job ID: " $SLURM_JOB_ID
date
# Set subject ID based on array index
subjs=($@) # You can input a list of subjects by running
# submit_job_array.sh sub-01 sub-02 ....... or just let
# this script collect all subjects in the BIDS directory
bids=/bigdata/lab/sburnslab/MRI_data/NIMH-volunteer/data/bids
if [[ $# -eq 0 ]]; then
# first go to data directory, grab all subjects,
# and assign to an array
pushd $bids
subjs=($(ls sub-* -d))
popd
fi
# take the length of the array
# this will be useful for indexing later
len=$(expr ${#subjs[@]} - 1) # len - 1
echo Spawning ${#subjs[@]} sub-jobs.
sbatch --array=0-$len ./run_fmriprep.sh ${subjs[@]}
Calling fmriprep
#!/bin/bash
subjs=($@)
subject=${subjs[${SLURM_ARRAY_TASK_ID}]}
#change the capitalized parts of these filepaths to match your project
project_dir=/bigdata/lab/sburnslab/MRI_data/NIMH-volunteer
scratch_dir=/scratch/$SLURM_JOB_USER/$SLURM_JOB_ID
data_dir=$project_dir/data
bids_dir=$data_dir/bids
derivatives_dir=$bids_dir/derivatives
scripts_dir=$project_dir/code/preprocessing
module load fmriprep
#change your fmriprep options below
singularity run --cleanenv --bind $project_dir --bind $scratch_dir \
/opt/linux/rocky/8/software/fmriprep/23.0.0/bin/fmriprep \
$bids_dir $derivatives_dir participant \
--participant-label $subject \
--fs-no-reconall \
--fs-license-file $project_dir/code/preprocessing/license.txt \
--anat-only \
--verbose \
--no-submm-recon \
--nthreads 8 --omp-nthreads 8 \
--output-spaces T1w fsaverage:den-41k \
MNI152NLin2009cAsym:res-native \
--write-graph --work-dir $scratch_dir \
--ignore fieldmaps \
--use-syn-sdc warn \
--output-layout legacy \
Version:
23.0.0
Environment (Docker, Singularity / Apptainer, custom installation):
Singularity on an institutional HPC cluster
Data formatted according to a validatable standard? Please provide the output of the validator:
Online bids validator reported no errors.
Relevant log outputs (up to 20 lines):
log
250208-09:24:16,993 nipype.workflow INFO:
[Node] Setting-up "_inu_n40" in "/scratch/smb02011/16727/fmriprep_23_0_wf/single_subject_ON99620_wf/anat_preproc_wf/brain_extraction_wf/inu_n4/mapflow/_inu_n40".
250208-09:24:16,995 nipype.workflow INFO:
[Node] Executing "_inu_n40" <nipype.interfaces.ants.segmentation.N4BiasFieldCorrection>
250208-09:24:18,933 nipype.workflow INFO:
[MultiProc] Running 1 tasks, and 2 jobs ready. Free memory (GB): 452.66/452.86, Free processors: 0/8.
Currently running:
* fmriprep_23_0_wf.single_subject_ON99620_wf.anat_preproc_wf.brain_extraction_wf.inu_n4
250208-09:25:38,448 nipype.workflow INFO:
[Node] Finished "_inu_n40", elapsed time 81.333546s.
250208-09:25:38,450 nipype.workflow WARNING:
Storing result file without outputs
250208-09:25:38,452 nipype.workflow WARNING:
[Node] Error on "_inu_n40" (/scratch/smb02011/16727/fmriprep_23_0_wf/single_subject_ON99620_wf/anat_preproc_wf/brain_extraction_wf/inu_n4/mapflow/_inu_n40)
250208-09:25:38,455 nipype.workflow WARNING:
Storing result file without outputs
250208-09:25:38,456 nipype.workflow WARNING:
[Node] Error on "fmriprep_23_0_wf.single_subject_ON99620_wf.anat_preproc_wf.brain_extraction_wf.inu_n4" (/scratch/smb02011/16727/fmriprep_23_0_wf/single_subject_ON99620_wf/anat_preproc_wf/brain_extraction_wf/inu_n4)
250208-09:25:40,315 nipype.workflow ERROR:
Node inu_n4 failed to run on host a001.hpc.pomona.edu.
250208-09:25:40,323 nipype.workflow ERROR:
Saving crash info to /bigdata/lab/sburnslab/MRI_data/NIMH-volunteer/data/bids/derivatives/fmriprep/sub-ON99620/log/20250208-092004_7fc4b1f2-9c87-4b85-bbc6-ad86d24dc924/crash-20250208-092540-smb02011-inu_n4-f4edbc88-606e-47bc-bc27-cee3846fc193.txt
crash report
Node: fmriprep_23_0_wf.single_subject_ON99620_wf.anat_preproc_wf.brain_extraction_wf.inu_n4
Working directory: /scratch/smb02011/16727/fmriprep_23_0_wf/single_subject_ON99620_wf/anat_preproc_wf/brain_extraction_wf/inu_n4
Node inputs:
args = <undefined>
bias_image = <undefined>
bspline_fitting_distance = 200.0
bspline_order = <undefined>
convergence_threshold = 1e-07
copy_header = True
dimension = 3
environ = {'NSLOTS': '8'}
histogram_sharpening = <undefined>
input_image = ['/scratch/smb02011/16727/fmriprep_23_0_wf/single_subject_ON99620_wf/anat_preproc_wf/brain_extraction_wf/truncate_images/mapflow/_truncate_images0/sub-ON99620_ses-01_acq-MPRAGE_T1w_template_maths.nii.gz']
mask_image = <undefined>
n_iterations = [50, 50, 50, 50]
num_threads = 8
output_image = <undefined>
rescale_intensities = False
save_bias = False
shrink_factor = 4
weight_image = <undefined>
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 1380, in _run_interface
result = self._collate_results(
File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/nodes.py", line 1293, in _collate_results
raise NodeExecutionError(
nipype.pipeline.engine.nodes.NodeExecutionError: Subnodes of node: inu_n4 failed:
Subnode 0 failed
Error: Traceback (most recent call last):
File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 454, in aggregate_outputs
setattr(outputs, key, val)
File "/opt/conda/lib/python3.9/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/lib/python3.9/site-packages/nipype/interfaces/base/traits_extension.py", line 135, in validate
self.error(objekt, name, str(value))
File "/opt/conda/lib/python3.9/site-packages/traits/base_trait_handler.py", line 74, in error
raise TraitError(
traits.trait_errors.TraitError: The 'output_image' trait of a N4BiasFieldCorrectionOutputSpec instance must be a pathlike object or string representing an existing file, but a value of '/scratch/smb02011/16727/fmriprep_23_0_wf/single_subject_ON99620_wf/anat_preproc_wf/brain_extraction_wf/inu_n4/mapflow/_inu_n40/sub-ON99620_ses-01_acq-MPRAGE_T1w_template_maths_corrected.nii.gz' <class 'str'> was specified.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 399, in run
runtime = self._post_run_hook(runtime)
File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/mixins/fixheader.py", line 127, in _post_run_hook
outputs = self.aggregate_outputs(runtime=runtime).get_traitsfree()
File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 461, in aggregate_outputs
raise FileNotFoundError(msg)
FileNotFoundError: No such file or directory '/scratch/smb02011/16727/fmriprep_23_0_wf/single_subject_ON99620_wf/anat_preproc_wf/brain_extraction_wf/inu_n4/mapflow/_inu_n40/sub-ON99620_ses-01_acq-MPRAGE_T1w_template_maths_corrected.nii.gz' for output 'output_image' of a N4BiasFieldCorrection interface
Traceback (most recent call last):
File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/utils.py", line 94, in nodelist_runner
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 _inu_n40.
Cmdline:
N4BiasFieldCorrection --bspline-fitting [ 200 ] -d 3 --input-image /scratch/smb02011/16727/fmriprep_23_0_wf/single_subject_ON99620_wf/anat_preproc_wf/brain_extraction_wf/truncate_images/mapflow/_truncate_images0/sub-ON99620_ses-01_acq-MPRAGE_T1w_template_maths.nii.gz --convergence [ 50x50x50x50, 1e-07 ] --output sub-ON99620_ses-01_acq-MPRAGE_T1w_template_maths_corrected.nii.gz --shrink-factor 4
Stdout:
Stderr:
Killed
Traceback:
Traceback (most recent call last):
File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 454, in aggregate_outputs
setattr(outputs, key, val)
File "/opt/conda/lib/python3.9/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/lib/python3.9/site-packages/nipype/interfaces/base/traits_extension.py", line 135, in validate
self.error(objekt, name, str(value))
File "/opt/conda/lib/python3.9/site-packages/traits/base_trait_handler.py", line 74, in error
raise TraitError(
traits.trait_errors.TraitError: The 'output_image' trait of a N4BiasFieldCorrectionOutputSpec instance must be a pathlike object or string representing an existing file, but a value of '/scratch/smb02011/16727/fmriprep_23_0_wf/single_subject_ON99620_wf/anat_preproc_wf/brain_extraction_wf/inu_n4/mapflow/_inu_n40/sub-ON99620_ses-01_acq-MPRAGE_T1w_template_maths_corrected.nii.gz' <class 'str'> was specified.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 399, in run
runtime = self._post_run_hook(runtime)
File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/mixins/fixheader.py", line 127, in _post_run_hook
outputs = self.aggregate_outputs(runtime=runtime).get_traitsfree()
File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 461, in aggregate_outputs
raise FileNotFoundError(msg)
FileNotFoundError: No such file or directory '/scratch/smb02011/16727/fmriprep_23_0_wf/single_subject_ON99620_wf/anat_preproc_wf/brain_extraction_wf/inu_n4/mapflow/_inu_n40/sub-ON99620_ses-01_acq-MPRAGE_T1w_template_maths_corrected.nii.gz' for output 'output_image' of a N4BiasFieldCorrection interface
Screenshots / relevant information:
The closest other posts on neurostars that I’ve been able to find suggest this is a memory or disk space issue, but I’m allocating what I think is a lot of memory to the job and disk space at the time of the crash says I’ve only used 5.6G out of 776G available. Is there something else I’m doing wrong? Note I have --fs-no-reconall flagged in this to try and isolate the issue but it also happened when trying to run FreeSurfer. I also tried to set a different working directory (scratch_dir=$project_dir/data/work) but that didn’t change the error.