The Volumes toolbox should help you there, too. However, you will need to
replace the tbxvol_changeSPM.m script from the downloadable version (see
SPM extensions web page) with the attached one.
On Wed, 19 Sep 2007, Dirk den Ouden wrote:
> Hi Zarinah,
>
> I believe this is the error message you get when you have moved your files
> to a different directory than the one you originally made the contrasts in.
> Steve Fix has written a script that fixes all the path references in your
> SPM.mat file, to go with your new/current directory. I'm sure you can get
> this by emailing him directly: <[log in to unmask]>
>
> best, Dirk
>
> ************************************
> Dr. Dirk-Bart den Ouden, Northwestern University
> Aphasia & Neurolinguistics Research Laboratory
> Dept. of Communication Sciences & Disorders
> 2240 Campus Drive, Evanston IL 60208-3066
> Phone (lab): 1-847-467-7591
> ************************************
>
>
>
> %%-----Original Message-----
> %%From: SPM (Statistical Parametric Mapping)
> %%[mailto:[log in to unmask]] On Behalf Of Zarinah Agnew
> %%Sent: Wednesday, September 19, 2007 11:39 AM
> %%To: [log in to unmask]
> %%Subject: [SPM] help!
> %%
> %%Hi all,
> %%
> %%I have carried out a random effects analysis on 22 subjects.
> %%For some reason when I now try to call up my individual
> %%subject data to look at the results through contrast manager
> %%I get this message:
> %%
> %%??? Cant open image file.
> %%
> %%Error in ==> spm_get_data at 41
> %% Y(i,:) = spm_sample_vol(V(i),XYZ(1,:),XYZ(2,:),XYZ(3,:),0);
> %%
> %%Error in ==> spm_getSPM at 530
> %% Z = min(Z,spm_get_data(xCon(i).Vspm,XYZ));
> %%
> %%Error in ==> spm_results_ui at 274
> %% [SPM,xSPM] = spm_getSPM;
> %%
> %%??? Error using ==> [hReg,xSPM,SPM] = spm_results_ui; Cant
> %%open image file.
> %%
> %%??? Error while evaluating uicontrol Callback
> %%
> %%Does anyone know what this means or why this might have
> %%suddenly started appearing? I hope so or I will have to
> %%reanalyse the whole lot..
> %%
> %%Many thanks,
> %%
> %%Zarinah
> %%
> %%Zarinah Agnew
> %%Cognitive Neuroimaging Group
> %%MRC Clinical Sciences Centre
> %%Imperial College London
> %%Hammersmith Hospital Campus
> %%Du Cane Road
> %%London
> %%W12 0NN
> %%
> %%Tel. 0208 38 (33733)
> [log in to unmask]
> %%
> %%www.csc.mrc.ac.uk
> %%
>
--
Volkmar Glauche
-
Department of Neurology [log in to unmask]
Universitaetsklinikum Freiburg Phone 49(0)761-270-5331
Breisacher Str. 64 Fax 49(0)761-270-5416
79106 Freiburg http://fbi.uniklinik-freiburg.de/
function varargout = tbxvol_changeSPM(bch)
% Change path names or byte order of image files in SPM structure
% FORMAT tbxvol_changeSPM(bch)
% ======
% Input arguments:
% bch.srcspm - file name of SPM.mat files to change
% bch.chpaths - which paths to change: one of
% - .dpaths - data files
% - .apaths - analysis files
% - .bpaths - both
% - .npaths - none
% .{d,a,b}paths.oldpath - path component to be replaced OR
% - "auto" automatically determine component
% - "ask" automatically determine component, but ask before
% replacing
% - .{d,a,b}paths.newpath - path component to be inserted OR
% - "auto" automatically determine component
% - "ask" automatically determine component, but ask before
% replacing
% bch.swap - swap byte order code of volume datatypes
%
% For all absolute references in SPM.xY occurences of oldpath are
% replaced by newpath (using Matlab strrep). This will only work if the
% overall structure of the file tree has not changed (i.e. moving an
% entire analysis dir will work, but not renaming each individual
% subject). In addition, byte order information of mapped files can be
% changed without touching other file information (such as scaling,
% dimensions etc).
% The new SPM struct is saved to the original SPM.mat file. A copy of the
% original SPM.mat is kept in the same directory under the filename
% SPM.mat.save.
% Multiple SPM.mat file names can be given, and the same string
% replacement will be done for all of them.
%
% This function is part of the volumes toolbox for SPM5. For general help
% about this toolbox, bug reports, licensing etc. type
% spm_help vgtbx_config_Volumes
% in the matlab command window after the toolbox has been launched.
%_______________________________________________________________________
%
% @(#) $Id: tbxvol_changeSPM.m,v 1.15 2007/03/28 14:22:24 glauche Exp $
rev = '$Revision: 1.15 $';
funcname = 'Change SPM.mat paths';
% function preliminaries
Finter=spm_figure('GetWin','Interactive');
Finter=spm('FigName',funcname,Finter);
SPMid = spm('FnBanner',mfilename,rev);
% function code starts here
load(bch.srcspm{1});
% save a copy
[newp n e v] = fileparts(bch.srcspm{1});
save_cfg=fullfile(newp, [n e '.save' v]);
if spm_matlab_version_chk('7') < 0
save(save_cfg, '-mat', 'SPM');
else
save(save_cfg, '-mat', '-V6', 'SPM');
end;
chpaths = fieldnames(bch.chpaths);
if ~strcmp(chpaths{1},'npaths')
if isfield(SPM,'swd')
oldp = SPM.swd;
else
if iscell(SPM.xY.P)
[oldp n e v] = fileparts(SPM.xY.P{1});
else
[oldp n e v] = fileparts(SPM.xY.P(1,:));
end;
end;
% try to be smart in finding leading path differences
% first, tokenise paths
ot={};
[op ot{end+1}] = fileparts(oldp);
while ~isempty(ot{end})
[op ot{end+1}] = fileparts(op);
end;
ot=ot(1:end-1);
nt={};
[np nt{end+1}] = fileparts(newp);
while ~isempty(nt{end})
[np nt{end+1}] = fileparts(np);
end;
nt=nt(1:end-1);
commp='';
for k=1:min(numel(nt),numel(ot))
if strcmp(nt{k},ot{k})
commp=fullfile(nt{k},commp);
else
break;
end;
end;
oldp = strrep(oldp,commp,'');
newp = strrep(newp,commp,'');
switch bch.chpaths.(chpaths{1}).oldpath
case 'ask',
bch.chpaths.(chpaths{1}).oldpath = spm_input('Replace path component','!+1','s',oldp);
case 'auto',
bch.chpaths.(chpaths{1}).oldpath = oldp;
end;
switch bch.chpaths.(chpaths{1}).newpath
case 'ask',
bch.chpaths.(chpaths{1}).newpath = spm_input('Insert path component','!+1','s',newp);
case 'auto',
bch.chpaths.(chpaths{1}).newpath = newp;
end;
if strcmp(chpaths{1},'dpaths')||strcmp(chpaths{1},'bpaths')
if iscell(SPM.xY.P)
oldP=SPM.xY.P;
else
oldP=cellstr(SPM.xY.P);
end;
for k=1:numel(oldP)
fprintf('Old file name: %s\n', oldP{k});
newP{k}=strrep(oldP{k},bch.chpaths.(chpaths{1}).oldpath,...
bch.chpaths.(chpaths{1}).newpath);
SPM.xY.VY(k).fname=strrep(SPM.xY.VY(k).fname,...
bch.chpaths.(chpaths{1}).oldpath,...
bch.chpaths.(chpaths{1}).newpath);
fprintf('New file name: %s\n', newP{k});
end
if iscell(SPM.xY.P)
SPM.xY.P=newP;
else
SPM.xY.P=char(newP);
end;
end;
if strcmp(chpaths{1},'apaths')||strcmp(chpaths{1},'bpaths')
try
SPM.xVol.VRpv.fname = strrep(SPM.xVol.VRpv.fname, ...
bch.chpaths.(chpaths{1}).oldpath, ...
bch.chpaths.(chpaths{1}).newpath);
end;
for cb = 1:numel(SPM.Vbeta)
try
SPM.Vbeta(cb).fname = strrep(SPM.Vbeta(cb).fname, ...
bch.chpaths.(chpaths{1}).oldpath, ...
bch.chpaths.(chpaths{1}).newpath);
end;
end;
try
SPM.VResMS.fname = strrep(SPM.VResMS.fname, ...
bch.chpaths.(chpaths{1}).oldpath, ...
bch.chpaths.(chpaths{1}).newpath);
end;
try
SPM.xM.VM.fname = strrep(SPM.xM.VM.fname, ...
bch.chpaths.(chpaths{1}).oldpath, ...
bch.chpaths.(chpaths{1}).newpath);
end;
for cc = 1:numel(SPM.xCon)
try
SPM.xCon(cc).Vcon.fname = strrep(SPM.xCon(cc).Vcon.fname, ...
bch.chpaths.(chpaths{1}).oldpath, ...
bch.chpaths.(chpaths{1}).newpath);
end
try
SPM.xCon(cc).Vspm.fname = strrep(SPM.xCon(cc).Vspm.fname, ...
bch.chpaths.(chpaths{1}).oldpath, ...
bch.chpaths.(chpaths{1}).newpath);
end
end;
SPM.swd = strrep(SPM.swd, bch.chpaths.(chpaths{1}).oldpath, ...
bch.chpaths.(chpaths{1}).newpath);
end;
end;
if bch.swap
try
SPM.xVol.VRpv = swaporder(SPM.xVol.VRpv);
end;
try
SPM.Vbeta = swaporder(SPM.Vbeta);
end;
try
SPM.VResMS = swaporder(SPM.VResMS);
end;
try
SPM.xM.VM = swaporder(SPM.xM.VM);
end
try
for cc = 1:numel(SPM.xCon)
try
SPM.xCon(cc).Vcon = swaporder(SPM.xCon(cc).Vcon);
end;
try
SPM.xCon(cc).Vspm = swaporder(SPM.xCon(cc).Vspm);
end;
end;
end;
for k = 1:numel(SPM.xY.VY)
SPM.xY.VY(k) = swaporder(SPM.xY.VY(k));
end;
end;
if spm_matlab_version_chk('7') < 0
save(bch.srcspm{1},'SPM','-append');
else
save(bch.srcspm{1},'SPM','-append','-V6');
end;
function Vo=swaporder(V)
Vo=V;
for k=1:numel(V)
if isfield(Vo,'dt')
Vo.dt(2) = ~Vo.dt(2);
else
warning(['File %s:\n Pre-SPM5-style SPM.mat. No byte ' ...
'swapping applied.\n'], Vo.fname);
end;
end;
|