anna,
flipud only works on 2d matrices:
>> x = rand(3,3,3);
>> flipud(x)
??? Error using ==> flipud
X must be a 2-D matrix.
you'll need to write some different code. in the past i have just read
in planes, flipped them explicity and wrote back out.
aHdr = spm_vol(P(iP,:));
aVol= spm_read_vols(aHdr);
nVol = 0*aVol;
for iz = 1:size(aVol,3)
nVol(:,:,iz) = flipud(aVol(:,:,iz));
end
nHdr = aHdr;
nHdr.fname = 'flipped.img';
spm_write_vol(nHdr,nVol);
change as you need.
Robert
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Robert C. Welsh, PhD
Research Investigator
Department of Radiology
University of Michigan
(734) - 764 - 2412 (fax)
[log in to unmask]
>>> Anna Barnes <[log in to unmask]> 06/16/06 2:22 PM >>>
Dear all
this is a bit lazy of me I know but can someone look at this code
below (I can't remember who wrote it originally, one of the mailbase
users?) and tell me which bit I change to make it flip the image top
to bottom instead of left to right
Cheers
Anna
% FORMAT spm_flip
% flips images from right to left
%
________________________________________________________________________
___
% get images
%-----------------------------------------------------------------------
----
P = spm_get(Inf,'*.img',{'select images for flipping'});
% flip
%-----------------------------------------------------------------------
----
spm_progress_bar('Init',length(P),'flipping','');
for i = 1:length(P)
[p,f,e,v] = fileparts(P{i});
Vi = spm_vol(P{i});
Vo = Vi;
Vo.fname = fullfile(p,['f' f e]);
Vo.descrip = [Vo.descrip ' - flipped'];
Vo = spm_imcalc(Vi,Vo,'flipud(i1)');
% progress
%-------------------------------------------------------------------
spm_progress_bar('Set',i);
end
spm_progress_bar('Clear')
**********************************************************
Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues.
|