Home > NoiseTools > nt_interpolate_bad_channels.m

nt_interpolate_bad_channels

PURPOSE ^

y=interpolate_bad_channels(x,iBad,coordinates,n) - interpolate bad channels from good

SYNOPSIS ^

function [toGood,fromGood]=interpolate_bad_channels(x,iBad,coordinates,n)

DESCRIPTION ^

y=interpolate_bad_channels(x,iBad,coordinates,n) - interpolate bad channels from good

  y: interpolated data
 
  x: data to interpolate
  iBad: indices of bad channels
  coordinates: coordinate map (see nt_proximity)
  n: number of neighboring channels to use [default: 3]

 NoiseTools;

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [toGood,fromGood]=interpolate_bad_channels(x,iBad,coordinates,n)
0002 %y=interpolate_bad_channels(x,iBad,coordinates,n) - interpolate bad channels from good
0003 %
0004 %  y: interpolated data
0005 %
0006 %  x: data to interpolate
0007 %  iBad: indices of bad channels
0008 %  coordinates: coordinate map (see nt_proximity)
0009 %  n: number of neighboring channels to use [default: 3]
0010 %
0011 % NoiseTools;
0012 
0013 nt_greetings;
0014 
0015 if nargin<3; 
0016     error('!'); 
0017 end
0018 if nargin<4; 
0019     n=3;
0020 end
0021 
0022 nchans=size(x,2);
0023 toGood=eye(nchans);
0024 toGood(:,iBad)=[];
0025 
0026 [closest,d]=nt_proximity(coordinates);
0027 disp(size(closest));
0028 disp(size(d));
0029 if size(closest,1)~=nchans; error('!'); end
0030 
0031 fromGood=eye(nchans);
0032 for iChan=iBad
0033     iOthers=closest(iChan,:);
0034     iOthers=setdiff(iOthers, iBad, 'stable'); % don't include bad channels
0035     if numel(iOthers)<n; error('!'); end
0036     iOthers=iOthers(1:n);
0037     w=1./(d(iChan,iOthers) + eps);
0038     w=w/sum(w);
0039     fromGood(iOthers,iChan)=w;
0040 end
0041 fromGood(iBad,:)=[];
0042     
0043 topo=ones(nchans,1);
0044 topo(iBad)=0;
0045 if nargout==0
0046     figure(100); clf
0047     subplot 121; nt_imagescc(fromGood);
0048     subplot 122; nt_topoplot(coordinates,topo);
0049 end
0050

Generated on Sat 29-Apr-2023 17:15:46 by m2html © 2005