> I never used MRIcro for that purpose but it seems quite quick in SPM.
> Use [Y,XYZ]=spm_read_vols(spm_vol(spm_get)) specifying binary mask as input
> to get voxel values in Y.
> Then use length(find(Y)) to get the number of non-zero voxels.
> that number over voxel size will be the volume in mm3
This will only work for binary images. For the results of the SPM
segmentation algorithms (eg GM volumes from c1*, rc1* or mwrc1*), then
paste the following into MATLAB:
P=spm_select(Inf,'nifti');
for i=1:size(P,1),
N=nifti(P(i,:)); % Get a handle to the image
X=N.dat(:,:,:,:,:); % Read all the data into an array
X=X(isfinite(X)); % Avoid possible problems with NaNs
t=sum(X); % Sum up the values
v=abs(det(N.mat(1:3,1:3))); % Volume of a voxel mm^3
fprintf('%g\n', t*v/100^3); % Print volume in litres
end
Best regards,
-John
--
John Ashburner <[log in to unmask]>
|