Synthstrip error while running MRIQC

Hi everyone. I am new to MRI field. I am working with my pilot data. I am getting errors while running MRIQC. Any help would be appreciated. Thank you.

Here is the script I am using:

#!/bin/bash

#User inputs:
bids_dir=/home/lotlikar/Pilot_Bernat   #absolute path
participant=P02
mem=40 #gb
container=docker 


if [ ! -d $bids_dir/derivatives/mriqc/sub-$participant ]; 
then
mkdir -p $bids_dir/derivatives/mriqc/sub-$participant 
fi

 
docker run -it --rm \
-v $bids_dir:/data:ro \
-v $bids_dir/derivatives/mriqc/sub-$participant:/out \
nipreps/mriqc:latest \
/data /out participant \
--participant_label $participant \
--mem_gb $mem \
--modalities T1w \
--deoblique \
--float32 \
-w $bids_dir/derivatives/mriqc/sub-$participant

The error I am getting in my Ubuntu terminal:

240104-14:54:38,951 nipype.workflow WARNING:
         [Node] Error on "mriqc_wf.anatMRIQC.synthstrip_wf.synthstrip" (/home/lotlikar/Pilot_Bernat/derivatives/mriqc/sub-P02/mriqc_wf/anatMRIQC/synthstrip_wf/_in_file_..data..sub-P02..anat..sub-P02_acq-mprage08iFIL_T1w.nii.gz/synthstrip)
240104-14:54:39,140 nipype.workflow ERROR:
         Node synthstrip.a0 failed to run on host 2a41b85f6aa1.
240104-14:54:39,150 nipype.workflow ERROR:
         Saving crash info to /out/logs/crash-20240104-145439-root-synthstrip.a0-601a6ed4-61c5-4ca5-b519-d24680328226.txt
Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/mriqc/engine/plugin.py", line 60, 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 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 synthstrip.

Cmdline:
        synthstrip -b 1 -i /home/lotlikar/Pilot_Bernat/derivatives/mriqc/sub-P02/mriqc_wf/anatMRIQC/synthstrip_wf/_in_file_..data..sub-P02..anat..sub-P02_acq-mprage08iFIL_T1w.nii.gz/pre_n4/clipped_corrected.nii.gz --model /opt/freesurfer/models/synthstrip.1.pt -n 1 -o clipped_corrected_desc-brain.nii.gz -m clipped_corrected_desc-brain_mask.nii.gz
Stdout:

Stderr:
        Killed
Traceback:
        RuntimeError: subprocess exited with code 137.

Traceback (most recent call last):
  File "/opt/conda/bin/mriqc", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.9/site-packages/mriqc/cli/run.py", line 168, in main
    mriqc_wf.run(**_plugin)
  File "/opt/conda/lib/python3.9/site-packages/nipype/pipeline/engine/workflows.py", line 638, in run
    runner.run(execgraph, updatehash=updatehash, config=self.config)
  File "/opt/conda/lib/python3.9/site-packages/mriqc/engine/plugin.py", line 184, in run
    self._clean_queue(jobid, graph, result=result)
  File "/opt/conda/lib/python3.9/site-packages/mriqc/engine/plugin.py", line 256, in _clean_queue
    raise RuntimeError("".join(result["traceback"]))
RuntimeError: Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/mriqc/engine/plugin.py", line 60, 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 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 synthstrip.

Cmdline:
        synthstrip -b 1 -i /home/lotlikar/Pilot_Bernat/derivatives/mriqc/sub-P02/mriqc_wf/anatMRIQC/synthstrip_wf/_in_file_..data..sub-P02..anat..sub-P02_acq-mprage08iFIL_T1w.nii.gz/pre_n4/clipped_corrected.nii.gz --model /opt/freesurfer/models/synthstrip.1.pt -n 1 -o clipped_corrected_desc-brain.nii.gz -m clipped_corrected_desc-brain_mask.nii.gz
Stdout:

Stderr:
        Killed
Traceback:
        RuntimeError: subprocess exited with code 137.

240104-14:55:32,188 nipype.workflow WARNING:
         [Node] Error on "mriqc_wf.anatMRIQC.synthstrip_wf.synthstrip" (/home/lotlikar/Pilot_Bernat/derivatives/mriqc/sub-P02/mriqc_wf/anatMRIQC/synthstrip_wf/_in_file_..data..sub-P02..anat..sub-P02_acq-mprage08iORIG_T1w.nii.gz/synthstrip)

Hi @Madhura_Lotlikar and welcome to neurostars!

For future software issues like this, please use the Software Support post category, which provides a post template that prompts you to give us more information that helps us debug you issue. (I have moved your post to this category after the fact).

I see a few issues here:

Since you renamed $bids_dir as /data in the container (with -v $bids_dir:/data:ro), Docker may not be able to find the working directory as you named it here, since you are using the original (and not renamed) name. Additionally, you should not put the working directory anywhere in your BIDS directory.

You can leave the output directory as just -v $bids_dir/derivatives:/out. MRIQC will automatically make the mriqc/sub-XX folders there.

This error means you probably ran out of memory. Are you running this on your personal computer or a high performance compute cluster? Are you sure you have 40 GB on your machine? You might need to change your Docker settings to allow up to 40GB. I would also explicitly set the number of CPUs you use for the job, as this impacts memory as well (more CPUs β†’ more memory usage).

Best,
Steven

1 Like

Hi Steven
Thank you very much for your response. I made the changes you suggested but I still see RuntimeError. I am running this on my PC. I ran the same script with small files and it completed the run. So it’s a memory issue.

I have 60gb still free on my laptop and I tried to set the memory limit higher on my docker container using:

docker run -d --name MP02 --memory=15g --memory-swap=15g -v $bids_dir:/data:ro -v $bids_dir/derivatives:/out nipreps/mriqc:latest

But for some reason, the container exits immediately (checked by passing docker ps -a). So I am unable to run MRIQC on my single-subject data. The current memory limit on docker is 7GB.

Hi @Madhura_Lotlikar,

You might have other options:

  1. Upload your data and run MRIQC on brainlife.io (Brainlife)
  2. Try the --oom-kill-disable flag, as described here (Runtime options with Memory, CPUs, and GPUs | Docker Docs). As a disclaimer, I have never used this flag so I do not know what kind of unforeseen consequences it may lead to.

Best,
Steven