From a101d24b3e151b833c30175ad68b1139228370e7 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Tue, 20 Sep 2022 18:41:06 +0200 Subject: [PATCH 1/2] FIX: Deployed Matlab apps must not call addpath() https://mathworks.com/help/compiler/isdeployed.html The path of a deployed application is fixed at compile time and cannot change. Use isdeployed to ensure that the application uses path modifying functions, such as addpath, before deployment. This fixes the case where nipype calls SPM12 Standalone, associated to Matlab Compiler Runtime (MCR) R2019a (9.6) or later. Upcoming versions of SPM12 Standalone will most probably be compiled with Matlab R2021b, and hence will be subject to this bug. --- nipype/interfaces/matlab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/matlab.py b/nipype/interfaces/matlab.py index 03e34b0b43..bfb9e34b48 100644 --- a/nipype/interfaces/matlab.py +++ b/nipype/interfaces/matlab.py @@ -191,7 +191,7 @@ def _gen_matlab_command(self, argstr, script_lines): else: prescript.insert(0, "fprintf(1,'Executing code at %s:\\n',datestr(now));") for path in paths: - prescript.append("addpath('%s');\n" % path) + prescript.append("if ~(ismcc || isdeployed), addpath('%s'); end;\n" % path) if not mfile: # clean up the code of comments and replace newlines with commas From 72fa3bf502da152c80c3a15b8378fb8b12000839 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Tue, 20 Sep 2022 20:06:47 +0200 Subject: [PATCH 2/2] Update nipype/interfaces/matlab.py Co-authored-by: Chris Markiewicz --- nipype/interfaces/matlab.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nipype/interfaces/matlab.py b/nipype/interfaces/matlab.py index bfb9e34b48..294abdf3ef 100644 --- a/nipype/interfaces/matlab.py +++ b/nipype/interfaces/matlab.py @@ -191,6 +191,9 @@ def _gen_matlab_command(self, argstr, script_lines): else: prescript.insert(0, "fprintf(1,'Executing code at %s:\\n',datestr(now));") for path in paths: + # addpath() is not available after compliation + # https://www.mathworks.com/help/compiler/ismcc.html + # https://www.mathworks.com/help/compiler/isdeployed.html prescript.append("if ~(ismcc || isdeployed), addpath('%s'); end;\n" % path) if not mfile: