Skip to content

NiBabies Singularity Container Python Error with importing SafeConfigParser #482

@cgregg1227

Description

@cgregg1227

What happened?

Hi,

I am attempting to run anat-only preprocessing on a participant using NiBabies v25.1.1 in a Singularity container. The input dataset is BIDS-compliant, and both T1w and T2w images are present.

The workflow proceeds normally through the initial anatomical stages and confirms that existing segmentations and brain masks are found. However, it appears to be running into an issue with Python as it proceeds specifically when trying to import SafeConfigParser.

See below for the terminal command I used and the log output error I got. Please let me know if there is anything else helpful for me to provide and thank you in advance for your help!

What command did you use?

apptainer run --cleanenv \
  -B /mnt/nfs/proj/opc/MRI/data/bibsnet_input:/data:ro \
  -B /mnt/nfs/proj/opc/MRI/data/bibsnet_output_nibabies:/out \
  -B /mnt/nfs/proj/ineind/freesurfer/license.txt:/opt/freesurfer/license.txt:ro \
  -B /mnt/nfs/proj/opc/MRI/data/bibsnet_output/bibsnet:/seg \
  -B /mnt/nfs/proj/opc/MRI/data/nibabies_work/sub-231109_ses-2wk:/work \
  /mnt/nfs/labs/Howell/Software/nibabies/nibabies_25.1.1.sif \
  /data /out participant -vvv \
  --participant-label 231109 --session-id 2wk \
  --anat-only \
  -w /work \
  --fs-license-file /opt/freesurfer/license.txt \
  --derivatives /seg \
  --age-months 0 \
  --surface-recon-method mcribs \
  --cifti-output 91k \
  --debug registration \
  --project-goodvoxels \
  --multi-step-reg \
  --norm-csf \
  --output-spaces fsLR MNIInfant:cohort-1 \
  --omp-nthreads 8 \
  --mem 300000 \
  --nprocs 8 \
  --stop-on-first-crash

What version of NiBabies are you using?

NiBabies 25.1.1 in Singularity Container

Relevant log output

(node:960610) Warning: Closing directory handle on garbage collection
(Use `node --trace-warnings ...` to show where the warning was created)
/opt/conda/envs/nibabies/lib/python3.12/site-packages/niworkflows/interfaces/nibabel.py:596: FutureWarning: 'force_resample' will be set to 'True' by default in Nilearn 0.13.0.
Use 'force_resample=True' to suppress this warning.
  resampled = nli.resample_img(fixed_image, target_affine=new_affine, interpolation='nearest')
/opt/conda/envs/nibabies/lib/python3.12/site-packages/niworkflows/interfaces/nibabel.py:596: FutureWarning: From release 0.13.0 onwards, this function will, by default, copy the header of the input image to the output. Currently, the header is reset to the default Nifti1Header. To suppress this warning and use the new behavior, set `copy_header=True`.
  resampled = nli.resample_img(fixed_image, target_affine=new_affine, interpolation='nearest')
Traceback (most recent call last):
  File "/opt/conda/envs/nibabies/bin/nibabies", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nibabies/cli/run.py", line 104, in main
    nibabies_wf.run(**_plugin)
  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/pipeline/engine/workflows.py", line 625, in run
    runner.run(execgraph, updatehash=updatehash, config=self.config)
  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/pipeline/plugins/base.py", line 177, in run
    self._clean_queue(jobid, graph, result=result)
  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/pipeline/plugins/base.py", line 255, in _clean_queue
    raise RuntimeError("".join(result["traceback"]))
RuntimeError: Traceback (most recent call last):
  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/pipeline/engine/nodes.py", line 525, in run
    result = self._run_interface(execute=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/pipeline/engine/nodes.py", line 643, in _run_interface
    return self._run_command(execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/nibabies/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 mcribs_recon.

Cmdline:
	MCRIBReconAll --deformablefastcollision --deformablejointhresh 1.000000 -nthreads 8 --surfrecon --surfreconmethod Deformable sub-231109_ses-2wk
Stdout:
	sub-231109_ses-2wk 1.0 True False False
	Traceback (most recent call last):
	  File "/opt/MCRIBS/bin/../MIRTK/MIRTK-install/lib/tools/recon-neonatal-cortex", line 46, in <module>
	    from configparser import SafeConfigParser  # Python 3
	    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	ImportError: cannot import name 'SafeConfigParser' from 'configparser' (/opt/conda/envs/nibabies/lib/python3.12/configparser.py). Did you mean: 'RawConfigParser'?

	During handling of the above exception, another exception occurred:

	Traceback (most recent call last):
	  File "/opt/MCRIBS/bin/../MIRTK/MIRTK-install/lib/tools/recon-neonatal-cortex", line 48, in <module>
	    from ConfigParser import SafeConfigParser  # Python 2
	    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	ModuleNotFoundError: No module named 'ConfigParser'
	Running command:
		MCRIBSurfReconDeformable sub-231109_ses-2wk 1.0 True False False
Stderr:
	/opt/MCRIBS/bin/MCRIBReconAll:253: SyntaxWarning: invalid escape sequence '\('
	  mat = re.match('^set\(ITK_VERSION_(MAJOR|MINOR|PATCH) "(\d+)"\)$', curLine)
	/opt/MCRIBS/bin/MCRIBReconAll:301: SyntaxWarning: invalid escape sequence '\('
	  mat = re.match('^SET\(VTK_(MAJOR|MINOR|BUILD)_VERSION "(\d+)"\)$', curLine)
Traceback:
	Traceback (most recent call last):
	  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/interfaces/base/core.py", line 404, in run
	    outputs = self.aggregate_outputs(runtime)
	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/interfaces/base/core.py", line 433, in aggregate_outputs
	    predicted_outputs = self._list_outputs()  # Predictions from _list_outputs
	                        ^^^^^^^^^^^^^^^^^^^^
	  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nibabies/interfaces/mcribs.py", line 252, in _list_outputs
	    self._verify_outputs('surfrecon', surfrecon_dir, error=True)
	  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nibabies/interfaces/mcribs.py", line 289, in _verify_outputs
	    raise FileNotFoundError(f'{step.capitalize()} missing: {fl}')
	FileNotFoundError: Surfrecon missing: pial-lh-reordered.vtp

Add any additional information or context about the problem here.

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions