Many SPMers use different versions of SPM. We can run different versions of SPM in one computer, but we need to set MATLAB path carefully.
I had some discussion with Volkmar Glauche and Guillaume Flandin, who kindly gave me advice how to write the script for running diferrent spms.
Below is the scripts which enables us to run SPM2, SPM5, and SPM8 concurrently.
- make a directory where you want to save scripts. (e.g. ~/spm_paths/)
- add the directory to the path in Matlab. (File -> Set Path -> Add path)
- put spm_rmpath.m in SPM2 folder.
- write scripts to run spm2, spm5, and spm8
- save these scripts in the directory ~/spm_paths/
- In a matlab window, type “spm2″
- In another matlab window, type “spm5″
- In another matlab window, type “spm8″
You find this file in SPM5 or SPM8 directory. You can just copy it from SPM5/8 to SPM2 directory.
suppose your spm2, spm5, and spm8 directories are “/usr/local/spm2″, “/usr/local/spm5″, and “/usr/local/spm8″. (change the pathname to your circumstance)
%%%%%%%%%%%%%%% spm2.m
% remove spm path
while true
try, spm_rmpath; catch break; end
end
% add spm2 path
addpath /usr/local/spm2;
% run spm2
spm;
%%%%%%%%%%%%%%% spm5.m
% remove spm path
while true
try, spm_rmpath; catch break; end
end
% add spm5 path
addpath /usr/local/spm5;
% run spm5
spm;
%%%%%%%%%%%%%%% spm8.m
% remove spm path
while true
try, spm_rmpath; catch break; end
end
% add spm8 path
addpath /usr/local/spm8;
% run spm8
spm;
(Of course you can add any paths you like between “addpath /usr/local/spm/spm2/5/8″
and “spm”)
Now you can run different versions of SPM concurrently.
ピングバック: SPM switcher: Run different versions of SPM in one Matlab