Skip to content

Commit 99c07f5

Browse files
committed
enh: Add support for spm/mcr config via env vars
This patch adds support for configuring the SPM standalone version (mcr) via environment variables. The respected environment variables are: USE_SPMMCR: any value, sets use_mcr to True SPMMCRCMD: command to use for spm mcr, if use_mcr is True
1 parent 49d76df commit 99c07f5

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

nipype/interfaces/spm/base.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,34 @@ def version(matlab_cmd=None, paths=None, use_mcr=None):
129129
130130
Parameters
131131
----------
132-
matlab_cmd : String specifying default matlab command
133-
134-
default None, will look for environment variable MATLABCMD
135-
and use if found, otherwise falls back on MatlabCommand
136-
default of 'matlab -nodesktop -nosplash'
132+
matlab_cmd: str
133+
Sets the default matlab command. If None, the value of the
134+
environment variable SPMMCRCMD will be used if set and use_mcr
135+
is True or the environment variable USE_SPMMCR is set.
136+
If one of USE_SPMMCR or SPMMCRCMD is not set, the existence
137+
of the environment variable MATLABCMD is checked and its value
138+
is used as the matlab command if possible.
139+
If none of the above was successful, the fallback value of
140+
'matlab -nodesktop -nosplash' will be used.
141+
paths : str
142+
use_mcr : bool
137143
138144
Returns
139145
-------
140146
spm_path : string representing path to SPM directory
141147
142148
returns None of path not found
143149
"""
150+
if use_mcr or 'USE_SPMMCR' in os.environ:
151+
use_mcr = True
152+
try:
153+
matlab_cmd = os.environ['SPMMCRCMD']
154+
except KeyError:
155+
pass
144156
if matlab_cmd is None:
145157
try:
146158
matlab_cmd = os.environ['MATLABCMD']
147-
except:
159+
except KeyError:
148160
matlab_cmd = 'matlab -nodesktop -nosplash'
149161
mlab = MatlabCommand(matlab_cmd=matlab_cmd)
150162
mlab.inputs.mfile = False

0 commit comments

Comments
 (0)