Skip to content

Commit 22813b0

Browse files
committed
enh: Add support for spm/mcr config via env vars
This patch adds support for enforcing and configuring the spm MCR standalone version via environment variables. The respected environment variables are: FORCE_SPMMCR: any value, sets use_mcr to True SPMMCRCMD: command to use when running spm MCR, if use_mcr is True
1 parent 1c23b50 commit 22813b0

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

doc/users/spmmcr.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ you can test by calling:
1919

2020
spm.SPMCommand().version
2121

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.
33+
2234
Information about the MCR version of SPM8 can be found at:
2335

2436
http://en.wikibooks.org/wiki/SPM/Standalone

nipype/interfaces/spm/base.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,31 @@ 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']

0 commit comments

Comments
 (0)