> I have 4D (3D + time) image in analyze format (as a single file, like a Big
> Mac burger) and need to create 3D images. Suppose you have 5-slice volume
> images taken 10 times over time, that is 50 slices of image. I'm getting
> from MRI a single *.img and header file and need to divide the stack of
> images into 10 volume images. Is there anyone who has done similar work
> using matlab? What about the header files? I'll appreciate your help.
I think that copying and pasting the following code should work.
Regards,
-John
_______________________________________________________________________
VI=spm_vol(spm_get(1,'*.img'));
n = 10; % Number of volumes to generate..
D = zeros([VI.dim(1:2) VI.dim(3)/n]);
for i=1:n,
VO = VI;
VO.fname = sprintf('%s_%.3d.img',spm_str_manip(VI.fname,'r'));
VO.dim(3) = floor(VI.dim(3)/n);
for j=1:floor(VI.dim(3)/n),
pl = (i-1)*floor(VI.dim(3)/n)+j;
D(:,:,j) = spm_slice_vol(VI,spm_matrix([0 0 pl]),VO.dim(1:2),1);
end;
spm_write_vol(VO,D);
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|