Dear John and SPMers:
I ran into a snafu while using the m-file "reslice.m" in SPM2 (see
attachment from the 2004 listserv). The MATLAB error message reads:
??? Error using ==> run
Error: File: c:\spm2\scripts\reslice.m Line: 25 Column: 31
This statement is not inside any function.
(It follows the END that terminates the definition of the function
"reslice".)
Error in ==> spm at 1276
evalin('base',CBs{v-1})
??? Error while evaluating uicontrol Callback.
Is there a problem with the code ?
thanks in advance,
Rob McClure
Robert K. McClure M.D.
Assistant Professor
Department of Psychiatry
UNC School of Medicine
Room 247, Medical School Wing C
Chapel Hill, NC, 27510-7160, USA
E-mail: [log in to unmask]
Office phone: 919-843-6629
Fax: 919-966-8004
Pager: 919-216-2058
function reslice(PI,PO,dim,mat,hld)
% FORMAT reslice(PI,PO,dim,mat,hld)
% PI - input filename
% PO - output filename
% dim - 1x3 matrix of image dimensions
% mat - 4x4 affine transformation matrix mapping
% from vox to mm (for output image).
% To define M from vox and origin, then
% off = -vox.*origin;
% M = [vox(1) 0 0 off(1)
% 0 vox(2) 0 off(2)
% 0 0 vox(3) off(3)
% 0 0 0 1];
%
% hld - interpolation method.
%___________________________________________________________________________
% %W% John Ashburner %E%
VI = spm_vol(PI);
VO = VI;
VO.fname = deblank(PO);
VO.mat = mat;
VO.dim(1:3) = dim;
VO = spm_create_image(VO); end; for x3 = 1:VO.dim(3),
M = inv(spm_matrix([0 0 -x3 0 0 0 1 1 1])*inv(VO.mat)*VI.mat);
v = spm_slice_vol(VI,M,VO.dim(1:2),hld);
VO = spm_write_plane(VO,v,x3);
end;
|