average normal direction in the neighbor of vertex [xxdev] = vb_cortex_normal_variance(brainfile,areafile,area_key,... para, coord_type) --- Input brainfile areafile areakey coord_type : = 'subj' : subject cortex normal. [default] = 'std' : standard cortex normal. --- Optional input para.tan_var : tangential variance coefficient para.var_max : tangential variance max In the brainfile, 'normal_stat' should be exist: normal_stat.neighbor_org : original brain neighbor index list normal_stat.normal_org : original brain normal vector --- Output xxdev : deviation from average normal vector (NP x 3) xxdev(:,1) = variance ratio for average normal vector direction xxdev(:,2) = variance ratio for tangential direction xxdev(:,3) = variance ratio for tangential direction angl = Angle between neighboring normal vector and average normal vector M. Sato 2006-7-23 Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [xxdev ,angl ]= ... 0002 vb_cortex_normal_variance(brainfile,areafile,area_key,... 0003 para, coord_type) 0004 % average normal direction in the neighbor of vertex 0005 % [xxdev] = vb_cortex_normal_variance(brainfile,areafile,area_key,... 0006 % para, coord_type) 0007 % --- Input 0008 % brainfile 0009 % areafile 0010 % areakey 0011 % coord_type : = 'subj' : subject cortex normal. [default] 0012 % = 'std' : standard cortex normal. 0013 % --- Optional input 0014 % para.tan_var : tangential variance coefficient 0015 % para.var_max : tangential variance max 0016 % 0017 % In the brainfile, 'normal_stat' should be exist: 0018 % normal_stat.neighbor_org : original brain neighbor index list 0019 % normal_stat.normal_org : original brain normal vector 0020 % --- Output 0021 % xxdev : deviation from average normal vector (NP x 3) 0022 % xxdev(:,1) = variance ratio for average normal vector direction 0023 % xxdev(:,2) = variance ratio for tangential direction 0024 % xxdev(:,3) = variance ratio for tangential direction 0025 % 0026 % angl = Angle between neighboring normal vector and average normal vector 0027 % 0028 % M. Sato 2006-7-23 0029 % 0030 % Copyright (C) 2011, ATR All Rights Reserved. 0031 % License : New BSD License(see VBMEG_LICENSE.txt) 0032 0033 % tangential variance coefficient 0034 if exist('para','var') & isfield(para,'tan_var') 0035 tan_var = para.tan_var; 0036 else 0037 tan_var = 1; 0038 end 0039 if ~exist('coord_type', 'var') 0040 coord_type = 'subj'; 0041 end 0042 0043 % tangential variance max 0044 if exist('para','var') & isfield(para,'var_max') 0045 var_max = para.var_max; 0046 else 0047 var_max = 2/3; 0048 end 0049 0050 % tangential angle max 0051 angle_max = pi/2; 0052 0053 normal_stat = vb_load_normal_statics(brainfile, coord_type); 0054 0055 % 0056 % --- original vertex near the cortical vertex 0057 % 0058 % normal_stat.neighbor_org : original brain neighbor index list 0059 % normal_stat.normal_org : original brain normal vector 0060 0061 % 0062 % --- Angle between neighboring normal vector and average normal vector 0063 % 0064 fprintf('--- Normal vector variance\n') 0065 angl = vb_calc_normal_variance(normal_stat.neighbor_org,normal_stat.normal_org ); 0066 0067 % 0068 % select area 0069 % 0070 if exist('areafile','var') & exist('area_key','var') ... 0071 & ~isempty(areafile) & ~isempty(area_key), 0072 Area = vb_get_area([areafile], area_key); 0073 ix = Area.Iextract; 0074 angl = angl(ix); 0075 end 0076 0077 NP = length(angl); 0078 xxdev = zeros(NP,3); 0079 tvar = sin( min( tan_var * abs(angl), angle_max) ); 0080 tvar = min( tvar, var_max ); 0081 0082 xxdev(:,1) = 1; 0083 xxdev(:,2) = tvar; 0084 xxdev(:,3) = tvar; 0085 0086 xxn = sum(xxdev,2); 0087 xxdev = xxdev./repmat(xxn, [1 3]);