Hi Joe,
First up, just noticed a typo, sorry,
>> E.g. something like:
>> xyz1 = [x y z 1]'; % -- voxel (homogeneous)
>> coords, image 1
>> XYZ1 = vol1.mat*[xyz1 1];
should be just:
>> XYZ1 = vol1.mat*xyz1;
>> % -- world coords (in both *registered* images)
>> xyz2 = vol2.mat\XYZ1; % voxel coords, image 2
> The first solution in rigid/affine transformation:
> say, I've got a sn.mat from coreg. Then I should apply
> the following: [x y z 1] / Affine. Where Afffine is
> the affine transformation parameter matrix. Am I
> right?
No, SPM uses a pre-multiplication convention (the affine matrix has
fourth *row* as [0 0 0 1]), so the homogeneous coordinates should be
in column vectors appearing on the right of the matrices, as in my
code example. Perhaps I've misunderstood what you want to do... but if
you want to go from voxel coordinates in one image to corresponding
affine-registered voxel coordinates in the other, then my code snippet
should do this.
> In case of normalisation, from the two links you gave
> me:
> with sn.mat from normalisation, all I can do to look
> at a few voxels in the registered image for
> coordinates reading ( manual ). Is it right?
No, you don't need to do anything manually/by-eye. By converting the
sn.mat into a deformation field, you can get, for each voxel in the
target, the non-linearly registered world-coordinates (equivalently
the world-coordinates for the source image), which you can then map
back to voxel coordinates in the source image using the inverse of the
source affine transform. Does that make sense?
Maybe I should just code up something to do this, instead of trying to
explain it... I assume a function along the lines of
[XYZ_trg_mm XYZ_src_mm XYZ_src_vx] =
coordmap(XYZ_trg_vx, trg, src, xfrm)
where xfrm could be nothing (src and trg affine registered), or an
sn.mat or an HDW y_ deformation field, would fit the bill? Would
anyone else find this useful?
Best,
Ged.
|