ReproNim / neurodocker

Generate custom Docker and Singularity images, and minimize existing containers
https://www.repronim.org/neurodocker/
Apache License 2.0
326 stars 97 forks source link

Add option to install CAT12 #407

Closed JohannesWiesner closed 1 year ago

JohannesWiesner commented 3 years ago

Recently, A CAT12 interface was added to nipype by @mfmachado. This interface was tested using a bare-metal installation of SPM and CAT12. Furthermore, @m-wierzba has already created a singularity image that uses the standalone version from CAT12. So I guess it could be possible to bring those two together in NeuroDocker to be able to use Nipype+CAT12 in a containerized form?

zndr27 commented 2 years ago

I'm also interested in this feature.

stebo85 commented 2 years ago

Cat12 comes in an MCR version: http://141.35.69.218/cat12/

so modifying the SPM12 file would be a good start: https://github.com/ReproNim/neurodocker/blob/master/neurodocker/templates/spm12.yaml

zndr27 commented 2 years ago

I previously tried building an image which using "cat12_latest_R2017b_MCR_Linux.zip"

However when I tried running CAT12Segment from the nipype interface I got the following error shown below. Upon further inspection, it seemed to me like many of the matlab files included with SPM are not in the CAT12 standalone MCR. Granted, I know very little about Matlab or SPM / CAT12 so I may have made a mistake.

/usr/local/lib/python3.8/dist-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

/usr/local/lib/python3.8/dist-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:

/usr/local/lib/python3.8/dist-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

/usr/local/lib/python3.8/dist-packages/nipype/interfaces/matlab.py in _run_interface(self, runtime) 162 pass 163 if "MATLAB code threw an exception" in runtime.stderr: --> 164 self.raise_exception(runtime) 165 return runtime 166

/usr/local/lib/python3.8/dist-packages/nipype/interfaces/base/core.py in raise_exception(self, runtime) 671 672 def raise_exception(self, runtime): --> 673 raise RuntimeError( 674 ( 675 "Command:\n{cmdline}\nStandard output:\n{stdout}\n"

RuntimeError: Command: /opt/spm/run_spm12.sh /opt/matlabmcr-2017b/v93 script /workspace/pyscript_cat12segment.m Standard output:

Setting up environment variables

LD_LIBRARY_PATH is .:/opt/matlabmcr-2017b/v93/runtime/glnxa64:/opt/matlabmcr-2017b/v93/bin/glnxa64:/opt/matlabmcr-2017b/v93/sys/os/glnxa64:/opt/matlabmcr-2017b/v93/sys/opengl/lib/glnxa64 Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/connectivity/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/external/signal/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/external/stats/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/fileio/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/forward/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/inverse/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/plotting/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/preproc/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/specest/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/statfun/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/trialfun/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/fieldtrip/utilities/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/ricoh_meg_reader/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/external/yokogawa_meg_reader/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/matlabbatch/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/toolbox/DAiSS/private Warning: Private directories not allowed in MATLAB path: /opt/spm/spm12_mcr/home/gaser/spm12/toolbox/TSSS/private SPM12, version 7771 (standalone) MATLAB, version 9.3.0.713579 (R2017b)


/ )( ( \/ )
_
\ )_
/ ) ( Statistical Parametric Mapping
(/() (/\/_) SPM12 - https://www.fil.ion.ucl.ac.uk/spm/

Executing /workspace/pyscript_cat12segment.m at 19-Jan-2022 16:50:29:

MATLAB Version: 9.3.0.713579 (R2017b) MATLAB License Number: unknown Operating System: Linux 5.13.0-23-generic #23-Ubuntu SMP Fri Nov 26 11:41:15 UTC 2021 x86_64 Java Version: Java 1.8.0_121-b13 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode

MATLAB Version 9.3 (R2017b)
Computational Anatomy Toolbox Version 1904 (CAT12.8)
FieldTrip Version unknown www.fieldtriptoolbox.org MATLAB Compiler Version 6.5 (R2017b)
RICOH MEG Reader toolbox for MATLAB Version 1.0.2
Statistical Parametric Mapping Version 7771 (SPM12)
Statistical Parametric Mapping Version 7771 (SPM12)
TFCE Toolbox Version 224 (version 1.0)
Template-O-Matic Toolbox Version 9 (TOM8)
Yokogawa MEG Reader toolbox for MATLAB Version 1.5.1
SPM version: SPM12 Release: 7771 SPM path: /opt/spm/spm12_mcr/home/gaser/spm12/spm.m Standard error: MATLAB code threw an exception: Undefined function or variable 'mysubs_fields'. File:/opt/spm/spm12_mcr/home/gaser/spm12/matlabbatch/@cfg_branch/cfg_branch.m Name:/opt/spm/spm12_mcr/home/gaser/spm12/matlabbatch/cfg_getfile.m Line:47 File:opt/spm/spm12_mcr/home/gaser/spm12/matlabbatch/cfg_getfile.m Name:/opt/spm/spm12_mcr/home/gaser/spm12/spm_select.m Line:47 File:opt/spm/spm12_mcr/home/gaser/spm12/spm_select.m Name:/opt/spm/spm12_mcr/home/gaser/spm12/spm_select.m Line:47 File:opt/spm/spm12_mcr/home/gaser/spm12/spm_jobman.m Name:/opt/spm/spm12_mcr/home/gaser/spm12/spm.m Line:47 File:opt/spm/spm12_mcr/home/gaser/spm12/spm_standalone.m Name:cfg_branch Line:114 File:eg_filter Name:cfg_getfile Line:115 File:pm_select Name:spm_select Line:115 File:pm_select Name:spm_jobman Line:115 File:pm Name:spm_standalone Line:59 File:ҡ Name:± Line:115 File:n Name:a Line:173 File:ѻ Name:s Line: Return code: 0

stebo85 commented 2 years ago

I build a container using the official CAT12 MCR release (http://141.35.69.218/cat12/CAT${CAT_VERSION}_${CAT_REVISION}_${MATLAB_VERSION}_MCR_Linux.zip ) and I also run into this problem. It seems that there is a custom function

SPM path: /opt/CAT12.8_r1904_R2017b_MCR_Linux/spm12_mcr/home/gaser/spm12/spm.m
Standard error:
MATLAB code threw an exception:
Undefined function or variable 'mysubs_fields'.

that breaks it. Maybe @ChristianGaser has an idea what this function is and why it didn't get compiled for the MCR.

I also tested @gllmflndn MCR SPM version with many toolboxes included (https://www.fil.ion.ucl.ac.uk/spm/download/restricted/utopia/dev/spm12_latest_BI_Linux_R2019b.zip) and run into another issue, but this time caused by the SnPM toolbox:

SPM version: SPM12 Release: 8157
SPM path: /opt/spm12/spm12_mcr/spm/spm12/spm.m
Standard error:
MATLAB code threw an exception:
Brace indexing is not supported for variables of this type.
File:/opt/spm12/spm12_mcr/spm/spm12/matlabbatch/cfg_callbuiltin.m
Name:/opt/spm12/spm12_mcr/spm/spm12/matlabbatch/@cfg_exbranch/subsref.m
Line:47
File:opt/spm12/spm12_mcr/spm/spm12/toolbox/SnPM/config/snpm_bch_ui_PairT.m
Name:/opt/spm12/spm12_mcr/spm/spm12/toolbox/SnPM/config/snpm_cfg_master.m
Line:47
File:opt/spm12/spm12_mcr/spm/spm12/toolbox/SnPM/tbx_cfg_snpm13.m
Name:/opt/spm12/spm12_mcr/spm/spm12/config/spm_cfg_static_tools.m

However, running SPM via Nipype works perfectly in the release version of SPM MCR (https://www.fil.ion.ucl.ac.uk/spm/download/restricted/bids/spm12_r7771_Linux_R2019b.zip)

zndr27 commented 2 years ago

Yes I want to echo that building a container with nipype + SPM12 r7771 MCR R2019b works for me as well! There seems to be issues with nipype + CAT12 MCR release specifically.

gllmflndn commented 2 years ago

I will have a look at the issue with SnPM - this happens in the context of the development version of SPM so this is a side issue.

I would prefer if the "official" standalone version of SPM was used for nipype + SPM12.

stebo85 commented 2 years ago

Christian Gaser found the problem and fixed it in this build :) http://www.neuro.uni-jena.de/cat12/CAT12.8_r1933_R2017b_MCR_Linux.zip - I am just building a new image for Neurodesk and then I have a look at writing the build recipe for neurodocker :)

kaczmarj commented 2 years ago

thank you @stebo85 and everyone else!

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.