Skip to content

Commit b567f2a

Browse files
committed
Merge pull request #759 from rku/enh/spmmcr_env_config
ENH: Add support for spm MCR configuration via environment
2 parents aec75f6 + 22813b0 commit b567f2a

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

doc/users/spmmcr.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,19 @@ you can test by calling:
1717

1818
.. testcode::
1919

20-
spm.SPMCommand().version
20+
spm.SPMCommand().version
21+
22+
If you want to enforce the standalone MCR version of spm for nipype globally,
23+
you can do so by setting the following environment variables:
24+
25+
*SPMMCRCMD*
26+
Specifies the command to use to run the spm standalone MCR version. You
27+
may still override the command as described above.
28+
29+
*FORCE_SPMMCR*
30+
Set this to any value in order to enforce the use of spm standalone MCR
31+
version in nipype globally. Technically, this sets the `use_mcr` flag of
32+
the spm interface to True.
2133

2234
Information about the MCR version of SPM8 can be found at:
2335

nipype/interfaces/spm/base.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,35 @@ 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 FORCE_SPMMCR is set.
136+
If one of FORCE_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 'FORCE_SPMMCR' in os.environ:
151+
use_mcr = True
152+
if matlab_cmd is None:
153+
try:
154+
matlab_cmd = os.environ['SPMMCRCMD']
155+
except KeyError:
156+
pass
144157
if matlab_cmd is None:
145158
try:
146159
matlab_cmd = os.environ['MATLABCMD']
147-
except:
160+
except KeyError:
148161
matlab_cmd = 'matlab -nodesktop -nosplash'
149162
mlab = MatlabCommand(matlab_cmd=matlab_cmd)
150163
mlab.inputs.mfile = False

0 commit comments

Comments
 (0)