0001 function Vlabel = vb_fill_atlas_label(brainfile, Vlabel, ix, Rlimit)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 [nextDD,nextIX] = vb_load_cortex_neighbour(brainfile);
0014
0015 NV = length(Vlabel);
0016 flg = zeros(NV,1);
0017
0018 flg(ix) = 1;
0019 Vlabel(ix) = 0;
0020 N = length(ix);
0021
0022 Nmax = 2*N;
0023 cnt = 0;
0024
0025 while N > 0
0026 for n=1:N
0027 j = ix(n);
0028 dd = nextDD{j};
0029 jj = nextIX{j};
0030 val = Vlabel(jj);
0031
0032 jx = find( val > 0 );
0033 [dmin, jmin] = min( dd(jx) );
0034
0035 if dmin < Rlimit
0036 Vlabel(j) = val(jx(jmin));
0037 flg(j)=0;
0038 end
0039 end
0040
0041 ix = find( flg > 0 );
0042 N = length(ix);
0043 cnt = cnt + 1;
0044 if cnt > Nmax, break; end
0045 end
0046