Mri_synthstrip failed

Summary of what happened:

I had provided a single t1w image, and two b700 dwi images in opposite PE directions as input to qsiprep. 4 CPUs of 8GB were provided.

I am not sure why synthstrip failed, was it due to the flags used in my call, resources allocated in HPC, or the NIFTI inputs even if they passed BIDS validation? I had BIDSified the data using the ezBIDS web interface.

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

export APPTAINERENV_FS_LICENSE=$GROUP_HOME/freesurferlicense.txt
singularity run -e --containall --writable-tmpfs --cleanenv \
/home/groups/jyeatman/software/singularity_images/qsiprep-0.20.0.sif \
/scratch/groups/jyeatman/howard/DBP/bids4 \
/scratch/groups/jyeatman/howard/DBP/qsiprep participant --participant-label sub-$SLURM_ARRAY_TASK_ID \
-w /scratch/groups/jyeatman/howard/DBP/qsiprep-work \
--nthreads 10 \
--omp-nthreads 8 \
--output-resolution 1.2 \
--infant \
--pepolar-method TOPUP+DRBUDDI

Version:

singularity build from docker://pennbbl/qsiprep:0.20.0 on HPC cluster

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

Summary
12 Files, 34.51MB
1 - Subject
1 - Session
Available Tasks
Available Modalities
MRI
We found 1 Warning in your dataset.
view 1 warning
Warning 1: [Code 113] NO_AUTHORS
Click here for more information about this issue

The Authors field of dataset_description.json should contain an array of fields - with one author per field. This was triggered because there are no authors, which will make DOI registration from dataset metadata impossible.

Relevant log outputs (up to 20 lines):

Cmdline:
	mri_synthstrip -i /scratch/groups/jyeatman/howard/DBP/qsiprep-work/qsiprep_wf/single_subject_20324_wf/dwi_finalize_acq_b700_dir_PA_wf/transform_dwis_t1/final_b0_ref/synthstrip_wf/pad_before_synthstrip_wf/resample_skulled_to_reference/vol0000_trans_scaled_merged_b0_series_mean_trans.nii -o vol0000_trans_scaled_merged_b0_series_mean_trans_brain.nii.gz -m vol0000_trans_scaled_merged_b0_series_mean_trans_mask.nii.gz
Stdout:
	Configuring model on the CPU
	Running SynthStrip model version 1
	Input image read from: /scratch/groups/jyeatman/howard/DBP/qsiprep-work/qsiprep_wf/single_subject_20324_wf/dwi_finalize_acq_b700_dir_PA_wf/transform_dwis_t1/final_b0_ref/synthstrip_wf/pad_before_synthstrip_wf/resample_skulled_to_reference/vol0000_trans_scaled_merged_b0_series_mean_trans.nii
Stderr:
	RuntimeWarning: invalid value encountered in divide
	Traceback (most recent call last):
	  File "/opt/freesurfer/bin/mri_synthstrip", line 232, in <module>
	    mask = (components == (np.argmax(bincount) + 1))
	  File "<__array_function__ internals>", line 180, in argmax
	  File "/usr/local/miniconda/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 1216, in argmax
	    return _wrapfunc(a, 'argmax', axis=axis, out=out, **kwds)
	  File "/usr/local/miniconda/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 57, in _wrapfunc
	    return bound(*args, **kwds)
	ValueError: attempt to get argmax of an empty sequence
Traceback:
	Traceback (most recent call last):
	  File "/usr/local/miniconda/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	  File "/usr/local/miniconda/lib/python3.10/site-packages/qsiprep/interfaces/freesurfer.py", line 605, in _run_interface
	    raise Exception("mri_synthstrip failed!")
	Exception: mri_synthstrip failed!

Screenshots / relevant information:


Hi @chiuhoward,

Could you try devoting more memory to the job? The new freesurfer tools in qsiprep (synthseg/synthstrip) are notoriously memory intensive.

Do you get the same error across multiple subjects?

Best,
Steven

Hi Steven,

thanks for the quick reply, I will try that. I’ve just started to work with qsiprep on my dataset, so I am currently trying the pipeline at the single subject level.

Before I allocate more memory and rerun the job, can I clarify if there is any relationship between the number of CPUs I allocate, —n-cpus/—nthreads, as well as —omp-nthreads that I should be mindful of?

Hi @chiuhoward,

In general, the more cpus you have, the faster things will go, and more memory will be used by the job. However, synthseg/strip are limited to 1cpu regardless of what you set in qsiprep arguments to limit memory.

Best,
Steven

I gave qsiprep a new work folder and deleted the previous output folder, but still had the same error.

I don’t think it’s a memory issue, unless even 256GB is still too little?

With the knowledge that synthseg/strip is limited to 1CPU, I requested for 256GB of memory (my understanding is that this calls 4 CPUs of 64GB memory on my compute cluster).

Cmdline:
	mri_synthstrip -i /scratch/groups/jyeatman/howard/DBP/qsiprep-work2/qsiprep_wf/single_subject_20324_wf/dwi_finalize_acq_b700_dir_PA_wf/transform_dwis_t1/final_b0_ref/synthstrip_wf/pad_before_synthstrip_wf/resample_skulled_to_reference/vol0000_trans_scaled_merged_b0_series_mean_trans.nii -o vol0000_trans_scaled_merged_b0_series_mean_trans_brain.nii.gz -m vol0000_trans_scaled_merged_b0_series_mean_trans_mask.nii.gz
Stdout:
	Configuring model on the CPU
	Running SynthStrip model version 1
	Input image read from: /scratch/groups/jyeatman/howard/DBP/qsiprep-work2/qsiprep_wf/single_subject_20324_wf/dwi_finalize_acq_b700_dir_PA_wf/transform_dwis_t1/final_b0_ref/synthstrip_wf/pad_before_synthstrip_wf/resample_skulled_to_reference/vol0000_trans_scaled_merged_b0_series_mean_trans.nii
Stderr:
	RuntimeWarning: invalid value encountered in divide
	Traceback (most recent call last):
	  File "/opt/freesurfer/bin/mri_synthstrip", line 232, in <module>
	    mask = (components == (np.argmax(bincount) + 1))
	  File "<__array_function__ internals>", line 180, in argmax
	  File "/usr/local/miniconda/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 1216, in argmax
	    return _wrapfunc(a, 'argmax', axis=axis, out=out, **kwds)
	  File "/usr/local/miniconda/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 57, in _wrapfunc
	    return bound(*args, **kwds)
	ValueError: attempt to get argmax of an empty sequence
Traceback:
	Traceback (most recent call last):
	  File "/usr/local/miniconda/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	  File "/usr/local/miniconda/lib/python3.10/site-packages/qsiprep/interfaces/freesurfer.py", line 605, in _run_interface
	    raise Exception("mri_synthstrip failed!")
	Exception: mri_synthstrip failed!

Hi @chiuhoward,

256 should be much more than enough. Can you share how you set the memory? E.g., did you submit to a job scheduler, like sbatch for SLURM systems?

That being said, the error doesn’t necessarily look like one that would be associated with a memory issue, but I’ve never seen synthstrip stop at this point before. Would you be able to share data an example subject (you can privately DM me a google drive link, for example)? Would also be curious if this error happens for other subjects in your dataset.

Best,
Steven