Home > bioelectromagnetism > freesurfer_label2tal.m

freesurfer_label2tal

PURPOSE ^

freesurfer_label2tal - convert freesurfer label to Talairach coordinates

SYNOPSIS ^

function [MNIv,TALv] = freesurfer_label2tal(LABELv,TalairachXFM)

DESCRIPTION ^

 freesurfer_label2tal - convert freesurfer label to Talairach coordinates

 [MNIv,TALv] = freesurfer_label2tal(LABELv,TalairachXFM)

 The input 'LABELv' are columns 2:4 from freesurfer_read_label; they must
 be Nx3 vertex coordinates in freesurfer RAS coordinates. The second
 input is the matrix from the talairach.xfm file (see
 freesurfer_read_talxfm).

 This function converts the RAS coordinates into the MNI Talairach
 coordinates (MNIv).  It can also return the adjusted Talairach
 coordinates (TALv), based on the notes by Matthew Brett. This function
 calls mni2tal to apply the conversion from MNI template space to 'true'
 Talairach space.  See Matthew Brett's online discussion of this topic,
 http://www.mrc-cbu.cam.ac.uk/Imaging/Common/mnispace.shtml

 The surface RAS coordinates are arranged into a column vector, 
 LABELv = [R A S 1]', which is multiplied by the talairach.xfm
 matrix, TalairachXFM, to give the MNI Talairach coordinates:

 MNIv = TalairachXFM * LABELv;
 TALv = mni2tal(MNIv);

 The return matrices are Nx3

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [MNIv,TALv] = freesurfer_label2tal(LABELv,TalairachXFM)
0002 
0003 % freesurfer_label2tal - convert freesurfer label to Talairach coordinates
0004 %
0005 % [MNIv,TALv] = freesurfer_label2tal(LABELv,TalairachXFM)
0006 %
0007 % The input 'LABELv' are columns 2:4 from freesurfer_read_label; they must
0008 % be Nx3 vertex coordinates in freesurfer RAS coordinates. The second
0009 % input is the matrix from the talairach.xfm file (see
0010 % freesurfer_read_talxfm).
0011 %
0012 % This function converts the RAS coordinates into the MNI Talairach
0013 % coordinates (MNIv).  It can also return the adjusted Talairach
0014 % coordinates (TALv), based on the notes by Matthew Brett. This function
0015 % calls mni2tal to apply the conversion from MNI template space to 'true'
0016 % Talairach space.  See Matthew Brett's online discussion of this topic,
0017 % http://www.mrc-cbu.cam.ac.uk/Imaging/Common/mnispace.shtml
0018 %
0019 % The surface RAS coordinates are arranged into a column vector,
0020 % LABELv = [R A S 1]', which is multiplied by the talairach.xfm
0021 % matrix, TalairachXFM, to give the MNI Talairach coordinates:
0022 %
0023 % MNIv = TalairachXFM * LABELv;
0024 % TALv = mni2tal(MNIv);
0025 %
0026 % The return matrices are Nx3
0027 %
0028 
0029 % $Revision: 1.1 $ $Date: 2005/07/05 23:39:42 $
0030 
0031 % Licence:  GNU GPL, no express or implied warranties
0032 % History:  06/2005, Darren.Weber_at_radiology.ucsf.edu
0033 %                    adapted from freesurfer_surf2tal
0034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0035 
0036 ver = '$Revision: 1.1 $';
0037 fprintf('FREESURFER_LABEL2TAL [v %s]\n',ver(11:15));
0038 
0039 %--------------------------------------------------------------------------
0040 % transpose LABELv into column vectors and
0041 % add ones to last row of the matrix
0042 
0043 Nvertices = size(LABELv,1);
0044 
0045 LABELv = LABELv';
0046 LABELv(4,:) = ones(1, Nvertices);
0047 
0048 %--------------------------------------------------------------------------
0049 % Convert FreeSurfer RAS to Talairach coordinates
0050 
0051 MNIv = TalairachXFM * LABELv;
0052 MNIv = MNIv(1:3,:)'; % return Nx3 matrix
0053 
0054 if nargout > 1,
0055     TALv = mni2tal(MNIv')';
0056 end
0057 
0058 return
0059 
0060 
0061 
0062 
0063 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0064 % The operations above are not consistent with the email below from Tosa,
0065 % which indicates an additional transformation from surfaceRAS to RAS. If
0066 % this is the case, the values in tksurfer are incorrect.
0067 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0068 % Email from
0069 % Yasunari Tosa, Ph.D.               Email: tosa@nmr.mgh.harvard.edu
0070 % NMR Ctr, Mass. General Hospital    TEL: 617-726-4050 Building 149, 13th Street
0071 % Charlestown, MA 02129
0072 %
0073 %
0074 % I think that the label file uses "surfaceRAS" values, not "RAS".
0075 % Therefore you have to translate in two steps
0076 %
0077 %          surfaceRAS --------->  RAS --------------> talairachRAS
0078 %                           translation             talairach.xfm
0079 %
0080 % where translation affine xfm is given by (I hope you can read
0081 % it as 4x1 vector = (4 x 4 translation matrix) x (4 x 1 vector) )
0082 %
0083 %         RAS              translation     label_position
0084 %           [ x_r ]     =   [ 1 0 0 c_r  ]  [label_r]
0085 %           [ x_a ]          [ 0 1 0 c_a ]  [label_a]
0086 %           [ x_s ]          [ 0 0 1 c_s  ]  [label_s]
0087 %           [ 1    ]          [ 0 0 0   1    ]  [   1      ]
0088 %
0089 % i.e.  x_r = label_r  + c_r     (actual RAS position is shifted by c_(ras) value).
0090 %       x_a = label_a + c_a
0091 %       x_s = label_s + c_s
0092 %
0093 % Then multiply RAS by talairach.xfm (4 x 4) gives the talairachRAS position.

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003