Home > bioelectromagnetism > freesurfer_label2tal_test.m

freesurfer_label2tal_test

PURPOSE ^

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 file = which('freesurfer_read_label');
0003 if file,
0004     [path, file, ext] = fileparts(file);
0005     cd(path)
0006 else
0007     error('cannot find "freesurfer_read_label" on the matlab path');
0008     return
0009 end
0010 
0011 % I read a subject rh.pial into tksurfer and selected a small patch of
0012 % vertices to save them into a small .label file.  These two files were
0013 % copied into:
0014 % freesurfer_label2tal_test.pial
0015 % freesurfer_label2tal_test.label
0016 
0017 surfFile = 'freesurfer_label2tal_test.pial';
0018 pial = freesurfer_read_surf(surfFile);
0019 surfFile = 'freesurfer_label2tal_test.orig';
0020 orig = freesurfer_read_surf(surfFile);
0021 
0022 lname = 'freesurfer_label2tal_test';
0023 label = freesurfer_read_label([], lname);
0024 LABELi = label(:,1);
0025 LABELv = label(:,2:4);
0026 
0027 xfmFile = 'freesurfer_label2tal_test.talairach.xfm';
0028 TalairachXFM = freesurfer_read_talxfm(xfmFile);
0029 
0030 [MNIv,TALv] = freesurfer_label2tal(LABELv,TalairachXFM);
0031 
0032 % These are the values noted from csurf/tksurfer for three vertices in the
0033 % .label area:
0034 % vertex   Vertex RAS          Vertex Talairach     MNI Tal              Curvature
0035 %  79497   58.81 -4.05 16.10   69.44 -14.69 -1.09   70.14 -15.07 -2.17   -0.175448
0036 %  81708   58.42 -2.60 15.52   69.04 -13.30 -1.81   69.74 -13.60 -2.94   -0.169868
0037 %  82883   58.10 -1.81 15.14   68.72 -12.55 -2.26   69.41 -12.80 -3.43   -0.145019
0038 % These vertex indices are from tksurfer, which are 0 indexed, so we need
0039 % to add 1 for matlab compatibility and then check the results
0040 tksurferIndex = [79497, 81708, 82883] + 1;
0041 checkLABELv = zeros(length(tksurferIndex),3);
0042 checkMNIv = checkLABELv;
0043 checkTALv = checkLABELv;
0044 for i = 1:length(tksurferIndex),
0045     labelIndex = find(label(:,1) == tksurferIndex(i));
0046     checkLABELv(i,:) = LABELv(labelIndex,:);
0047     checkMNIv(i,:) = MNIv(labelIndex,:);
0048     checkTALv(i,:) = TALv(labelIndex,:);
0049 end
0050 
0051 % These are the final values from these operations:
0052 [checkLABELv, checkTALv, checkMNIv]
0053 %
0054 % ans =
0055 %
0056 %    58.8150   -4.0450   16.1020   69.4361  -14.6923   -1.0908   70.1375  -15.0708   -2.1713
0057 %    58.4180   -2.5990   15.5180   69.0438  -13.3031   -1.8091   69.7412  -13.6034   -2.9427
0058 %    58.1010   -1.8110   15.1420   68.7161  -12.5491   -2.2592   69.4102  -12.8039   -3.4329
0059 
0060 
0061 % However, note that .label files contain .orig values:
0062 % >> pial(LABELi(1:5),:)
0063 %
0064 % ans =
0065 %
0066 %    61.9822   -5.1003   17.5164
0067 %    61.5910   -5.5861   16.0358
0068 %    61.9058   -3.7053   18.3539
0069 %    61.5532   -4.1727   16.7315
0070 %    61.4371   -3.5764   16.1880
0071 %
0072 % >> orig(LABELi(1:5),:)
0073 %
0074 % ans =
0075 %
0076 %    59.4524   -5.5179   17.1148
0077 %    59.3218   -5.5571   16.2510
0078 %    59.3762   -4.5750   17.4985
0079 %    59.1861   -4.5583   16.4948
0080 %    58.8150   -4.0450   16.1021
0081 %
0082 % >> LABELv(1:5,:)
0083 %
0084 % ans =
0085 %
0086 %    59.4520   -5.5180   17.1150
0087 %    59.3220   -5.5570   16.2510
0088 %    59.3760   -4.5750   17.4980
0089 %    59.1860   -4.5580   16.4950
0090 %    58.8150   -4.0450   16.1020
0091

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