Using SPM Standalone to run compiled MATLAB code

Summary of what happened:

I am attempting to create a Docker container built on MATLAB Runtime and SPM. This docker container will be used on a platform called Flywheel, which requires MATLAB code to be compiled in order to be executed (using MATLAB Compiler). However, it seems that I cannot execute a compiled script with SPM. I also cannot add SPM to the script before it is compiled, as ‘addpath’ throws an error.

Is it possible to use SPM to execute a compiled script? I have seen prior discussions on using SPM to execute an .m script using MCR and Nipype. However, nothing I have tried has worked so far. I do not have a MATLAB license, so it is difficult to test this locally…

I appreciate anyone’s thoughts on how to make this work using this software!

Command used (and if a helper script was used, a link to the helper script or the command generated):

/opt/spm/spm12 /opt/mcr/v99 function ${FLYWHEEL}/my_function

Version:

MATLAB 2020b
MATLAB Compiler 2020b
SPM12 Standalone for MATLAB 2020b
Docker 4.39.0
Flywheel CLI (beta) 0.20.0+main.5d2c95f3

Environment (Docker, Singularity / Apptainer, custom installation):

Docker via Flywheel

Screenshots / relevant information:

Script that I have compiled comes from this repo: GitHub - LeoIacca/rPOP: Repository with scripts and templates to run rPOP