Hi,
All you have to do is form the two matrices as I described
before and then pre-multiply the second matrix by the inverse
of the first matrix (you can get the inverse and concatenate -
which is the same as multiplying - by using convert_xfm in
separate calls). Then if you take the resulting matrix and
apply it to the second volume, it should be resampled to
match the first volume.
All the best,
Mark
On 20 Jan 2005, at 15:48, Wang, Liqin wrote:
> Thank you very much, Mark. It's really help.
> Now I have another question.
> Given two 3x3 direction cosine matrices(DCM), which represent two
> separate volumes. If I want to change the second volume to be the same
> coordinate system as the first one by just using the DCM, how could I
> do it?
>
> Thanks,
>
> Liqin
>
> -----Original Message-----
> From: FSL - FMRIB's Software Library
> [SMTP:[log in to unmask]] On Behalf Of Mark Jenkinson
> Sent: Thursday, January 20, 2005 5:26 AM
> To: [log in to unmask]
> Subject: Re: [FSL] direction cosine to affine
> transformation matrix
>
> Hi,
>
> In order to make a flirt matrix which can be used to resample
> the image along the new axes, specified by the direction
> cosines,
> you need to do the following:
>
> 1 - select an origin in voxel coordinates, where coordinates
> start at zero in the first voxel stored in the image
> (normally
> the bottom left of the first slice). It is common,
> but not
> compulsory, to pick the centre of the volume.
> 2 - multiply the coordinates from step 1 by the voxel
> dimensions
> in mm (e.g. the voxels might be 2mm x 2mm x 3mm,
> making a
> coordinate of 2,5,7 become 4,10,21)
> 3 - the coordinate from step 2 must be made negative and put
> in the
> fourth column of the affine matrix
> 4 - the first three columns of the matrix are formed from the
> direction cosines - with all the cosines related to
> the new
> x-axis in the first row, those for the y-axis in the
> second
> row and those for the z-axis in the third row. Don't
> forget
> that this forms the first three columns, with the
> fourth
> column set by step 3.
> 5 - the fourth row needs to be set to 0 0 0 1
>
> That's it - if you do the above and put it in a text file with
> one row per line and one or more spaces between the column
> entries
> then you have a valid flirt affine matrix.
> To test it, use the -applyxfm -init options to flirt in order
> to
> see what the resampled image looks like.
>
> All the best,
> Mark
>
>
> On 19 Jan 2005, at 22:53, Wang, Liqin wrote:
>
>> Hi, Could anyone give me a hint about how to convert a 3x3 direction
>> cosine matrix to affine transformation matrix?
>>
>> Thanks,
>>
>> Liqin Wang
|