SPM/Installation on 64bit Mac OS (Intel)
The SPM Wikibooks moved to https://www.fil.ion.ucl.ac.uk/spm/docs/ |
Preamble
editIf you use drag-and-drop in Finder to install the updates, it will actually perform a folder copy and not a folder merge so that updated files will be overwritten but unchanged old files will be deleted (see this thread). Using the command line option as described below will overcome this.
SPM12
editMac Intel with 64bit MATLAB is a supported SPM12 platform. Precompiled MEX files (*.mexmaci64) are included in the SPM distribution.
Installation
editDownload spm12.zip and its updates spm12_updates_rxxxx.zip in your home directory then type the following in a Terminal:
cd /Users/login unzip spm12.zip unzip -o spm12_updates_rxxxx.zip -d spm12
Start MATLAB and add SPM into your path, either using File > Set Path > Add Folder... or typing
addpath /Users/login/spm12 savepath
in MATLAB's workspace.
Compilation
editIf you are using macOS Catalina, Big Sur, Monterey or Ventura, try this first: fix for MEX files on recent macOS as you shouldn't need to recompile the MEX files.
Should you want to compile SPM MEX files, you need to have Apple's development environment Xcode installed.
You also need to have the mex executable in your system path. To do so, type the following in a Terminal:
export PATH=/Applications/MATLAB_R2017a.app/bin:$PATH
with the appropriate path where MATLAB is installed
Then, in a Terminal, from the src folder of your SPM12 installation, type:
cd /Users/login/spm12/src make distclean make && make install make external-distclean make external && make external-install
If you get errors such as Bad : modifier in $ (/), this is because the instructions are given for a bash Terminal while you are using a tcsh Terminal. The equivalent commands are:
setenv PATH /Applications/MATLAB_R2017a.app/bin:${PATH}
If you get errors such as xcrun: error: SDK "macosx10.14.1" cannot be located while compiling, execute the following:
sudo xcode-select --switch /Applications/Xcode.app/
SPM8
editMac Intel with 64bit MATLAB (available since R2009b) is a supported SPM8 platform. Precompiled MEX files (*.mexmaci64) are included in the SPM distribution.
Installation
editDownload spm8.zip and its updates spm8_updates_rxxxx.zip in your home directory then type the following in a Terminal:
cd /Users/login unzip spm8.zip unzip -o spm8_updates_rxxxx.zip -d spm8
Start MATLAB and add SPM into your path, either using File > Set Path > Add Folder... or typing
addpath /Users/login/spm8
in MATLAB's workspace.
Compilation
editShould you want to compile SPM MEX files, you need to have Apple's development environment Xcode installed. It should be available on your Mac OS X installation DVD.
You also need to have the mex executable in your system path. To do so, type the following in a Terminal:
export PATH=/Applications/MATLAB_R2009a.app/bin:$PATH
with the appropriate path where MATLAB is installed
Then, in a Terminal, from the src folder of your SPM8 installation, type:
cd /Users/login/spm8/src export MACI64=1 make distclean make && make install make toolbox-distclean make toolbox && make toolbox-install make external-distclean make external && make external-install
If you get errors such as Bad : modifier in $ (/), this is because the instructions are given for a bash Terminal while you are using a tcsh Terminal. The equivalent commands are:
setenv PATH /Applications/MATLAB_R2009a.app/bin:${PATH} setenv MACI64 1
SPM5
editPrecompiled MEX files for Mac Intel with 64bit MATLAB (*.mexmaci64) are available in the latest update.
Installation
editDownload spm5.zip in your home directory then type the following in a Terminal:
cd /Users/login unzip spm5.zip
Start MATLAB and add SPM into your path, either using File > Set Path > Add Folder... or typing
addpath /Users/login/spm5
in MATLAB's workspace.
Compilation
editIf you want to compile SPM5 MEX files by yourself, you need to have Xcode installed and mex in your system path (see SPM8 for details).
Then, in a Terminal, from the src folder of your SPM5 installation, type:
cd /Users/login/spm5/src export MACI64=1 make distclean make && make install
SPM2
editThere are no plans to provide SPM2 64bit MEX files for Mac Intel.
Troubleshooting
editmacOS Catalina, Big Sur, Monterey, Ventura
editIf you have issues with MEX files on macOS (""*.mexmaci64" cannot be opened because the developer cannot be verified. macOS cannot verify that this app is free from malware" or "Code signature not valid for use in process using Library Validation: library load disallowed by system policy"), open a Terminal, cd to the SPM directory and type:
find . -name "*.mexmaci64" -exec xattr -d com.apple.quarantine {} \;
If It doesn't work, please try this equivalent alternative, replacing SPM_PATH with the path of your SPM installation:
sudo xattr -r -d com.apple.quarantine SPM_PATH sudo find SPM_PATH -name "*.mexmaci64" -exec spctl --add {} \;
Java Exception and abrupt exit on Mac OS X version 10.10 Yosemite
editIf you get MATLAB issues with Yosemite, see the following bug report for a patch:
http://www.mathworks.com/support/bugreports/1098655
"This is pdfTeX, Version ..." error
editIf you get an error message such as:
mex -O -c spm_vol_utils.c -DSPM_UNSIGNED_CHAR mex: unrecognized option `-O' mex: unrecognized option `-c' This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011) restricted \write18 enabled. entering extended mode (./spm_vol_utils.c This is MeX Version 1.05 18 XII 1993 (B. Jackowski & M. Ry\'cko) ! You can't use `macro parameter character #' in vertical mode.
this is due to a conflict between MATLAB mex and a LaTeX command with the same name. Edit src/Makefile.var and mention the full path when referring to MEXBIN
MEXBIN = /Applications/MATLAB_R2012a.app/bin/mex
or change PATH accordingly.
Slowdown when using graphical inputs
editThis seems to happen when a window manager for macOS is installed ( Magnet orTiles), see this.