> >V = spm_vol(spm_get(1,'*_seg*.img'));
> > vol = 0;
> > for i=1:V.dim(3),
> > img = spm_slice_vol(V,spm_matrix([0 0 i]),V.dim(1:2),0);
> > vol = vol + sum(img(:));
> > end;
> > fprintf('%g voxels, %g litres\n', vol, vol*det(V.mat(1:3,1:3))*1e-6);
> >
> >but it does work well with all segmented images except the modulated ones
> > in SPM5b.
> >With the modulated segments it does not work and there is no error
> > message. The result is:
> >NaN voxels, NaN litres
Try the following instead...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
P = spm_select(Inf,'image','Select images');
for j=1:size(P,1),
V = spm_vol(deblank(P(j,:)));
vol = 0;
for i=1:V.dim(3),
img = spm_slice_vol(V,spm_matrix([0 0 i]),V.dim(1:2),0);
img = img(finite(img));
vol = vol + sum(img(:));
end;
voxvol = abs(det(V.mat(1:3,1:3)))*1e-6;
fprintf('%g voxels, %g litres\n', vol, vol*voxvol);
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Best regards,
-John
|