INTERPOLATE_CORTEX Interpolate current density from a sparse tesselation to a dense tesselation function InterpMatrix = interpolate_cortex(sparseFV,denseFV,vertConn); sparseFV is the sparse Faces/Vertices structure denseFV is the dense Faces/Vertices structure vertConn is the vertices connectivity of the dense Faces/Vertices structure InterpMatrix returned is a sparse matrix (nDenseVertices x nSparseVertices) used for interpolation, where nDenseVertices in the number of vertices in the dense structure and nSparseVertices is the number of vertices in the sparse structure Interpolated current density is given by DenseCurrentDensity = InterpMatrix * SparseCurrentDensity Remarks: Every vertex in sparseFV should have a corresponding one in denseFV (i.e. same coordinates) sparseFV=reducepatch(denseFV) matlab function produces such tesselations Surfaces should be connected, i.e. there should exist a path through triangles connecting every pair of vertices on the surface interpolate_cortex performs interpolation in terms of surface neighbours and not in terms of volume neighbours See also REDUCEPATCH VERTICES_CONNECTIVITY PATCH_SWELL
0001 function [InterpMatrix] = interpolate_cortex(sparseFV,denseFV,vertConn) 0002 % INTERPOLATE_CORTEX Interpolate current density from a sparse tesselation to a dense tesselation 0003 % function InterpMatrix = interpolate_cortex(sparseFV,denseFV,vertConn); 0004 % sparseFV is the sparse Faces/Vertices structure 0005 % denseFV is the dense Faces/Vertices structure 0006 % vertConn is the vertices connectivity of the dense Faces/Vertices structure 0007 % 0008 % InterpMatrix returned is a sparse matrix (nDenseVertices x nSparseVertices) used for interpolation, 0009 % where nDenseVertices in the number of vertices in the dense structure and nSparseVertices is the 0010 % number of vertices in the sparse structure 0011 % Interpolated current density is given by DenseCurrentDensity = InterpMatrix * SparseCurrentDensity 0012 % 0013 % Remarks: Every vertex in sparseFV should have a corresponding one in denseFV (i.e. same coordinates) 0014 % sparseFV=reducepatch(denseFV) matlab function produces such tesselations 0015 % Surfaces should be connected, i.e. there should exist a path through triangles connecting every pair 0016 % of vertices on the surface 0017 % interpolate_cortex performs interpolation in terms of surface neighbours and not in terms of volume 0018 % neighbours 0019 % 0020 % See also REDUCEPATCH VERTICES_CONNECTIVITY PATCH_SWELL 0021 0022 % Dimitrios Pantazis, Ph.D. 0023 % 11-Apr-02 0024 % <copyright> 0025 % <copyright> 0026 0027 0028 %choose whether to display bars 0029 if(~exist('VERBOSE','var')), 0030 VERBOSE = 1; % default non-silent running of waitbars 0031 end 0032 0033 %Initialize variables 0034 nDenseVertices=size(denseFV.vertices,1); 0035 nSparseVertices=size(sparseFV.vertices,1); 0036 existInSparse=zeros(nDenseVertices,1); 0037 InterpMatrix=sparse(nDenseVertices,nSparseVertices); 0038 0039 0040 %find vertices that have been preserved in sparse patch 0041 %iDense: index of common vertices in denseFV 0042 %iSparse: index of common vertices in sparseFV 0043 [ignore,iDense,iSparse]=intersect(denseFV.vertices,sparseFV.vertices,'rows'); 0044 existInSparse(iDense) =iSparse; %helpful vector 0045 0046 %For a strange reason it takes awful time if I write InterpMatrix(iDense,iSparse)=1; 0047 for i=1:length(iDense) 0048 InterpMatrix(iDense(i),iSparse(i))=1; 0049 end 0050 0051 %interpolate the rest of the vertices 0052 if(VERBOSE) 0053 hwait = waitbar(0,sprintf('Interpolating the %.0f remaining vertices...',nDenseVertices-nSparseVertices)); 0054 drawnow %flush the display 0055 step=round(nDenseVertices/20); 0056 end 0057 for i=1:nDenseVertices 0058 if(VERBOSE) 0059 if(~rem(i,step)) % twenty updates 0060 waitbar(i/nDenseVertices,hwait); 0061 drawnow %flush the display 0062 end 0063 end 0064 if(~existInSparse(i)) 0065 startPatch=i; 0066 nLayer=0; 0067 neighboursKnown=[]; 0068 neighboursKnownScale=[]; 0069 while(length(neighboursKnown)<3 & nLayer <10 ) 0070 swelledPatch=patch_swell(startPatch,vertConn); %swell patch to find know vertices 0071 if(isempty(swelledPatch)) 0072 %disp('surface not closed'); 0073 break; 0074 end 0075 temp=existInSparse(swelledPatch); 0076 neighboursNew=temp(temp>0)'; 0077 nLayer=nLayer+1; 0078 neighboursKnown=[neighboursKnown neighboursNew]; 0079 neighboursKnownScale=[neighboursKnownScale nLayer*ones(1,length(neighboursNew))]; 0080 startPatch=[swelledPatch startPatch]; 0081 end 0082 %update InterpMatrix 0083 InterpMatrix(i,neighboursKnown)=(1./neighboursKnownScale)/sum(1./neighboursKnownScale); 0084 end 0085 end 0086 if(VERBOSE) 0087 close(hwait); 0088 end