SPM/Standalone

From Wikibooks, open books for an open world
< SPM
Jump to: navigation, search


Introduction[edit]

A standalone SPM is a version of SPM that has been compiled using the MATLAB Compiler, see:

so that it does not require the availability of a MATLAB licence.

A beta version of a standalone SPM8 is available upon request for most platforms (Windows 32/64 bit, Linux 32/64 bit, and MacOS 64 bit). Please contact fil.spm@ucl.ac.uk.

Installation[edit]

Following your request, you will be given instructions to download the following components:

  • The MATLAB Compiler Runtime (MCR) v4.13, corresponding to MATLAB R2010a for your architecture: there are subfolders in the MCR folder for 32- and 64-bit Windows (win32, win64), Linux (glnx86, glnxa64), and 64-bit Mac (maci64). On Windows platforms, if you don't have Microsoft Visual C++ runtime components installed, you might also need to download the vcredist_*.exe file from the same folder.
  • The Component Technology File (CTF) containing the compiled SPM, as a ZIP file.

Installation of the MCR[edit]

You need to do this operation only once, even if you use several versions of standalone SPM.

Run the MCRInstaller executable you downloaded and follow the instructions.

Windows installation requires to have administrative privileges and you might also have to install the Visual C++ Redistributable Package (vcredist_*.exe), that can be found in the same folder as the MCRInstaller. We also recommend you restart Windows at this point.

If you run into problems, or want to learn more, see:

Installation of the CTF[edit]

Unzip the spm8_rxxx.zip archive containing the SPM Component Technology File (CTF) in an appropriate folder. It contains a number of small executables for each supported platform and a large spm8.ctf file containing the compiled version of SPM8 itself.

The first time the standalone application will be executed, the CTF file will be unpacked in a subfolder so if you installed the CTF in a folder that requires administrative permission for write access, you should execute the application once under those privileges -- see below.

On Mac, you also need to unzip the spm8_maci64.zip archive.

Usage[edit]

To start SPM graphical user interface:

  • on Windows: double-click on spm8_wxx.exe
  • on Linux, type
./run_spm8.sh /usr/local/MATLAB/MATLAB_Compiler_Runtime/v713/

where the argument is the path to your MCR installation.

  • on Mac, type
./run_spm8.sh /Applications/MATLAB/MATLAB_Compiler_Runtime/v713/

where the argument is the path to your MCR installation.

The first execution should take longer to start as the CTF file will be unpacked. When installing SPM system-wide, you should do the first unpacker execution as root, i.e.

./run_spm8.sh /usr/local/MATLAB/MATLAB_Compiler_Runtime/v713/ quit

On Linux/Mac, you can edit the Shell script run_spm8.sh to hardcode the location of the MCR installation, thus removing the need of providing it on the command line.

The other arguments that can be used are the modality (as in `spm fmri`) or the keyword `batch` to start directly the batch system window, e.g.:

./run_spm8.sh /Applications/MATLAB/MATLAB_Compiler_Runtime/v713/ fmri
./run_spm8.sh /Applications/MATLAB/MATLAB_Compiler_Runtime/v713/ batch

Furthermore, `batch` followed by a batch filename (*.mat or *.m) will start SPM, execute the batch and quit:

./run_spm8.sh /Applications/MATLAB/MATLAB_Compiler_Runtime/v713/ batch mybatch.mat

You can create a shortcut on your Desktop that already contains one of these arguments for a faster launch.

On Linux, for achieving menu entries, you can install an appropriate .desktop file and an icon file for SPM. For example (SPM12b), save the following as spm12b.desktop (modify according to your needs/MCR version):

 [Desktop Entry]
 Name=spm12b
 GenericName=SPM12b
 Comment=Statistical Parametric Mapping
 Exec=/usr/local/SPM/spm12b/run_spm12b.sh /usr/local/MATLAB/MATLAB_Compiler_Runtime/v717
 Icon=spm
 Terminal=false
 Type=Application
 Categories=Education;Science;

Additionally get the spm icon from http://www.fil.ion.ucl.ac.uk/spm/favicon.ico and convert it to an png file, name it spm.png (this is the one referred to in the .desktop file as icon).

Then (package xdg-utils required) execute in a terminal:

 xdg-desktop-menu install --novendor spm12b.desktop
 xdg-icon-resource install --novendor --size 32 spm.png

To deinstall desktop and icon file run

 xdg-icon-resource uninstall --size 32 spm
 xdg-desktop-menu uninstall spm12b.desktop

Trouble-shooting[edit]

  • Why do I receive an error regarding missing mclmcrrt7x.dll ?

The first thing to try is restarting your computer, if you haven't already, since Windows can fail to find this dll even when the path is correctly set if it hasn't been restarted. If you still have problems, see: http://www.mathworks.com/support/solutions/en/data/1-1IW46N/

  • What to do if I get the error "Unable to obtain exclusive lock on CTF directory because of a file access error."?

You need to set variable MCR_INHIBIT_CTF_LOCK to 1, see this.

  • What to do if I get the error "readlink: illegal option -- f" on a Mac?

Change the last line of run_spm8.sh so that it reads:

`dirname $0`/${MACAPP}spm8_${MWE_ARCH} $*
  • How to have the standalone version using a single computational thread?

Version r4667 of the standalone SPM is compiled with the "-R -singleCompThread" flag in mcc so that it will use a single thread at runtime.

Previous version, r4290, was not using this compilation option so you might want to have your MATLAB script to start with maxNumCompThreads(1); to have the same effect.

  • Why do I get a warning "Process manager already initialized -- can't fully enable headless mode." followed by a crash on Mac OS?

Try installing XQuartz (you must logout and back in again after installing XQuartz).

  • What to do if I get the error "Error: libXp.so.6: cannot open shared object file: No such file or directory"?

You need to install the package containing libXp on your Linux platform:

yum install libXp.x86_64
  • What to do if I get the error "This process is attempting to exclude an item from Time Machine by path without administrator privileges. This is not supported."?

Run the standalone as root once, i.e. start the command line with sudo.

Frequently Asked Questions[edit]

  • Will it run faster?

No: http://www.mathworks.com/support/solutions/en/data/1-1ARNS/

  • Is it possible to add other SPM toolboxes?

No: only core SPM toolboxes are available, contributed SPM toolboxes are not present and cannot be added without a whole recompilation.

  • How to compile the SPM standalone by myself?

Have a look at config/spm_make_standalone.m and spm_standalone.m in your SPM installation.

Open MATLAB, at the command line, addpath the spm directory (if not done already), goto the config subdirectory, and run spm_make_standalone. You will need to wait some minutes. Matlab needs either the Signal Processing Toolbox installed, or in spm_make_standalone.m the line with '-N','-p',fullfile(matlabroot,'toolbox','signal') needs to be deleted.

Documentation[edit]

The MATLAB Compiler Toolbox presentation:

The MATLAB Compiler Toolbox documentation:

The MATLAB Compiler Support page: