John, Benjamin, and SPMers:
Thanks again for your help. John, apologies for being so opaque about
the origins of this script. John wrote and posted a version of
reslice.m on the listerv, last dated Jan 14 2004 see
(http://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind04&L=SPM&P=R9647&I=-3)
with a link to (http://www.sph.umich.edu/~nichols/JG/reslice.m) where
the code actually is located.
At Ben's suggestion I removed the end; at line 25 column 31 after V0 =
spm_create_image(V0); which fixes one of the error messages.
But after rerunning the script in SPM2, a new error message appears and
one persists.
??? Error using ==> run
Input argument "PI" is undefined.
Error in ==> spm at 1276
evalin('base',CBs{v-1})
Suggestions?
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
----- Original Message -----
From: John Ashburner <[log in to unmask]>
Date: Wednesday, September 21, 2005 6:05 am
Subject: Re: [SPM] reslice.m
> The file reslice.m isn't an official part of SPM2, so I can't
> really say any
> more. Who wrote it? Was it me, and if so do you remember when?
> I've
> probably written loads of functions called reslice.m, so I
> wouldn't remember
> this particular one. If it is a small function, then the
> following link may
> help: http://www.mathworks.co
>
> Best regards,
> -John
>
> On Tuesday 20 September 2005 23:14, Robert McClure wrote:
> > 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);
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;
|