Dear FreeSurfer devs,
I'm writing a program in JavaScript that converts FreeSurfer surface (mesh) files to other formats, which require the vertices to sit in scanner RAS coordinates.
Right now I'm relying on the FreeSurfer brain.finalsurf.mgz or T1.mgz file to obtain the Torig (vox to tkr-ras) and Norig (vox to scanner ras) matrices, and using these matrices to calculate the rigid transform. This approach requires the users to upload the mgz volume files (but I only need the transforms).
Today I found that each binary surface file (e.g. lh.pial) has a little footer that starts with uint32 sequence `2 0 20`, followed by the meta information such as xras, yras, zras, and cras. For example:
valid = 1 # volume info valid
filename = ../mri/filled-pretess127.mgz
volume = 256 256 256
voxelsize = 1.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+00
xras = -1.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
yras = 0.000000000000000e+00 0.000000000000000e+00 -1.000000000000000e+00
zras = 0.000000000000000e+00 1.000000000000000e+00 0.000000000000000e+00
cras = -1.000000000000000e+00 -1.700000000000000e+01 1.900000000000000e+01
\u0000\u0000\u0000\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0001
From what I understand, cras is the xyz of the volume center, which is the translation from mesh vertices xyz (in tkr-ras) to native scanner RAS.
I wonder if I can rely on this information to calculate the transform from tkr-ras to scan-ras, if so, where are the rotation matrices? (Affine/rigid transform is a 4x4 matrix, if cras is the translation, where are the first 3x3 elements, are those always identity matrices?)
Best,
- Dipterix