I'm not sure how you computed your M from the contents of the rp*.txt,
but I'd guess it was via spm_matrix.m. Without looking through the
code, I can't remember which way round the mapping goes. The contents
of rp*.txt are really only for use for modelling confounds in the
design matrix when you do the statistical tests. For actually
figuring out the mappings, I'd suggest you use the voxel-to-world
mappings in the image headers.
M1=spm_get_space('image1.nii');
M2=spm_get_space('image2.nii');
To map from voxel i1, j1, k1 in image 1 to the corresponding voxel i2,
k2, j2 in image 2, you'd use the following:
M = M2\M1;
ijk2 = M(1:3,:)*[i1, j1, k1, 1]'
If the images have been realigned, each volume should have a different
matrix in its header. Prior to alignment, all these matrices should
be the same. The reference image (the first image selected when you
do realignment, which should not move) should have the same matrix
after realignment. Therefore to assess the amount of movement, you
can compare the matrices after realignment, with the matrix in the
reference image.
Best regards,
-John
On 13 April 2011 08:48, Yuan Wang <[log in to unmask]> wrote:
> Hello,
>
> I am working on an issue which is finding the voxel position before SPM realignment estimate&reslice based on the rigid-body transformation.
>
> I've already calculated the rigid-body transformation matrices for all the time points according to the rp*.txt. The formula which I found was:
>
> (y1,y2,y3,1)'=M*(x1,x2,x3,1)'
>
> M- transformation matrix
> x- voxel position in an image
> y- voxel position in another space
>
> First, I don't know if the x and y here are the vx or mm (we can read both voxel position information from the SPM Graphic).
>
> Second, are there any assumption on this formula? Such as x and y space should have same voxel size or anything else which may affect this formula.
>
> Third, if the y I compute out is the voxel position in the image before SPM (2dseq) or after?
>
> Forth, how does the reslice affect the voxel position? I notise there is a voxel-to-world matrix, should I use that?
>
> I am stucked here.
> Thanks in advance.
>
> Best Regards,
> Yuan Wang
>
|