Deviation angle from average normal vector in the neighbor of root vertex xxdev = vb_calc_normal_variance(member_id, xx) --- Input member_id{n} : member vertex index which belog to the n-th root point xx(i,:) : normal vector at the vertex-i in the original brain --- Output xxdev : deviation angle from average normal vector M. Sato 2006-7-14 Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function xxdev = vb_calc_normal_variance(member_id, xx) 0002 % Deviation angle from average normal vector in the neighbor of root vertex 0003 % xxdev = vb_calc_normal_variance(member_id, xx) 0004 % --- Input 0005 % member_id{n} : member vertex index which belog to the n-th root point 0006 % xx(i,:) : normal vector at the vertex-i in the original brain 0007 % --- Output 0008 % xxdev : deviation angle from average normal vector 0009 % 0010 % M. Sato 2006-7-14 0011 % 0012 % Copyright (C) 2011, ATR All Rights Reserved. 0013 % License : New BSD License(see VBMEG_LICENSE.txt) 0014 0015 % Number of target vertex for calculation 0016 Nroot = length(member_id); 0017 0018 % Deviation angle from average normal vector 0019 xxdev = zeros(Nroot,1); 0020 0021 for n=1:Nroot, 0022 % neighbor point index 0023 inext = member_id{n}; 0024 Nnext = length(inext); 0025 0026 % normal vector of neighbor point 0027 xxnext = xx(inext,:); 0028 0029 % mean normal vector 0030 xxn = sum(xxnext,1); 0031 xxs = max( sqrt(sum(xxn.^2)), eps ); 0032 xxn = xxn/xxs; 0033 0034 % mean angle from mean normal vector 0035 xxdev(n) = sum(acos(xxnext*xxn'))/Nnext; 0036 end;