On Thu, 3 May 2007 13:49:54 +0100, Ged Ridgway <[log in to unmask]> wrote:
>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.
Hi, Ged, thanks for prompt reponse. I have more questions:
what is vol1.mat and vol2.mat? after coreg using SPM, all I have is sn.mat,
which upon being opened, shows Affine matrix and a couple of log kind of
structs. Am I missing something here? (using SPM5).
>> 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?
So, the mapping between the two volumes takes two steps:
first, get deformation filed; second, convert that deformation-caused
coodinates back to source volume by inverse affine transform. How do I read
the deform field file? I have loaded into SPM in Display. Then I can read
for each voxel two triplets: mm, and vx and intensity.
plese forgive me if my qustions sound too elementary.
Thanks a lot,
Joe
|