Thank you for your reply.
The commands to create the custom brain mask:
sour_dir=/home/user/data/BIDSDATA
targ_dir=/home/user/data/DRIVDATA/SynthStrip
curr_sub=sub-S01
INPUT=${sour_dir}/${curr_sub}/anat/${curr_sub}_T1w.nii.gz
OUTDIR=${targ_dir}/${curr_sub}/anat
mri_synthstrip -i ${INPUT} -m ${OUTDIR}/${curr_sub}_desc-brain_mask.nii.gz --no-csf
The commands to run fMRIPrep (25.2.5):
sour_dir=/home/user/data/BIDSDATA
targ_dir=/home/user/data/DRIVDATA
work_dir=/home/user/data/TMPODATA
FSLICENSE=/usr/local/freesurfer/7.4.1/license.txt
TFDIR=/home/user/software/TemplateFlow
docker run -ti --rm \
-v ${sour_dir}:/data:ro \
-v ${targ_dir}:/out \
-v ${work_dir}:/work \
-u $(id -u):$(id -g) \
-v ${TFDIR}:/opt/templateflow \
-v ${FSLICENSE}:/opt/freesurfer/license.txt \
-e TEMPLATEFLOW_HOME=/opt/templateflow \
nipreps/fmriprep:25.2.5 \
/data /out/FMRIPREP participant \
-w /work --fs-license-file /opt/freesurfer/license.txt --nthreads 10 \
--dummy-scans 5 \
--notrack --stop-on-first-crash \
--derivatives anat=/out/SynthStrip
From the fMRIPrep log, the custom mask was successfully identified:
260810-14:15:21,65 nipype.workflow INFO:
ANAT Found brain mask - skipping Stage 6
However, when applying the mask, the following error occurred:
Traceback (most recent call last):
File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
result["result"] = node.run(updatehash=updatehash)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/nipype/pipeline/engine/nodes.py", line 525, in run
result = self._run_interface(execute=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/nipype/pipeline/engine/nodes.py", line 643, in _run_interface
return self._run_command(execute)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/nipype/pipeline/engine/nodes.py", line 769, in _run_command
raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node apply_mask.
Traceback:
Traceback (most recent call last):
File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/nipype/interfaces/base/core.py", line 401, in run
runtime = self._run_interface(runtime)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.pixi/envs/fmriprep/lib/python3.12/site-packages/niworkflows/interfaces/nibabel.py", line 78, in _run_interface
raise ValueError('Image and mask affines are not similar enough.')
ValueError: Image and mask affines are not similar enough.
Regarding your request for a visual demonstration, unfortunately, I’m not familiar with fMRIPrep’s internal workflow, so I’m not sure how to generate one. As for the potential spatial mismatch, I’ve seen this issue mentioned in previous posts, which is where I learned about it.