Hi Anna, Robert,
Robert Welsh wrote:
> flipud only works on 2d matrices:
That's true, but spm_imcalc actually works on a plane-by-plane basis,
so this shouldn't be a problem.
> Vo = spm_imcalc(Vi,Vo,'flipud(i1)');
If this (and Robert's equivalent version) gives a left-right flip,
then I think fliplr instead of flipud should give a superior-inferior
flip. (This might sound a bit odd, but I think it's just that the
Analyze images have first axis as along rows, while Matlab indexes
first down columns).
In the event that you actually want to re-order the slices (i.e.
neither fliplr nor flipud give the "correct" flip), you could adapt
Robert's code to do this, replacing the for-loop with something like:
nz = size(aVol,3);
for iz = 1:nz
nVol(:,:,iz) = flipud(aVol(:,:,nz+1-iz));
end
although, note that a flip in any plane can be given by a flip in any
other plane with a suitable rotation. So you could just use the
original code to flip, and then use "reorient" to rotate as desired.
Best,
Ged.
|