NIPYPE SPM Normalize12 crashing

I’ m using NiPype through a Singularity image made with Neurodocker. I have successfully used other SPM preprocessing functions but the Normalize12 is crashing.
I’m basically using the following code:

import nipype.interfaces.spm as spm

matlab_cmd = '/opt/spm12-r7771/run_spm12.sh /opt/matlabmcr-2010a/v713/ script'
spm.SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True)

norm12 = spm.Normalize12()
norm12.inputs.image_to_align = 'myT1.nii'
norm12.run()

Unfortunately that gives me the very extensive following error (had to cut it a little):


RuntimeError Traceback (most recent call last)
in ()
1 norm12 = spm.Normalize12()
2 norm12.inputs.image_to_align = os.path.join(T1_output_folder,‘T1.nii’)
----> 3 norm12.run()

/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/nipype/interfaces/base/core.py in run(self, cwd, ignore_exception, **inputs)
396 # Run interface
397 runtime = self._pre_run_hook(runtime)
→ 398 runtime = self._run_interface(runtime)
399 runtime = self._post_run_hook(runtime)
400 # Collect outputs

/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/nipype/interfaces/spm/base.py in _run_interface(self, runtime)
385 deepcopy(self._parse_inputs())
386 )
→ 387 results = self.mlab.run()
388 runtime.returncode = results.runtime.returncode
389 if self.mlab.inputs.uses_mcr:

/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/nipype/interfaces/base/core.py in run(self, cwd, ignore_exception, **inputs)
396 # Run interface
397 runtime = self._pre_run_hook(runtime)
→ 398 runtime = self._run_interface(runtime)
399 runtime = self._post_run_hook(runtime)
400 # Collect outputs

/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/nipype/interfaces/matlab.py in _run_interface(self, runtime)
168 def _run_interface(self, runtime):
169 self.terminal_output = “allatonce”
→ 170 runtime = super(MatlabCommand, self)._run_interface(runtime)
171 try:
172 # Matlab can leave the terminal in a barbbled state

/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/nipype/interfaces/base/core.py in _run_interface(self, runtime, correct_return_codes)
744 runtime = run_command(runtime, output=self.terminal_output)
745 if runtime.returncode is None or runtime.returncode not in correct_return_codes:
→ 746 self.raise_exception(runtime)
747
748 return runtime

/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/nipype/interfaces/base/core.py in raise_exception(self, runtime)
675 “Command:\n{cmdline}\nStandard output:\n{stdout}\n”
676 “Standard error:\n{stderr}\nReturn code: {returncode}”
→ 677 ).format(**runtime.dictcopy())
678 )
679

RuntimeError: Command:
/opt/spm12-r7771/run_spm12.sh /opt/matlabmcr-2010a/v713/ script /mydata/EXC30/MREG_recon/T1/pyscript_normalize12.m
Standard output:
{Warning: Initializing Handle Graphics failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup,
which should be resolved as soon as possible. Error detected was:
MATLAB:Java:GenericException
Could not find }

In matlabrc at 102
SPM12, version 7771 (standalone)
MATLAB, version 7.10.0.499 (R2010a)


/ )( _ ( / )
_
\ )
/ ) ( Statistical Parametric Mapping
(
/(_) (_//_) SPM12 - SPM - Statistical Parametric Mapping

Executing /mydata/EXC30/MREG_recon/T1/pyscript_normalize12.m at 18-Aug-2021 19:33:03:

MATLAB Version 7.10.0.499 (R2010a)
MATLAB License Number: unknown
Operating System: Linux 3.10.0-1062.9.1.el7.x86_64 #1 SMP Mon Dec 2 08:31:54 EST 2019 x86_64
Java VM Version: Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode

MATLAB Version 7.10 (R2010a)
MATLAB Compiler Version 4.13 (R2010a)
Signal Processing Toolbox Version 6.13 (R2010a)
SPM version: SPM12 Release: 7771
SPM path: /opt/spm12-r7771/spm12_mcr/spm12/spm.m


18-Aug-2021 19:33:10 - Running job #1

18-Aug-2021 19:33:10 - Running ‘Normalise: Estimate & Write’

SPM12: spm_preproc_run (v7670) 19:33:10 - 18/08/2021

Segment /mydata/EXC30/MREG_recon/T1/T1.nii,1


   Segmentation violation detected at Wed Aug 18 19:33:13 2021

Configuration:
MATLAB Version: 7.10.0.499 (R2010a)
MATLAB License: unknown
Operating System: Linux 3.10.0-1062.9.1.el7.x86_64 #1 SMP Mon Dec 2 08:31:54 EST 2019 x86_64
GNU C Library: 2.24 stable
Window System: The X.Org Foundation (11906000), display :1.0
Current Visual: 0x21 (class 4, depth 24)
Processor ID: x86 Family 6 Model 5 Stepping 4, GenuineIntel
Virtual Machine: Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode
Default Encoding: UTF-8

Fault Count: 1

Register State:
rax = 00002aaabc10fcb8 rbx = 00002aaabc10fcb8
rcx = 00000000ffffffff rdx = 00002aaabc10fcc0
rbp = 00002aaaba2cc560 rsi = 00002aaabc10f400
rdi = 00002aaabc10fc70 rsp = 00002aaaba2cc510
r8 = 0000000000000000 r9 = 0000000000000000
r10 = 000000000000003e r11 = 00002aaabb41b028
r12 = 00002aaabc10f400 r13 = 00002aaab1723079
r14 = 0000000000000000 r15 = 0000000000000000
rip = 00002aaabaf774f1 flg = 0000000000010202

[…]

Could not initialize the dynamic Java classpath needed for toolboxes and
custom java classes. The Java calls may not work in the deployed mode. If
you are using certain MathWorks toolbox that uses jar files, you can
extract the CTF archive by either running the application once or using the
extractCTF utility and then copy the toolbox jar file from
_mcr/java/jar/toolbox directory to the /java/jar/toolbox
directory. For your custom Java class and jar files, you can copy these to
any directory on your target machine and add this directory and/or the jar
files with fully qualified path to the classpath.txt in your MCR installation.
Segmentation fault
Return code: 139