We calculate the 4×4 transform that takes the volume from the original coordinates to talairach coordinates. This transform is never actually applied to the volume. Rather, it is saved (in the base structure, as base.vol2tal), and used in calculations, both to display Talairach coordinates when viewing the volume on mrLoadRet, and to align ROIs across different subjects.
We keep everything in the base structure, and we don't change the NIFTI headers, e.g., we do not re-set sform code to 3, we do not actually rotate the volume, and we do not change the s-form. Rather, we leave the sform code as 1, and save talXform to the base structure to be used for viewing or aligning.
The basic equation is:
(User-Chosen Points) = (transformation matrix )*(Canonical Talairach Points)
This is done in mrAlignGui under the Talairach callback, and the code follows these steps:
The Canonical Talairach coordinates are:
tAC = [0 0 0]'; tPC = [0 -24 0]'; tSAC = [0 0 72]'; tIAC = [0 0 -42]'; tPPC = [0 -102 0]'; tAAC = [0 68 0]'; tLAC = [-62 0 0]'; tRAC = [62 0 0]';
These are converted into an 8×4 matrix:
talPoints = [tAC tPC tSAC tIAC tPPC tAAC tLAC tRAC]; talPoints(4, :) = ones(1,size(talPoints,2));
talInfo.filename = ALIGN.volumePath; talInfo = talairach(ALIGN.volumePath);
points = [talInfo.AC;talInfo.PC;talInfo.SAC;talInfo.IAC;talInfo.PPC;talInfo.AAC;talInfo.LAC;talInfo.RAC]'; points(4, :) = ones(1,size(points,2));
talTransform = talPoints*pinv(points);
ALIGN.volBase.vol2tal = talTransform; ALIGN.volBase.talInfo = talInfo;