0001 function normal_stat = vb_original_normal_statics(proj_root,brain_parm)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 brain_file = [proj_root filesep brain_parm.brain_file];
0021
0022
0023 if isfield(brain_parm,'R_normal')
0024 Rmax = brain_parm.R_normal;
0025 else
0026 Rmax = 0.004;
0027 end
0028
0029
0030
0031
0032 vb_disp('Load original brain')
0033 [V0L,F0L,n0L,V0R,F0R,n0R] = vb_load_orig_brain_surf(brain_parm);
0034
0035
0036
0037 vb_disp('Change coordinate to [m] ');
0038
0039 V0L = V0L/1000;
0040 V0R = V0R/1000;
0041
0042
0043
0044
0045 tic
0046 vb_disp_nonl('Set normal direction outward: ')
0047 [F0L, V0L, xxL] = vb_out_normal_surf(F0L,V0L);
0048
0049 xxsig = sign( sum( n0L .* xxL , 2) );
0050 n0L = n0L .* repmat(xxsig, [1 3]);
0051
0052 [F0R, V0R, xxR] = vb_out_normal_surf(F0R,V0R);
0053
0054 xxsig = sign( sum( n0R .* xxR , 2) );
0055 n0R = n0R .* repmat(xxsig, [1 3]);
0056 vb_disp(sprintf('%f[sec]',toc));
0057
0058
0059
0060 load(brain_file,'BV_index')
0061
0062 NV0L = size(V0L,1);
0063 indxL = BV_index.Left;
0064 indxR = BV_index.Right;
0065
0066 if min(indxR) > NV0L,
0067 indxR = indxR - NV0L;
0068 end
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 tic
0079 vb_disp_nonl('Find neighbor index (Left): ')
0080 [xxD,xxF] = vb_next_distance( F0L, V0L );
0081 vb_disp(sprintf('%f[sec]',toc));
0082
0083
0084 vb_disp_nonl('Make neighbor member list of original brain (Left): ')
0085 tic
0086 Llist = vb_find_near_member(xxF, xxD, indxL, Rmax);
0087 vb_disp(sprintf('%f[sec]',toc));
0088
0089
0090
0091
0092
0093 tic
0094 vb_disp_nonl('Find neighbor index (Right): ')
0095 [xxD,xxF] = vb_next_distance( F0R, V0R );
0096 vb_disp(sprintf('%f[sec]',toc));
0097
0098
0099 vb_disp_nonl('Make neighbor member list of original brain (Right): ')
0100 tic
0101 Rlist = vb_find_near_member(xxF, xxD, indxR, Rmax);
0102 vb_disp(sprintf('%f[sec]',toc));
0103
0104
0105 clear V0R F0R V0L F0L xxD xxF BV_index
0106
0107
0108
0109
0110
0111
0112 vb_disp('Merge neighbor index')
0113
0114 NL = length(Llist);
0115 NR = length(Rlist);
0116
0117 neighbor = cell(NL+NR,1);
0118
0119 for n=1:NL
0120 neighbor{n} = Llist{n};
0121 end
0122
0123 for n=1:NR
0124 neighbor{n + NL} = Rlist{n} + NV0L;
0125 end
0126
0127 normal = [n0L; n0R];
0128
0129
0130
0131 normal_stat.neighbor_org = neighbor;
0132 normal_stat.normal_org = normal;
0133
0134
0135