
P       = spm_select(Inf,'nifti','Select files');
volumes = zeros(size(P,1),1);                % Tissue volumes

for i=1:size(P,1),                           % Loop over images
    Nii  = nifti(deblank(P(i,:)));           % Read file information
    X    = Nii.dat(:,:,:,:,:);               % Read data
    vvol = abs(det(Nii.mat(1:3,1:3)))/100^3; % Voxel volume in litres
    volumes(i) = sum(X(isfinite(X)))*vvol;   % Compute the volume
end

