The way that the matrices work is a bit different from the principles
suggested in your email. The idea is to align the images so that SPM
considers them all to be in alignment with each other. Suppose you have the
following, where A, B and C are all aligned with each other (as shown using
Check Reg):
A = spm_vol('A.img');
B = spm_vol('B.img');
C = spm_vol('C.img');
Then to map from voxels in A to voxels in B, you would use the matrix that
maps from voxels in A, to real-world coordinates, and then from real-world
coordinates to voxels in B:
inv(B.mat) * A.mat
or:
B.mat\A.mat
So, if you have some voxel indices i, j and k for the image A, these would
correspond to the following indices in B:
ijk = B.mat\A.mat*[i; j; k; 1];
disp(ijk(1:3)')
Note that the order of the multiplications is from right to left, and the
steps can be broken down into:
xyz = A.mat*[i; j; k; 1];
ijk = B.mat*xyz;
disp(ijk(1:3)')
or as:
M = B.mat\A.mat
ijk = M*[i; j; k; 1];
disp(ijk(1:3)')
To map from voxels in B to voxels in A, you would use:
A.mat\B.mat
Similarly, to map from voxels in C to voxels in A, you would use:
A.mat\C.mat
By now, you may be getting the picture.
If you are sequentially aligning images together, then you may need to make
use of the "other" files. Here are some examples that should (in principle)
work:
--- Example 1 ---
In this example, both B and C are moved into alignment with A.
1st coreg
source image: B <- moved to align with A
reference image: A
other images: none
2nd coreg
source image: C <- moved to align with A
reference image: A
other images: none <- no need for any "other" image to be moved.
--- example 2 ---
In this example, B and A are first aligned. Then A is aligned with C, so B
also needs to be moved with it.
1st coreg
source image: B
reference image: A
other images: none
2nd coreg
source image: A <- This image gets moved, so you need to move B with it
reference image: C
other images: B <- B is in alignment with A, so you move it when you move A.
Best regards,
-John
On Thursday 22 January 2009 18:13, Joel Dunn wrote:
> Hi,
> How can I calculate SPM transform matrices after successive realignments?
> E.g. I have 3 images, A B & C.
>
> where V=spm_vol(image);
>
> If I know the V.mat when C is realigned to B and B realigned to A, what is
> the V.mat to map C to A?
>
> Sounds simple but so am I.
> Joel
|