QSIPrep Exception raised while executing Node mask_template

Hi all - long time listener, first time caller. I’m having problems running qsiprep - please see below for details.

Many thanks!

Oli

Summary of what happened:

Attempting to run qsiprep using T1w and dwi data was inputs. Completes fine in some subjects/sessions, but some encounter a fatal error. I can’t tell why some do and some do not complete, but hoping that this will help me figure that out.

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

parallel --verbose --progress -j 2 \
docker run --gpus all --rm \
    -e DOCKER_VERSION_8395080871=29.1.3 \
    --mount type=bind,source=$HOMEDIR,dst=$HOMEDIR \
    -v /home/hackerman/Desktop/ssd_workdir:/home/hackerman/Desktop/ssd_workdir:rw \
    -v ${HOMEDIR}/bids_complete:${HOMEDIR}/bids_complete:ro \
    -v ${HOMEDIR}/derivatives:${HOMEDIR}/derivatives:rw \
    -v $FSLICK:/opt/freesurfer/license.txt:ro \
    pennlinc/qsiprep:26.1.0 \
    $HOMEDIR/bids_complete \
    ${HOMEDIR}/derivatives/qsiprep \
    -w /home/hackerman/Desktop/ssd_workdir/temp_{} \
    --output-resolution 2 \
    participant \
   --verbose \
   --sdc-anat-reference synb0 \
   --gpu {diffprep,drbuddi,eddy} \
   --subject-anatomical-reference sessionwise \
   --anat-modality T1w \
   --participant-label {} \
   --skip-bids-validation ::: $subs
CODE HERE

Version:

qsiprep version = “26.1.0”

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

docker DOCKER_VERSION_8395080871=29.1.3

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

Converted using dcm2bids but I skip bids validation

PASTE VALIDATOR OUTPUT HERE

Relevant log outputs (up to 20 lines):

<!-- Below thisTraceback (most recent call last):
  File "/app/.pixi/envs/qsiprep/lib/python3.11/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/qsiprep/lib/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 546, in run
    result = self._run_interface(execute=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/qsiprep/lib/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 661, in _run_interface
    return self._run_command(execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/qsiprep/lib/python3.11/site-packages/nipype/pipeline/engine/nodes.py", line 787, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node mask_template.
Cmdline:
	3dcalc -a /home/hackerman/Desktop/ssd_workdir/temp_sub-3124/qsiprep_26_1_wf/sub_3124_ses_20140528_wf/anat_preproc_wf/get_template_image/tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz -b /home/hackerman/Desktop/ssd_workdir/temp_sub-3124/qsiprep_26_1_wf/sub_3124_ses_20140528_wf/anat_preproc_wf/get_template_image/tpl-MNI152NLin2009cAsym_res-01_desc-brain_mask.nii.gz -expr "a*b" -prefix tpl-MNI152NLin2009cAsym_res-01_T1w_calc.nii.gz
Stdout:
Stderr:
	++ 3dcalc: AFNI version=AFNI_25.2.09 (Aug 24 2025) [64-bit]
	++ Authored by: A cast of thousands
	++ WARNING: nifti_read_buffer(/home/hackerman/Desktop/ssd_workdir/temp_sub-3124/qsiprep_26_1_wf/sub_3124_ses_20140528_wf/anat_preproc_wf/get_template_image/tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz):
	   data bytes needed = 17060042
	   data bytes input  = 12547649
	   number missing    = 4512393 (set to 0)
	** NIFTI load bricks: cannot read brick 0 from '/home/hackerman/Desktop/ssd_workdir/temp_sub-3124/qsiprep_26_1_wf/sub_3124_ses_20140528_wf/anat_preproc_wf/get_template_image/tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz'
	e[7m** FATAL ERROR:e[0m Can't load dataset '/home/hackerman/Desktop/ssd_workdir/temp_sub-3124/qsiprep_26_1_wf/sub_3124_ses_20140528_wf/anat_preproc_wf/get_template_image/tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz': is it complete?
	** Program compile date = Aug 24 2025 line, provide any other information that might be meaningful. This could be screenshots, troubleshooting steps you have tried, or information about your operating system, etc. -->


Screenshots / relevant information:

Hi @OliJimbo and welcome to neurostars!

Sounds like a potential templateflow issue. Do you have the templateflow archive cloned somewhere on your machine that you can pass in instead (by passing the TEMPLATEFLOW_HOME environment variable to Docker)?

Best,
Steven

Hi Steven - thanks for your reply. I’ve just cloned it from Datalad (only mni2009asymc because that seems to be where it’s hanging) - I’ll let you know how I get on!

Hi again,

So I tried that and am still getting the same issue. I just tried opening the input file to 3dcalc resample in fsleyes and the following error:

fsleyes tpl-MNI152NLin2009cAsym_res-01_desc-brain_mask.nii.gz 

OSError: Expected 8530021 bytes, got 3199233 bytes from object
 - could the file be damaged?

It might be that qsiprep is using the cached files rather than the local templateflow clone version - I’ll try deleting these and run it again

Hi @OliJimbo,

Are you making sure you are running QSIPrep in such that a way that it is using the datalad clone you want it to?

Best,
Steven

Hi Steven (sorry for the delay - I was off sick yesterday).

OK - I’m fairly sure it’s a problem with me rather than a templateflow problem.

The sessions in which the process fails have anatomical images that are spread over two runs. I thought dcm2bids handled this so didn’t think to check! I don’t know what’s happening under the hood but a guess is that the template is being reoriented to an incomplete reference - e.g. this error occurs both when running the pipeline and when trying to open the output file in fsleyes.

++ WARNING: nifti_read_buffer(/home/hackerman/Desktop/ssd_workdir/temp_sub-3118/qsiprep_26_1_wf/sub_3118_ses_20160224_wf/anat_preproc_wf/reorient_tpl_mask_to_lps/tpl-MNI152NLin2009cAsym_res-01_desc-brain_mask.nii.gz):
	   data bytes needed = 8530021
	   data bytes input  = 3199233
	   number missing    = 5330788 (set to 0)

Sorry for the inconvenience!