Differences between revisions 1 and 23 (spanning 22 versions)
Revision 1 as of 2004-07-30 11:00:45
Size: 4414
Editor: DavidTuch
Comment: Added coordinate system entry from TosasFaq
Revision 23 as of 2008-04-29 11:46:13
Size: 10090
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Coordinate systems = [[FreeSurferWiki|top]]

= FreeSurfer Coordinate Systems =

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

 * '''[[attachment:fscoordinates.ppt]]'''

or PDF:

 * '''[[attachment:fscoordinates.pdf]]'''

This also includes a little intro to Affine Transformations.

See also: '''[[attachment:vox2ras.pdf]]'''

== 1.0 Coordinate System Overview Disclaimer: The stuff below may or may not be correct. ==

'''''Disclaimer:''''' The stuff below may or may not be correct.Use the info above instead.

Freesurfer uses at least 4 voxel coordinate systems and 4 "RAS" coordinate systems.
Line 3: Line 23:
Freesurfer uses at least 4 voxel coordinate systems and 4 "RAS" coordinate systems.

0. Stored in volume file
0. Stored in volume file
Line 12: Line 30:
      L^3 with S mm voxel |    L^3 with S mm voxel |
Line 18: Line 36:
      L^3 with S mm voxel                       L^3 with S mm voxel
}}}
Line 20: Line 39:
The functional analysis stream uses another coordinate system to map from the src volume.
Line 21: Line 41:
Functional analysis(fMRI) part uses another coordinate system to map from the src volume.


     original volume ========> RAS ("scanner RAS", c_(r,a,s) != 0 in general)    
{{{
     original volume ========> RAS ("scanner RAS", c_(r,a,s) != 0 in general)
Line 28: Line 46:
     original volume ========> tkregRAS where c_(r,a,s) = 0       original volume ========> tkregRAS where c_(r,a,s) = 0
Line 32: Line 50:
          V 7. fixed("standard") V                                   V 7. fixed("standard") V
Line 34: Line 52:
}}}
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.
Line 35: Line 55:
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. 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.
Line 37: Line 57:
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.

{{{
Line 44: Line 62:
}}}
Line 47: Line 65:
The transform 4 (surfaceRASFromConformedVoxel) is fixed as The transform 4 (surface``RAS``From``Conformed``Voxel) is fixed as
Line 49: Line 67:
{{{
Line 54: Line 72:
}}}
Line 55: Line 74:
The transform 1 (conformedVoxelFromVoxel) is calculated by (in a matrix sense) The transform 1 (conformed``Voxel``From``Voxel) is calculated by (in a matrix sense)
Line 57: Line 76:
{{{
     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 ]
}}}
The transform 3(Surface``RAS``From``RAS) is calculated by (in a matrix sense). Note that it is independent of conformed voxel size S and the length L:
Line 58: Line 84:
     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 ]

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:

{{{
Line 70: Line 89:
}}}
Because of the xform3 (changing only translation part), it is easy to calculate Surface``RAS``From``Voxel (xform3*xform0) and is given by
Line 71: Line 92:
Because of the xform3 (changing only translation part), it is easy to calculate SurfaceRASFromVoxel (xform3*xform0) and is given by

{{{
Line 78: Line 97:
}}}
where t1,t2,t3 are the translation part of xform0.
Line 79: Line 100:
where t1,t2,t3 are the translation part of xform0. The transform 5 and the transform 7 are calculated by the requirement
Line 81: Line 102:
The transform 5 and the transform 7 are calculated by the requirement

{{{
Line 88: Line 107:
}}}
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.
Line 89: Line 110:
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. == 2.0 Relationship between lores and hires surfaceRAS ==
{{{
                conformed vol -------------> surfRAS
                          | |
                          | | surfRASToRAS
                          V V
                 high res ------------> RAS
                          | |
                          | | Xfm
                          V V
                 low res ------------> RAS
                          | |
                          | | RASToSurfRAS
                          V V
                conformed vol -------------> surfRAS
}}}
Therefore, the map from the high res surfaceRAS to the low res surfaceRAS is given by
Line 91: Line 128:
{{{
     highresSurfRASTolowresSurfRAS = RASTosurfRAS(lowres) * Xfm * sufRASToRAS(highres)
Line 92: Line 131:
which is not equal to Xfm. In fact,

{{{
       RASTosurfRAS(lowres) = 1 0 0 -c_r(lowres) surfRASTORAS(highres) = 1 0 0 c_r(highres)
                              0 1 0 -c_a(lowres) 0 1 0 c_a(highres)
                              0 0 1 -c_s(lowres) 0 0 1 c_s(highres)
                              0 0 0 1 0 0 0 1
}}}

or write these as
{{{
       RASToSurfRAS(lowres) = [ 1 -C(lowres)] surfRASToRAS(highres) = [ 1 C(highres)]
                              [ 0 1 ] [ 0 1 ]

       Xfm = [ R T ]
                              [ 0 1 ]
}}}
Then,
{{{
       highresSurfRASTolowresSurfRAS = [ 1 -C(lowres)] x [ R T ] x [ 1 C(highres)]
                                       [ 0 1 ] [ 0 1 ] [ 0 1 ]

                                     = [ R R*C(highres)-C(lowres) + T ]
                                       [ 0 1 ]
}}}
The conclusion is that the transform is non-trivial. Even when R = 1 and T = 0 (no rotation), we have

{{{
      highresSurfRASTolowresSurfRAS = [ 1 C(highres)-C(lowres)]
                                       [ 0 1 ]
}}}
Therefore, when translating highres vertex positions into lowres vertex position, we must make sure that c_(ras) for highres and lowres must match exactly.

== 3.0 FreeSurferTalairach ==
 * FreeSurferTalairach

== 4.0 Direction cosines ==
The direction cosines tell you about how the acquired volume x, y, z axes correspond to the R(right), A(anterior), S(superier) axes. You can see this info by running the command, [[mri_info]] <volume>. For example, x_r = -1, x_a = 0, x_s = 0 means that the x axis points to the left (-1) of the R axis (no components along A and S axes). The '''CORONAL''' orientation, which is by the way the default freesurfer volume orientation, has x_r = -1, x_a = 0, x_s = 0, y_r = 0, y_a = 0, y_s = -1, z_r = 0, z_a = 1, z_s = 0. This means that the x axis points to the left, the y axis points to the inferior, and the z axis points to the anterior direction. The "c_ras" values specify where the volume center sits in the RAS coordinate system. That is, c_r, c_a. c_s are the RAS coordinate values of a voxel point (width/2, height/2, depth/2). Note that we use the convention of the voxel coordinate such that the center of a voxel corresponds to the
integer voxel coordinate position. This is not the usual convention taken by the graphics software like OpenGL. You have to watch out for this 1/2 voxel position shift.

Each volume format stores this direction cosine information in each own way. COR volume (COR-001, ...) stores it in COR-.info file. [[DICOM]] stores it in the file. Note that Analyze file (.img)stores it in .mat file, meanwhile bflort (.bfloat or .bshort) stores it in .bhdr file. For these formats it is essential to have these files.

== 5.0 MNI Talairach in tkmedit ==
[[tkmedit]] shows a non-identity Talairach even though talairach.xfm is an identity matrix. The reason is described in [[http://www.mrc-cbu.cam.ac.uk/Imaging/Common/mnispace.shtml|Cambride Imagers-MNI space]]. [[tkmedit]] uses Approach 2 described in the web page.

There are two talairach transformed used in [[tksurfer]]. One is MNI talairach and the other is modified talairach. The modified talairach is done in `tksurfer.c conv_initialize()`:

{{{
For Z < 0:

 conv_mnital_to_tal_m_ltz = MatrixIdentity (4, NULL);
  stuff_four_by_four (conv_mnital_to_tal_m_ltz,
        0.99, 0, 0, 0,
        0.00, 0.9688, 0.042, 0,
        0.00, -0.0485, 0.839, 0,
        0.00, 0, 0, 1);
}}}

{{{
For Z > 0:

  conv_mnital_to_tal_m_gtz = MatrixIdentity (4, NULL);
  stuff_four_by_four (conv_mnital_to_tal_m_gtz,
        0.99, 0, 0, 0,
        0.00, 0.9688, 0.046, 0,
        0.00, -0.0485, 0.9189, 0,
        0.00, 0, 0, 1);
}}}

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

1.0 Coordinate System Overview Disclaimer: The stuff below may or may not be correct.

Disclaimer: The stuff below may or may not be correct.Use the info above instead.

Freesurfer uses at least 4 voxel coordinate systems and 4 "RAS" coordinate systems.

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

The functional analysis stream uses another coordinate system to map from the src volume.

     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

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.

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.

              [-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 ]

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.

The transform 4 (surfaceRASFromConformedVoxel) is fixed as

              [-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]

The transform 1 (conformedVoxelFromVoxel) is calculated by (in a matrix sense)

     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 ]

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:

     xform3 = xform4 * inv(xform2) = [ 1 0 0  -c_r]
                                     [ 0 1 0  -c_a]
                                     [ 0 0 1  -c_s]
                                     [ 0 0 0    1 ]

Because of the xform3 (changing only translation part), it is easy to calculate SurfaceRASFromVoxel (xform3*xform0) and is given by

     SurfaceRASFromVoxel = [  3x3 part   (t1 - c_r)]
                           [  same as    (t2 - c_a)]
                           [  xform0     (t3 - c_s)]
                           [    0            1     ]

where t1,t2,t3 are the translation part of xform0.

The transform 5 and the transform 7 are calculated by the requirement

              [-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.

2.0 Relationship between lores and hires surfaceRAS

                conformed vol ------------->     surfRAS
                          |                         |
                          |                         |   surfRASToRAS
                          V                         V
                 high  res    ------------>        RAS
                          |                         |
                          |                         |    Xfm
                          V                         V
                 low  res     ------------>        RAS
                          |                         |
                          |                         |   RASToSurfRAS
                          V                         V
                conformed vol ------------->     surfRAS

Therefore, the map from the high res surfaceRAS to the low res surfaceRAS is given by

     highresSurfRASTolowresSurfRAS = RASTosurfRAS(lowres) * Xfm * sufRASToRAS(highres)

which is not equal to Xfm. In fact,

       RASTosurfRAS(lowres) = 1 0 0 -c_r(lowres)        surfRASTORAS(highres) =  1 0 0  c_r(highres)
                              0 1 0 -c_a(lowres)                                 0 1 0  c_a(highres)
                              0 0 1 -c_s(lowres)                                 0 0 1  c_s(highres)
                              0 0 0     1                                        0 0 0    1

or write these as

       RASToSurfRAS(lowres) = [ 1  -C(lowres)]      surfRASToRAS(highres) = [ 1 C(highres)]
                              [ 0   1        ]                              [ 0 1         ]

       Xfm                  = [ R   T ]
                              [ 0   1 ]

Then,

       highresSurfRASTolowresSurfRAS = [ 1  -C(lowres)] x [ R   T ]  x [ 1   C(highres)]
                                       [ 0   1        ]   [ 0   1 ]    [ 0   1         ]

                                     = [ R   R*C(highres)-C(lowres) + T ]
                                       [ 0          1                   ]

The conclusion is that the transform is non-trivial. Even when R = 1 and T = 0 (no rotation), we have

      highresSurfRASTolowresSurfRAS =  [ 1  C(highres)-C(lowres)]
                                       [ 0          1           ]

Therefore, when translating highres vertex positions into lowres vertex position, we must make sure that c_(ras) for highres and lowres must match exactly.

3.0 FreeSurferTalairach

4.0 Direction cosines

The direction cosines tell you about how the acquired volume x, y, z axes correspond to the R(right), A(anterior), S(superier) axes. You can see this info by running the command, mri_info <volume>. For example, x_r = -1, x_a = 0, x_s = 0 means that the x axis points to the left (-1) of the R axis (no components along A and S axes). The CORONAL orientation, which is by the way the default freesurfer volume orientation, has x_r = -1, x_a = 0, x_s = 0, y_r = 0, y_a = 0, y_s = -1, z_r = 0, z_a = 1, z_s = 0. This means that the x axis points to the left, the y axis points to the inferior, and the z axis points to the anterior direction. The "c_ras" values specify where the volume center sits in the RAS coordinate system. That is, c_r, c_a. c_s are the RAS coordinate values of a voxel point (width/2, height/2, depth/2). Note that we use the convention of the voxel coordinate such that the center of a voxel corresponds to the integer voxel coordinate position. This is not the usual convention taken by the graphics software like OpenGL. You have to watch out for this 1/2 voxel position shift.

Each volume format stores this direction cosine information in each own way. COR volume (COR-001, ...) stores it in COR-.info file. DICOM stores it in the file. Note that Analyze file (.img)stores it in .mat file, meanwhile bflort (.bfloat or .bshort) stores it in .bhdr file. For these formats it is essential to have these files.

5.0 MNI Talairach in tkmedit

tkmedit shows a non-identity Talairach even though talairach.xfm is an identity matrix. The reason is described in Cambride Imagers-MNI space. tkmedit uses Approach 2 described in the web page.

There are two talairach transformed used in tksurfer. One is MNI talairach and the other is modified talairach. The modified talairach is done in tksurfer.c conv_initialize():

For Z < 0:

 conv_mnital_to_tal_m_ltz = MatrixIdentity (4, NULL);
  stuff_four_by_four (conv_mnital_to_tal_m_ltz,
                      0.99,       0,     0, 0,
                      0.00,  0.9688, 0.042, 0,
                      0.00, -0.0485, 0.839, 0,
                      0.00,       0,     0, 1);

For Z > 0:

  conv_mnital_to_tal_m_gtz = MatrixIdentity (4, NULL);
  stuff_four_by_four (conv_mnital_to_tal_m_gtz,
                      0.99,       0,      0, 0,
                      0.00,  0.9688,  0.046, 0,
                      0.00, -0.0485, 0.9189, 0,
                      0.00,       0,      0, 1);

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