CALC_COVAR_PRIOR image prior with distance-based interelement covar This is a simplification of exponential_covar_prior.m Reg= calc_covar_prior( inv_model ) Reg => output regularization inv_model => inverse model struct P_type--prior type 1: elements are globally correlated 2: elements within/without electrode rings are correlated to elements in same region. 3: only elements within electrode rings are correlated.
0001 function Reg= calc_covar_prior( inv_model ) 0002 % CALC_COVAR_PRIOR image prior with distance-based interelement covar 0003 % This is a simplification of exponential_covar_prior.m 0004 % Reg= calc_covar_prior( inv_model ) 0005 % Reg => output regularization 0006 % inv_model => inverse model struct 0007 % P_type--prior type 0008 % 1: elements are globally correlated 0009 % 2: elements within/without electrode rings are correlated to elements in same region. 0010 % 3: only elements within electrode rings are correlated. 0011 0012 % (C) 2007, Tao Dai and Andy Adler. Licenced under the GPL Version 2 0013 % $Id: calc_covar_prior.html 2819 2011-09-07 16:43:11Z aadler $ 0014 0015 % get average x,y,z of each element 0016 ff = inv_model.fwd_model; 0017 nel = size(ff.elems,1); 0018 eta = .1;%attenuation factor. eta is large when elems're spatially highly correlated 0019 0020 dist = zeros(nel); 0021 0022 z1 = ff.nodes(ff.electrode(1).nodes,3);%upper electrode ring 0023 z2 = ff.nodes(ff.electrode(end).nodes,3);%lower electrode ring 0024 0025 for dim = 1: size(ff.nodes,2); 0026 coords = reshape(ff.nodes(ff.elems,dim),[size(ff.elems)]);%coord of four vertex of each elem 0027 m_coords = mean( coords,2);%calc center coord 0028 if dim == 3 0029 temp = double((m_coords<max(z1,z2))&(m_coords>min(z1,z2)));%regions of interests 0030 H = temp*temp'; 0031 switch inv_model.fourD_prior.P_type %Prior type 0032 case 1 % all elements are correlated 0033 H = eta*(ones(size(H))); 0034 case 2 % elements of ROI are not correlated with elements of non_ROI 0035 temp = double(m_coords>max(z1,z2)); 0036 H = H + temp*temp'; 0037 temp = double(m_coords<min(z1,z2)); 0038 H = H + temp*temp'; 0039 H = eta*(H+1e-6); 0040 case 3 % elements are only correlated within ROI, non-ROI elements are highly attenuated 0041 H = eta*(H+1e-6); 0042 otherwise 0043 error('no such a 3-D prior type'); 0044 end 0045 end 0046 difm = m_coords*ones(1,nel); 0047 difm = difm - difm'; 0048 dist= dist + difm.^2;% 0049 end 0050 dist = sqrt(dist);%elements distance matrix 0051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0052 dist = dist/max(dist(:)); 0053 0054 Reg = exp(-dist ./ H);% 3-D elements correlations matrix.