Hello,
There are two separate issues involved.
First, it's best to separate the directories where the update *.m files
are located, to avoid conflicts among the filenames.
Second, each version (SPM2 or SPM5) builds a list of paths following
spm2/ or, what is the same, following spm5/ (you can check this very
easily typing path at the matlab command prompt). When I didn't clean
these paths, I lost functionality without error reports.
One solution is to use the path(pathdef) function to restore the matlab
default paths and rebuild the spm paths each time you call spm2 or spm5.
Below is a matlab function which does that. I annotated it with comments
and it is self-explanatory. I have run a basic dataset (pre-processing
and activation on a single session) in both spm5 and spm2 and it seems to
be a clean solution and to work without a problem. I haven't tested group
processing yet, though.
The function is called from the matlab prompt with either
choose_spm_version('spm2') or choose_spm_version('spm5'), and you have
full interactive use of either version. Of course, they cannot be used
concurrently from the same MATLAB session but I think if you open a second
MATLAB session you wouldn't have a problem running the other SPM version.
function choose_spm_version(str)
if str=='spm2'
path(pathdef) ; % get default matlab paths
startup % get my own extra paths in startup.m
addpath( genpath([ 'C:\MATLAB6p5p1\work\spm2' ] ) );
addpath( genpath([ 'C:\MATLAB6p5p1\work\spm2\spm2_updates' ] ));
end;
if str=='spm5'
path(pathdef) ; % get default matlab paths
startup % get my own extra paths in startup.m
addpath( genpath([ 'C:\MATLAB6p5p1\work\spm5' ] ) );
addpath( genpath([ 'C:\MATLAB6p5p1\work\spm5\spm5_updates_411' ] ));
end;
rehash path % not necessary but too old to change programming habits
--------------------------------------------------------
> Hi Sophie,
>
>> I have SPM2 installed and it runs like lightening on my WinXP (matlab 6.5)
>
> Congrats :)
>
>> I have also installed SPM5 but have problems activating it, I have to
go
>> into
>> the SPM5 directory and then run it from there, then SPM5 isn't happy
accessing
>> my files, doesn't like running from results directories etc....
>
>
> That is because it does not find necessary files. In order for it to do
so you should add the spm5-directory to the Matlab-path (you can use
addpath, or, if you're lazy like me, the GUI: Edit, set Path...). The
problem is that now, spm2 will be unhappy :(
>
>> I'm thinking of purchasing Matlab 7.0 and putting SPM5 under that
version, just
>> to keep them separate.
>> Is this a good idea?
>
> Well, you could do that, but it is much easier if you just do the
following:
> remove all spm-traces from the path
> save (to pathdef.m)
> make a copy of this file (back.m or so)
> add spm5 with subdirectories to the path
> save (to pathdef.m)
> make a copy of this file and call it path5.m (or so)
> Quit Matlab
> rename back.m to pathdef.m
> Restart Matlab
> add spm2 with subdirectories to the path
> save (to pathdef.m)
> make a copy of this file and call it path2.m (or so)
>
> Now you have two separate path definitions for each version, and if you
then use a batch file each for starting Matlab as the one below, you
will be happy ever after (or at least your spm-versions will :)
>
> Best,
> Marko
>
> - Begin batch file
> @ECHO OFF
> echo.
> echo Starting SPM2...
> echo.
>
> IF EXIST C:\Util\Matlab\toolbox\local\pathdef.m del /q
> C:\Util\Matlab\toolbox\local\pathdef.m
> COPY C:\Util\Matlab\toolbox\local\path2.m
> C:\Util\Matlab\toolbox\local\pathdef.m
>
> C:
> cd..
> cd..
> cd..
> cd Util
> cd Matlab
> cd work
>
> rem This also starts Matlab with below normal priority and diables Java
start /BELOWNORMAL C:\Util\Matlab\bin\win32\matlab.exe -nojvm
>
> exit /B
> exit
> - End batch file
>
>> ps. The SPM5 manual is one of the most beautiful things I've ever seen!!!!
>
> PS: If this is true you should definitely spend less time in the lab :) --
> =====================================================================
Marko Wilke (Dr.med./M.D.)
> [log in to unmask]
>
> Universitäts-Kinderklinik University Children's Hospital
Abt. III (Neuropädiatrie) Dept. III (Pediatric neurology)
> Hoppe-Seyler-Str. 1, D - 72076 Tübingen
> Tel.: (+49) 07071 29-83416 Fax: (+49) 07071 29-5473
=====================================================================
>
>
>
|