Differences between revisions 1 and 32 (spanning 31 versions)
Revision 1 as of 2004-07-30 11:00:45
Size: 4414
Editor: DavidTuch
Comment: Added coordinate system entry from TosasFaq
Revision 32 as of 2012-06-07 12:11:39
Size: 6642
Editor: tanha
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Coordinate systems =
{{{
Freesurfer uses at least 4 voxel coordinate systems and 4 "RAS" coordinate systems.
[[FreeSurferWiki|top]]
Line 5: Line 3:
0. Stored in volume file
     original volume ========> RAS ("scanner RAS", c_(r,a,s)!=0 in general)
          | |
          | 1. calculated | identity
          | |
          V 2. calculated V
   conformed volume ========> RAS (to have the same c_(r,a,s) as above)
      L^3 with S mm voxel |
          | |
          | identity | 3. calculated (translation)
          | |
          V 4. fixed(standard) V
   conformed volume ========> SurfaceRAS with c_(r,a,s) = 0
      L^3 with S mm voxel
= FreeSurfer Coordinate Systems =

The "official" FreeSurfer Coordinate definitions can be found in the following power-points slides ('''SEE THESE FIRST'''):

 * '''[[attachment:fscoordinates.ppt|FS Coordinates (PowerPoint)|&do=get]]'''

or PDF:

 * '''[[attachment:fscoordinates.pdf|FS Coordinates (PDF)|&do=get]]'''

This also includes a little intro to Affine Transformations.

See also: '''[[attachment:vox2ras.pdf|VOX2RAS(PDF)|&do=get]]'''

== Transformations between Freesurfer Surfaces and TrackVis ==
 * FreeSurferTrackVisTransforms
'''Also see:''' [[http://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferTrackVisTransforms|TrackVis Transforms]] '''<--- !!!'''

== Use Cases ==

Below are several cases in which someone has a coordinate in one coordinate system and wants to transform it to some other coordinate system (eg, a point on the surface to MNI305 space). Each computation shows the matrices needed and how to get them as well as a check using tkmedit/tksurfer. The equations are based on those in '''[[attachment:fscoordinates.ppt|FS Coordinates (PowerPoint)|&do=get]]'''. CRS is column-row-slice. RAS is right-anterior-superior.

The checks assume you have run tkmedit and tksurfer in the following way:

tkmedit subject orig.mgz -reg register.dat -ov mov.nii -surfs

tksurfer subject lh inflated -reg register.dat -ov mov.nii

Note on Talairach: FreeSurfer does not report true "Talairach" coordinates. The coordinates listed unter "Talairach" are actually based on Matthew Brett's 10/8/98 non-linear transform from MNI305 space (see http://www.mrc-cbu.cam.ac.uk/Imaging/mnispace.html). FreeSurfer also reports "Talairach MNI" coordinates. These are MNI305 space.
Line 21: Line 34:
Functional analysis(fMRI) part uses another coordinate system to map from the src volume. == Transforms within a subject's anatomical space ==
Line 23: Line 36:
------------------------------------------------------------------
1. I have a point on the surface and want to compute the CRS for
voxel in the orig.mgz that corresponds to this point:
Line 24: Line 40:
     original volume ========> RAS ("scanner RAS", c_(r,a,s) != 0 in general)
          | |
          | identity | calculated
          V 5. fixed("standard") V
     original volume ========> tkregRAS where c_(r,a,s) = 0
          | |
          | 6. calculated | mri2fmri (registration will give this)
          | |
          V 7. fixed("standard") V
     overlay volume ========> fRAS where c_(r,a,s) = 0
VoxCRS = inv(Torig)*[tkrR tkrA tkrS 1]'
Line 35: Line 42:
All these coordinate systems make it a rather difficult task to trace to the original source volume voxel index from surface or functional index. If you can follow the arrows, you can get the necessary transforms easily. where [tkrR tkrA tkrS] is the "Vertex RAS" as seen in the tksurfer
Tools window (also output of mris_convert). Torig is the Vox2tkrRAS
matrix obtained from "mri_info --vox2ras-tkr orig.mgz" (note: this is
the same for all orig volumes).
Line 37: Line 47:
The transform 2 (CORONAL coordinates) is calculated so that the following equation holds. That is, the direction cosine part is fixed, but not the translation part. In this way, the conformed volume always in the CORONAL orientation. Test: click on a point in tksurfer. Use "Vertex RAS" to compute
Vox2CRS. Round Vox2CRS to the nearest integer. Hit Save Point in
tksurfer. In tkmedit, Goto Saved Point. Compare VoxCRS to "Volume
Index". Note: you may need to use the "Volume RAS" from tkmedit in the
computation above to get an exact match.
Line 39: Line 53:
------------------------------------------------------------------
2. I have an RAS point on the surface (tkrR tkrA tkrS) ("Vertex RAS" from
tksurfer) and want to compute the MNI305 RAS that corresponds to this
point:
Line 40: Line 58:
              [-1 0 0 s1][S 0 0 0][L/2] [c_r] s1 = c_r + S*L/2
              [ 0 0 1 s2][0 S 0 0][L/2] = [c_a] ==> s2 = c_a - S*L/2
       [ 0 -1 0 s3][0 0 S 0][L/2] [c_s] s3 = c_s + S*L/2
              [ 0 0 0 1][0 0 0 1][ 1 ] [ 1 ]
MNI305RAS = TalXFM*Norig*inv(Torig)*[tkrR tkrA tkrS 1]'
  TalXFM: subject/orig/transforms/talairach.xfm
  Norig: mri_info --vox2ras orig.mgz
  Torig: mri_info --vox2ras-tkr orig.mgz
Line 45: Line 63:
where c_(r,a,s) is from the "scanner RAS". This "scanner RAS" has the physical meaning of "Right-Anterior-Superior" directions of the head. Test: click on a point in tksurfer. Use "Vertex RAS" to compute
MNI305RAS. Compare MNI305RAS to "Vertex MNI Talairach". Also, hit Save
Point in tksurfer. In tkmedit, Goto Saved Point, compare MNI305RAS to
"MNI Coordinates". Note: you may need to use the "Volume RAS" from
tkmedit in the computation above to get an exact match.
Line 47: Line 69:
The transform 4 (surfaceRASFromConformedVoxel) is fixed as ------------------------------------------------------------------
3. I have a point on the surface ("Vertex RAS" in tksurfer) and want to
compute the Scanner RAS in orig.mgz that corresponds to this point:
Line 49: Line 73:
ScannerRAS = Norig*inv(Torig)*[tkrR tkrA tkrS 1]'
  Norig: mri_info --vox2ras orig.mgz
  Torig: mri_info --vox2ras-tkr orig.mgz
Line 50: Line 77:
              [-1 0 0 S*L/2][S 0 0 0]
              [ 0 0 1 -S*L/2][0 S 0 0]
       [ 0 -1 0 S*L/2][0 0 S 0]
              [ 0 0 0 1 ][0 0 0 1]
Test: click on a point in tksurfer. Use "Vertex RAS" to compute
ScannerRAS. Save Point. In tkmedit, Goto Saved Point, compare
ScannerRAS to "Volume Scanner Coordinates".
Line 55: Line 81:
The transform 1 (conformedVoxelFromVoxel) is calculated by (in a matrix sense) ----------------------------------------------------------------
4. I have a CRS from a voxel in the orig.mgz volume and want to
compute the RAS in surface space (tkrRAS) for this point:
Line 57: Line 85:
tkrRAS = Torig*[C R S 1]'
  Torig: mri_info --vox2ras-tkr orig.mgz
Line 58: Line 88:
     xform1 = inv(xform2) * xform0 = [1/S 0 0 0][-1 0 0 s1] * xform0
                                      [ 0 1/S 0 0][ 0 0 -1 s3]
          [ 0 0 1/S 0][ 0 1 0 -s2]
                                      [ 0 0 0 1][ 0 0 0 1 ]
Test: click on a point in tkmedit very close to the left hemi white
surface. Use the "Volume index" to compute tkrRAS. Hit "Save Point" in
tkmedit. In tksurfer, Goto Saved Point. Compare tkrRAS to "Vertex
RAS". It might not be exactly the same because you might not have
clicked exactly on a vertex in tkmedit.
Line 63: Line 94:
The transform 3(SurfaceRASFromRAS) is calculated by (in a matrix sense). Note that it is independent of conformed voxel size S and the length L: == Transforms within subject across imaging modalities ==
Line 65: Line 96:
------------------------------------------------------------------
5. I have a point on the surface ("Vertex RAS") and want to compute the CRS for the
corresponding voxel in my functional/diffusion/ASL/rawavg/etc "mov"
volume:
Line 66: Line 101:
     xform3 = xform4 * inv(xform2) = [ 1 0 0 -c_r]
                                     [ 0 1 0 -c_a]
                                     [ 0 0 1 -c_s]
                                     [ 0 0 0 1 ]
movCRS = inv(Tmov)*Reg*[tkrR tkrA tkrS 1]'
  Tmov: mri_info --vox2ras-tkr mov.nii
  Reg: register.dat
     tkregister2 --mov mov.nii --reg register.dat
Line 71: Line 106:
Because of the xform3 (changing only translation part), it is easy to calculate SurfaceRASFromVoxel (xform3*xform0) and is given by Test: click on a point in tksurfer and hit Save Point. Compute movCRS
using the "Vertex RAS". Round movCRS to the nearest integer. In
tkmedit, Goto Saved Point. Compare movCRS to "Functional Overlay
Index Coordinates".
Line 73: Line 111:
--------------------------------------------------------------
6. I have a CRS from a voxel in my functional/diffusion/ASL/rawavg/etc
"mov" volume and want to compute the CRS for the corresponding point in
the orig.mgz:
Line 74: Line 116:
     SurfaceRASFromVoxel = [ 3x3 part (t1 - c_r)]
                           [ same as (t2 - c_a)]
                           [ xform0 (t3 - c_s)]
                           [ 0 1 ]
origCRS = inv(Torig) * Reg * Tmov * [movC movR movS 1]'
  Torig: mri_info --vox2ras-tkr orig.mgz
  Tmov: mri_info --vox2ras-tkr mov.nii
  Reg: register.dat
     tkregister2 --mov mov.nii --reg register.dat
Line 79: Line 122:
where t1,t2,t3 are the translation part of xform0. Test: click on a point in tkmedit very close to the left hemi white
surface. Use the "Functional Overlay Index Coordinates" to compute
origCRS (round to the nearest integer). Compare origCRS to the "Volume
index". Note: you may need to use the "Volume RAS" from tkmedit in
the computation above to get an exact match.
Line 81: Line 128:
The transform 5 and the transform 7 are calculated by the requirement --------------------------------------------------------------
7. I have a CRS from a voxel in my functional/diffusion/ASL/rawavg/etc
"mov" volume and want to compute the tkrRAS for the corresponding
point on the surface:
Line 83: Line 133:
tkrRAS = inv(Reg) * Tmov * [movC movR movS 1]'
  Tmov: mri_info --vox2ras-tkr mov.nii
  Reg: register.dat
     tkregister2 --mov mov.nii --reg register.dat
Line 84: Line 138:
              [-1 0 0 s1][xsize 0 0 0][width/2 ] [0]
              [ 0 0 1 s2][ 0 ysize 0 0][height/2] = [0]
       [ 0 -1 0 s3][ 0 0 zsize 0][depth/2 ] [0]
              [ 0 0 0 1][ 0 0 0 1][ 1 ] [1]

Here the name "RAS" lost the meaning completely. This "RAS" is just to be used for alignment purpose only. The width/height/depth are for the appropriate volume. The reason is that the original volume could be sagittal or horizontal.

}}}
Test: click on a point in tkmedit very close to the left hemi white
surface. Use the "Functional Overlay Index Coordinates" to compute
tkrRAS. Hit "Save Point" in tkmedit. In tksurfer, hit "Goto Saveed
Point". Compare tkrRAS to "Vertex RAS". It might not be exactly the
same because you might not have clicked exactly on a vertex in
tkmedit.

top

FreeSurfer Coordinate Systems

The "official" FreeSurfer Coordinate definitions can be found in the following power-points slides (SEE THESE FIRST):

or PDF:

This also includes a little intro to Affine Transformations.

See also: VOX2RAS(PDF)

Transformations between Freesurfer Surfaces and TrackVis

Also see: TrackVis Transforms <--- !!!

Use Cases

Below are several cases in which someone has a coordinate in one coordinate system and wants to transform it to some other coordinate system (eg, a point on the surface to MNI305 space). Each computation shows the matrices needed and how to get them as well as a check using tkmedit/tksurfer. The equations are based on those in FS Coordinates (PowerPoint). CRS is column-row-slice. RAS is right-anterior-superior.

The checks assume you have run tkmedit and tksurfer in the following way:

tkmedit subject orig.mgz -reg register.dat -ov mov.nii -surfs

tksurfer subject lh inflated -reg register.dat -ov mov.nii

Note on Talairach: FreeSurfer does not report true "Talairach" coordinates. The coordinates listed unter "Talairach" are actually based on Matthew Brett's 10/8/98 non-linear transform from MNI305 space (see http://www.mrc-cbu.cam.ac.uk/Imaging/mnispace.html). FreeSurfer also reports "Talairach MNI" coordinates. These are MNI305 space.

Transforms within a subject's anatomical space


1. I have a point on the surface and want to compute the CRS for voxel in the orig.mgz that corresponds to this point:

VoxCRS = inv(Torig)*[tkrR tkrA tkrS 1]'

where [tkrR tkrA tkrS] is the "Vertex RAS" as seen in the tksurfer Tools window (also output of mris_convert). Torig is the Vox2tkrRAS matrix obtained from "mri_info --vox2ras-tkr orig.mgz" (note: this is the same for all orig volumes).

Test: click on a point in tksurfer. Use "Vertex RAS" to compute Vox2CRS. Round Vox2CRS to the nearest integer. Hit Save Point in tksurfer. In tkmedit, Goto Saved Point. Compare VoxCRS to "Volume Index". Note: you may need to use the "Volume RAS" from tkmedit in the computation above to get an exact match.


2. I have an RAS point on the surface (tkrR tkrA tkrS) ("Vertex RAS" from tksurfer) and want to compute the MNI305 RAS that corresponds to this point:

MNI305RAS = TalXFM*Norig*inv(Torig)*[tkrR tkrA tkrS 1]'

  • TalXFM: subject/orig/transforms/talairach.xfm Norig: mri_info --vox2ras orig.mgz Torig: mri_info --vox2ras-tkr orig.mgz

Test: click on a point in tksurfer. Use "Vertex RAS" to compute MNI305RAS. Compare MNI305RAS to "Vertex MNI Talairach". Also, hit Save Point in tksurfer. In tkmedit, Goto Saved Point, compare MNI305RAS to "MNI Coordinates". Note: you may need to use the "Volume RAS" from tkmedit in the computation above to get an exact match.


3. I have a point on the surface ("Vertex RAS" in tksurfer) and want to compute the Scanner RAS in orig.mgz that corresponds to this point:

ScannerRAS = Norig*inv(Torig)*[tkrR tkrA tkrS 1]'

  • Norig: mri_info --vox2ras orig.mgz Torig: mri_info --vox2ras-tkr orig.mgz

Test: click on a point in tksurfer. Use "Vertex RAS" to compute ScannerRAS. Save Point. In tkmedit, Goto Saved Point, compare ScannerRAS to "Volume Scanner Coordinates".


4. I have a CRS from a voxel in the orig.mgz volume and want to compute the RAS in surface space (tkrRAS) for this point:

tkrRAS = Torig*[C R S 1]'

  • Torig: mri_info --vox2ras-tkr orig.mgz

Test: click on a point in tkmedit very close to the left hemi white surface. Use the "Volume index" to compute tkrRAS. Hit "Save Point" in tkmedit. In tksurfer, Goto Saved Point. Compare tkrRAS to "Vertex RAS". It might not be exactly the same because you might not have clicked exactly on a vertex in tkmedit.

Transforms within subject across imaging modalities


5. I have a point on the surface ("Vertex RAS") and want to compute the CRS for the corresponding voxel in my functional/diffusion/ASL/rawavg/etc "mov" volume:

movCRS = inv(Tmov)*Reg*[tkrR tkrA tkrS 1]'

  • Tmov: mri_info --vox2ras-tkr mov.nii Reg: register.dat
    • tkregister2 --mov mov.nii --reg register.dat

Test: click on a point in tksurfer and hit Save Point. Compute movCRS using the "Vertex RAS". Round movCRS to the nearest integer. In tkmedit, Goto Saved Point. Compare movCRS to "Functional Overlay Index Coordinates".


6. I have a CRS from a voxel in my functional/diffusion/ASL/rawavg/etc "mov" volume and want to compute the CRS for the corresponding point in the orig.mgz:

origCRS = inv(Torig) * Reg * Tmov * [movC movR movS 1]'

  • Torig: mri_info --vox2ras-tkr orig.mgz Tmov: mri_info --vox2ras-tkr mov.nii Reg: register.dat
    • tkregister2 --mov mov.nii --reg register.dat

Test: click on a point in tkmedit very close to the left hemi white surface. Use the "Functional Overlay Index Coordinates" to compute origCRS (round to the nearest integer). Compare origCRS to the "Volume index". Note: you may need to use the "Volume RAS" from tkmedit in the computation above to get an exact match.


7. I have a CRS from a voxel in my functional/diffusion/ASL/rawavg/etc "mov" volume and want to compute the tkrRAS for the corresponding point on the surface:

tkrRAS = inv(Reg) * Tmov * [movC movR movS 1]'

  • Tmov: mri_info --vox2ras-tkr mov.nii Reg: register.dat
    • tkregister2 --mov mov.nii --reg register.dat

Test: click on a point in tkmedit very close to the left hemi white surface. Use the "Functional Overlay Index Coordinates" to compute tkrRAS. Hit "Save Point" in tkmedit. In tksurfer, hit "Goto Saveed Point". Compare tkrRAS to "Vertex RAS". It might not be exactly the same because you might not have clicked exactly on a vertex in tkmedit.

CoordinateSystems (last edited 2019-07-29 17:18:06 by 172)