Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
---- ''text originating from [[http://www.mail-archive.com/freesurfer@nmr.mgh.harvard.edu/msg08085.html|Patrick Schikowski]]'' |
|
Line 5: | Line 3: |
register.dat is a 4x4 matrix, since it is not possible to encode a complete affine transformation (translation, scaling and rotation) in a 3x3 matrix. At the beginning you have separated matrices for the translation, the scaling and rotation. They are encoded like this: {{{ Translation T = (1,0,0,tx) (0,1,0,ty) (0,0,1,tz) (0,0,0,1) }}} The translation vector is therefore placed in the last line of the matrix, the rest looks like a unit matrix. The scaling matrix is: {{{ Scaling S = (sx,0,0,0) (0,sy,0,0) (0,0,sz,0) (0,0,0,1) }}} The rotation matrix is somehow more complicated and results from 3 separated rotation matrices, one for the rotation around each axis (x,y,z). Put together the rotation is encoded in the upper left 3x3 matrix. For details see the (computer graphics) literature. {{{ Rotation R = (r1,r2,r3,0) (r4,r5,r6,0) (r7,r8,r9,0) (0, 0, 0, 1) }}} Luckily one can multiply the matrices together. If you do it in the right way, you will end up with one transformation matrix, the one freesurfer offers: {{{ A = T * S * R }}} In A everything is included, the translation, the scaling and the rotation. It doesn't really matter that the matrix is 4x4, but of course you can only multiply it with a 4-dimensional vector for transformation purposes. To do so, you just have to expand the familiar 3-dimensional vector by one dimension and put in a 1 at the 4th dimension. {{{ Vector v = (x) (y) (z) (1) }}} Now you will be able to multiply this one with the 4x4 transformation matrix and you will end up with the transformed point. You just have to ignore the 4th dimension of the vector, or you can change it back to a 3-dimensional one, by just cutting away the 4th dimension. {{{ v * A = v_transformed }}} |
register.dat is the format that various freesurfer programs (eg, tkregister2, bbregister, spmregister, mri_vol2surf, mri_vol2vol, etc) use to store and access a 4x4 matrix transformation matrix. It consists of four lines of header and a 4x4 matrix followed by a "footer" line. The header lines are: 1. Subject - name of subject as found in $SUBJECTS_DIR/subject (not always necessary) 2. In-plane voxel resolution in mm -- ignored 3. Between-plane voxel resolution in mm -- ignored 4. Intensity - used by tkregister2 The footer line should always be "round". The registration matrix maps from the tkRAS of the subject anatomical target volume to the tkRAS of the input/movable volume and can code up to 12 DOF (ie, an affine transform). Example: mgh-02407836-v2 3.437500 5.000000 0.150000 9.999921e-01 1.462518e-04 -3.969864e-03 7.764969e-01 3.899203e-03 -2.272341e-01 9.738325e-01 -3.873044e+01 7.596778e-04 9.738404e-01 2.272329e-01 -1.456367e+00 0.000000e+00 0.000000e+00 0.000000e+00 1.000000e+00 round |
register.dat
register.dat is the format that various freesurfer programs (eg, tkregister2, bbregister, spmregister, mri_vol2surf, mri_vol2vol, etc) use to store and access a 4x4 matrix transformation matrix. It consists of four lines of header and a 4x4 matrix followed by a "footer" line.
The header lines are: 1. Subject - name of subject as found in $SUBJECTS_DIR/subject (not always necessary) 2. In-plane voxel resolution in mm -- ignored 3. Between-plane voxel resolution in mm -- ignored 4. Intensity - used by tkregister2
The footer line should always be "round".
The registration matrix maps from the tkRAS of the subject anatomical target volume to the tkRAS of the input/movable volume and can code up to 12 DOF (ie, an affine transform).
Example:
mgh-02407836-v2 3.437500 5.000000 0.150000 9.999921e-01 1.462518e-04 -3.969864e-03 7.764969e-01 3.899203e-03 -2.272341e-01 9.738325e-01 -3.873044e+01 7.596778e-04 9.738404e-01 2.272329e-01 -1.456367e+00 0.000000e+00 0.000000e+00 0.000000e+00 1.000000e+00 round