# AFNI and NIfTI Server for NIMH/NIH/PHS/DHHS/USA/Earth

##### Personal tools
You are here: Home » SSCC » Storage of Talairach Transformation

# Storage of Talairach Transformation

##### Document Actions
Submitted by bpittman. on 2005-04-18 09:15.
An answer to a question from a loyal user, who was concerned about transforming ROI volumes calculated in Talairach space back to the original brain space.

How the Talairach Transformation is Stored in the .HEAD File
A linear warp is stored as 30 numbers in the THD_linear_mapping struct:

• mfor = 3x3 matrix (the forward matrix)
• mbac = 3x3 matrix (the backward matrix)
• bvec = 3-vector (forward transform is x_map = [mfor] * x_in - bvec)
• svec = 3-vector (backward transform is x_in = [mbac] * x_map - svec)
• bot = 3-vector (range of x vector values )
• top = 3-vector (to use for transformation)
The Talairach transform is stored as 12 of these, so comprises 360 numbers total. These numbers are stored in the WARP_DATA attribute in the prefix+tlrc.HEAD file. Each block of 30 contiguous numbers is one of these linear warps. In order, their indexes are (copied from 3ddata.h)
```#define W_RAS  0  /* right-anterior -superior mapping index */
#define W_LAS  1  /* left -anterior -superior */
#define W_RMS  2  /* right-medial   -superior */
#define W_LMS  3  /* left -medial   -superior */
#define W_RPS  4  /* right-posterior-superior */
#define W_LPS  5  /* left -posterior-superior */
#define W_RAI  6  /* right-anterior -inferior */
#define W_LAI  7  /* left -anterior -inferior */
#define W_RMI  8  /* right-medial   -inferior */
#define W_LMI  9  /* left -medial   -inferior */
#define W_RPI 10  /* right-posterior-inferior */
#define W_LPI 11  /* left -posterior-inferior */
```
That is, the first 30 numbers correspond to the Right-Anterior-Superior region of the brain in Talairach coordinates; the next 30 for the Left-Anterior-Superior region of the brain; et cetera. Here are some numbers from a file, corresponding to the Right-Medial-Superior region (#2):
```       1.030303              0              0              0      0.8695359
0.06210971              0    -0.07029709      0.9841592      0.9705882
0              0              0       1.144201    -0.07220985
0     0.08172864       1.010938      0.4121149      -12.08224
-41.22271     -0.3999939       10.84782       42.66106          -9999
0              0              0             23         9999.9
```
Note that the last 6 numbers give the bot vector as [-9999,0,0] and the top vector as [0,23,9999.9]. This indicates that this transformation is valid for vectors [x,y,z] with
``` -9999 < x < 0      (the right of the brain),
0 < y < 23     (the medial region, between the AC and PC)
0 < z < 9999.9 (the superior region, above the AC-PC line)
```
Recall that AFNI (x,y,z) coordinates are in DICOM order:
```                   -x = Right     +x = Left
-y = Anterior  +y = Posterior
-z = Inferior  +z = Superior
```
In particular, x and y are sign-reversed with respect to SPM.

The "forward" transformation transforms (x,y,z) in +orig coordinates to +tlrc coordinates -- this corresponds to the mfor matrix. The "backward" transformation is the inverse of the forward, and corresponds to the mbac matrix. If you are counting volume in +tlrc coords, then you want to multiply by the determinant of the mbac matrix to scale to volume in +orig coords.

The regions for each transform are given in the bot and top vectors. These are fixed, though, for the AFNI +tlrc transform, at

```Right    = {x < 0}  Left     = {0 < x}
Anterior = {y < 0}  Medial   = {0 < y < 23}  Posterior = {23 < y}
Superior = {0 < z}  Inferior = {z < 0}
```
You could extract the 360 numbers from the WARP_DATA field using the command
`   3dAttribute WARP_DATA anat+tlrc`
for example -- this writes to stdout, which I suppose you could pipe into another program to calculate the determinants you want.

##### Blog
« May 2013 »
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

This site conforms to the following standards: