Home > vbmeg > functions > brain > vb_original_normal_statics.m

vb_original_normal_statics

PURPOSE ^

Find original vertex near the cortical vertex

SYNOPSIS ^

function normal_stat = vb_original_normal_statics(proj_root,brain_parm,BV_index)

DESCRIPTION ^

 Find original vertex near the cortical vertex
  normal_stat = vb_original_normal_statics(proj_root,brain_parm,BV_index)
 --- Input
 proj_root
 brain_parm
  brain_parm.R_normal : Max radius of neighbor search
 BV_index  : original vertex index in BV/FS corresponding to brain.
 --- Output
 normal_stat.neighbor_org : original brain neighbor index list
 normal_stat.normal_org   : original brain normal vector
 normal_stat.neighbor_dd  : mean neighbor distance list
 normal_stat.neighbor_area : neighbor_area list

 [history]
 M. Sato  2015-12-14 ver.2.0

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function  normal_stat = vb_original_normal_statics(proj_root,brain_parm,BV_index)
0002 % Find original vertex near the cortical vertex
0003 %  normal_stat = vb_original_normal_statics(proj_root,brain_parm,BV_index)
0004 % --- Input
0005 % proj_root
0006 % brain_parm
0007 %  brain_parm.R_normal : Max radius of neighbor search
0008 % BV_index  : original vertex index in BV/FS corresponding to brain.
0009 % --- Output
0010 % normal_stat.neighbor_org : original brain neighbor index list
0011 % normal_stat.normal_org   : original brain normal vector
0012 % normal_stat.neighbor_dd  : mean neighbor distance list
0013 % normal_stat.neighbor_area : neighbor_area list
0014 %
0015 % [history]
0016 % M. Sato  2015-12-14 ver.2.0
0017 %
0018 % Copyright (C) 2011, ATR All Rights Reserved.
0019 % License : New BSD License(see VBMEG_LICENSE.txt)
0020 
0021 if isempty(proj_root)
0022     brain_file  = [brain_parm.brain_file];
0023 else
0024     brain_file  = [proj_root filesep brain_parm.brain_file];
0025 end
0026 
0027 % Max radius of neighbor search
0028 if isfield(brain_parm,'R_normal')
0029     Rmax = brain_parm.R_normal; 
0030 else
0031     Rmax = 0.003;    % 3mm
0032 end
0033 
0034 EPS = 1e-10;
0035 %
0036 % --- Load original brain
0037 %
0038 vb_disp('Calculate original normal statics')
0039 vb_disp('Load original brain')
0040 [V0L,F0L,n0L,V0R,F0R,n0R] = vb_load_orig_brain_surf(brain_parm);
0041 
0042 %tic
0043 % ----- This is done in vb_load_orig_brain_surf for freesurfer
0044 %[F0L, V0L, n0L] = vb_out_normal_surf(F0L,V0L);
0045 %[F0R, V0R, n0R] = vb_out_normal_surf(F0R,V0R);
0046 %
0047 %vb_disp(sprintf('%f[sec]',toc));
0048 
0049 %
0050 % --- SPM cordinate in [m]
0051 %
0052 vb_disp('Change coordinate to [m] ');
0053 
0054 V0L = V0L/1000;
0055 V0R = V0R/1000;
0056 
0057 NV0L  = size(V0L,1);
0058 NV0R  = size(V0R,1);
0059 NV0   = NV0L + NV0R;
0060 
0061 %
0062 % --- Check normal direction outward
0063 %     normal vector for disconnected vertex is set to zero
0064 vb_disp('check normal direction outward: ')
0065 
0066 %
0067 % ---- Check closed surface by solid_angle/(2*pi) = 1
0068 %
0069 omega  = vb_solid_angle_check(V0L,F0L);
0070 vb_disp(sprintf('Left solid_angle/(2*pi) = %5.3f',omega));
0071 if abs(omega - 1) > EPS,
0072     vb_disp('Surface is not closed ');
0073 end
0074 omega  = vb_solid_angle_check(V0R,F0R);
0075 vb_disp(sprintf('Right solid_angle/(2*pi) = %5.3f',omega));
0076 if abs(omega - 1) > EPS,
0077     vb_disp('Surface is not closed ');
0078 end
0079 
0080 %
0081 % ---- Check abnormal direction
0082 %
0083 NLxx = sum( (sum(n0L.^2,2) - 1) < EPS );
0084 if NLxx ~= NV0L,
0085     vb_disp(sprintf('# of left abnormal normal vector (%d)',NV0L - NLxx));
0086 end
0087 NRxx = sum( (sum(n0R.^2,2) - 1) < EPS );
0088 if NRxx ~= NV0R,
0089     vb_disp(sprintf('\n# of right abnormal normal vector (%d)',NV0R - NRxx));
0090 end
0091 
0092 %
0093 % ---- Load Original vertex index for reduced cortex
0094 %
0095 indxL = BV_index.Left;
0096 indxR = BV_index.Right;
0097 
0098 NL = length(indxL);
0099 NR = length(indxR);
0100 
0101 if min(indxR) > NV0L,
0102     indxR = indxR - NV0L;
0103 end
0104 
0105 %-------------------------------------------------------
0106 % Search neighbor points along cortex sheet
0107 % and calculate normal direction statistics
0108 %-------------------------------------------------------
0109 
0110 neighbor = cell(NL+NR,1);
0111 neighbor_dd = zeros(NL+NR,1);
0112 neighbor_area = zeros(NL+NR,1);
0113 
0114 %
0115 % --- Make neighbor list of original brain (Left)
0116 %
0117 tic
0118 vb_disp_nonl('Find neighbor index (Left): ')
0119 [xxDL,xxFL, xxTL]   = vb_next_distance( F0L, V0L ); 
0120 vb_disp(sprintf('%f[sec]',toc));
0121 
0122 % Vertex area
0123 [xxAL] = vb_calc_patch_area(V0L, F0L, xxTL);
0124 vb_disp(':Done')
0125 
0126 vb_disp_nonl('Make neighbor list of original brain (Left): ')
0127 tic
0128 
0129 prg_all = NL;
0130 prg = 0;
0131 Ndisp = fix(prg_all/20);
0132 
0133 % --- Search neighbor points along cortex sheet
0134 for n=1:NL
0135     [Vindx, dd] = vb_find_neighbor(Rmax, indxL(n), xxFL, xxDL );
0136     neighbor{n} = Vindx;
0137     
0138     % neighbor mean distance
0139     neighbor_dd(n) = mean(dd);
0140     % neighbor area
0141      neighbor_area(n) = sum(xxAL(Vindx));
0142     
0143     if mod(n,Ndisp)==0, 
0144       for ii=1:15; vb_disp_nonl(sprintf('\b')); end
0145       vb_disp_nonl(sprintf('%3d %% processed',ceil(100*(prg/prg_all))));
0146     end
0147     prg = prg+1;
0148 end
0149 vb_disp_nonl(sprintf(' %f[sec]\n',toc));
0150 
0151 %
0152 % --- Make neighbor member list of original brain (Right)
0153 %
0154 tic
0155 vb_disp_nonl('Find neighbor index (Right): ')
0156 [xxDR,xxFR,xxTR]   = vb_next_distance( F0R, V0R ); 
0157 vb_disp(sprintf('%f[sec]',toc));
0158 
0159 % Vertex area
0160 [xxAR] = vb_calc_patch_area(V0R, F0R, xxTR);
0161 vb_disp(':Done')
0162 
0163 vb_disp_nonl('Make neighbor list of original brain (Right): ')
0164 tic
0165 
0166 prg_all = NR;
0167 prg = 0;
0168 Ndisp = fix(prg_all/20);
0169 
0170 % --- Search neighbor points along cortex sheet
0171 for n=1:NR
0172     [Vindx, dd] = vb_find_neighbor(Rmax, indxR(n), xxFR, xxDR );
0173     neighbor{n + NL} = Vindx + NV0L;
0174     
0175     % neighbor mean distance
0176     neighbor_dd(n + NL) = mean(dd);
0177     % neighbor area
0178      neighbor_area(n + NL) = sum(xxAR(Vindx));
0179     
0180     if mod(n,Ndisp)==0, 
0181       for ii=1:15; vb_disp_nonl(sprintf('\b')); end
0182       vb_disp_nonl(sprintf('%3d %% processed',ceil(100*(prg/prg_all))));
0183     end
0184     prg = prg+1;
0185 end
0186 vb_disp_nonl(sprintf(' %f[sec]\n',toc));
0187 
0188 % neighbor info
0189 normal_stat.neighbor_org = neighbor;
0190 normal_stat.neighbor_dd  = neighbor_dd;
0191 normal_stat.neighbor_area = neighbor_area;
0192 
0193 % Original vertex, normal & patch
0194 normal_stat.normal_org = [n0L; n0R];
0195 
0196 %normal_stat.V0L = V0L;
0197 %normal_stat.V0R = V0R;
0198 %normal_stat.F0L = F0L;
0199 %normal_stat.F0R = F0R;
0200 
0201 % Original dimension
0202 normal_stat.Nvertex    = NL+NR;
0203 normal_stat.NvertexL   = NL;
0204 normal_stat.NvertexR   = NR;
0205 normal_stat.Nvertex0   = NV0;
0206 normal_stat.NvertexL0  = NV0L;
0207 normal_stat.NvertexR0  = NV0R;
0208 
0209 return

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005