>> For more general matrices, I think I've seen both of the following in
>> various places (I'm not sure which is correct -- they do seem to
>> differ for arbitrary matrices... any comments John?):
>> vox = sqrt(sum(V.mat(1:3,1:3).^2))
Having looked at this more, I think the above is only correct for 9dof
matrices (that contain no shear/skew). For general 12dof affine
matrices, I think the second form I suggested, using spm_imatrix, must
be used.
To illustrate this, try the following, where the voxel dims should be
[1 2 3], and hence the voxel volume should be 6:
M = spm_matrix([1 2 3 1 2 3 1 2 3]), det(M)
sqrt(sum(M(1:3,1:3).^2)), prod(ans)
subsref(spm_imatrix(M), substruct('()', {7:9})), prod(ans)
M = spm_matrix([1 2 3 1 2 3 1 2 3 1 2 3]), det(M)
sqrt(sum(M(1:3,1:3).^2)), prod(ans)
subsref(spm_imatrix(M), substruct('()', {7:9})), prod(ans)
Though, I guess SPM5 mats will be 9dof, since the NIfTI qform can't
represent shears anyway. I'm not sure about SPM2, but had the
impression that the mats might be 12 dof...
Best,
Ged.
|