Hi Darren,
I don't have any experience of the talairach.xfm files, though Doug
Greve in Boston has been looking at freesurfer/fsl conversions for
transformations, so he would have a very good idea.
As for the flirt conventions, I've emailed details on these before
and I've included one of these responses below which should help.
Your interpretation of the 4x4 affine matrix isn't quite right though.
The right hand column are the translations, but the rotations, scalings
and skews are *all* in the upper left 3x3 part - thoroughly mixed
together. To separate them you can run avscale, but this isn't a
unique decomposition as there are so many choices of convention.
Also, FSL does not interpret left or right. It just orders its
coordinates based on the order they appear in the .img file.
For calculating Talaraich coords it does use negative voxel dimension
info (see second reply below). Note that reslicing/transforming an
image does not require Talaraich coords - only voxel or mm coords
to be used, hence it is only the few components of FSL that deal
in Talaraich coords (e.g. img2talcoord) that ever do anything
beyond our standard mm coord system which is totally driven from
the data ordering.
You might also find that slices is useful as it will always display the
images as they are ordered in the data too - hence this is useful
for actually figuring out how our conventions might relate to those
that you see from other display programs which do worry about
left and right designations as well as the data order.
Hope this helps.
All the best,
Mark
-----------------
.. on flirt matrices ...
The coordinates that flirt uses are not defined with respect to anatomy
but with respect to data storage block. That is, when going through
the data block byte by byte, the coordinates are: (0,0,0) then (1,0,0)
then (2,0,0) then ... then (0,1,0) then (1,1,0) then ... (0,0,1) then
(1,0,1) then ... etc.
So, the position in the data block of a voxel coordinate (x,y,z) is
given
by (x + N_x * (y + N_y * z)) where (N_x,N_y,N_z) are the number of
voxels in the x, y and z directions. Note that x is always in the
range 0 to (N_x - 1), and similarly for y and z.
Consequently, the orientation of the axes with respect to the anatomy
depends on the type of scanning and reslicing that's been done (e.g.
axial or coronal or sagittal acquistions)
This defines the *voxel* coordinate conventions.
However, the matrices always use mm coordinates.
These are defined as the voxel coordinates multiplied by the voxel
dimensions.
For example, if the voxel coordinate of interest was (30,20,10) and
the voxel dimensions were (4,4,6) mm then the mm coordinate would be
(120,80,60) mm. FLIRT uses mm coordinates in all images so that the
voxel dimensions and FOV do not need to be stored in the transformation
matrix.
So, a flirt matrix represents the transformation:
new mm coordinates = matrix * old mm coordinates
where each coordinate is represented by as a standard homogeneous
coordinate column vector (i.e. [ x_mm y_mm z_mm 1 ]' )
---------------------
... and on negative voxel dimensions ...
Slices and flirt and FSL in general *do not care* whether the voxel dim is
positive or negative. They effectively always treat them as positive.
The only bit of FSL that ever uses this information is when converting
voxel coordinates (or internal flirt mm coords) to Talaraich coordinates
where the negative signs are used, together with the origins (which are
also otherwise ignored).
All the results seem to be consistent with this. Whether the output
image from flirt has a negative dim or not is totally dependent on
the reference image, since the sizes and dims are just copied from
this image (i.e. the output is a clone of the reference image but
with the intensities within it changed - to those of the tranformed
input image).
We could, of course, have decided to never save negative dims but just
make a specific vox -> Tal coord conversion that relied on certain
fixed conventions for the image. However, I think we went with negative
dims in order to maintain compliance with MEDx - especially with
respect to the display of images - as this was our principle viewing
platform.
Personally, I wish no-one (including minc format) ever used negative
voxel dims - the world would be a better place without them! Still, I
think there are bigger problems out there than this too. :)
-----------------
Darren Weber wrote:
> Dear Steve, Mark, et al,
>
> I'm trying to obtain Talairach coordinates for freesurfer using FSL/FLIRT
> registration. It may be easy to convert a .mat file to the freesurfer
> talairach.xfm file (a simple format conversion), but I would appreciate
> consideration and any comments on the process described below, as there are
> some steps involved in doing the registration.
>
> In freesurfer, when starting tksurfer, it tries to read the file:
>
> subject/mri/transforms/talairach.xfm
>
> so it can display the normalized coordinates for a given vertex location.
> I'm trying to create this file via FSL/FLIRT (as it is more convenient than
> SPM because I don't have matlab licence under linux).
>
> I've used the FSL/FLIRT tool under linux to generate a .mat registration
> file. These files are not matlab binary data files (as in SPM), they are
> ascii files that contain the 4x4 spatial transform matrix (I think the top
> left 3x3 is the rotations and the right most 3x1 is the translations, while
> the bottom row is shears and scaling).
>
> In my case, I'm registering a T1 analyze volume with the MNI
> avg152T1_brain.img template in the FSL distribution. The T1 analyze file
> was created from original GE files that were converted to analyze (axial,
> LAS) and then converted to COR files (coronal, RAS) with:
>
> mri_convert -iid -1 0 0 -ijd 0 1 0 -ikd 0 0 1 orig.img orig
>
> Note the iid is flipped in X, as I think freesurfer displays use RAS
> (neurological), while Analyze is LAS (radiological). I'm not entirely sure
> about this step. I've checked the orig volume in tkmedit by display of the
> axes, which show the R arrow pointing toward the left, so I think this is
> correct. Any comments on this are appreciated.
>
> At this stage, the volume has been effectively resliced from the original
> dimensions into a coronal 256x256x256 and 1mm^3 voxels (the COR volume).
>
> To ensure the registration uses the same dimensions as the COR volume, I
> convert the COR volume back into analyze (now 256x256x256 1mm^3 voxels)
> using:
>
> mri_convert -oid -1 0 0 -ojd 0 1 0 -okd 0 0 1 orig orig.img
>
> Note the oid is flipped back to LAS, again. Using the FSL tool 'slices
> orig.img' it appears to be correctly oriented (LAS).
>
> Then I applied FSL/FLIRT registration to this volume to generate a .mat
> file. Have you had any experience in generating a freesurfer talairach.xfm
> (or similar) files from these .mat files?
>
>
> Best regards, Darren
>
>
> --
> Darren Weber, PhD Student
> Cognitive Neuroscience, School of Psychology
> Flinders University of SA, GPO Box 2100, Adelaide, SA 5001, Aust.
> Ph: (61 8) 8201 3998, Fax: (61 8) 8201 3877
> http://brain.mhri.edu.au/~dlw/homepages/index.html
>
>
|