Home > NoiseTools > nt_sns1.m

nt_sns1

PURPOSE ^

y=nt_sns1(x,nneigbors,skip,w,threshold) - sensor noise suppression

SYNOPSIS ^

function x=nt_sns1(x,nneighbors,skip,w,threshold)

DESCRIPTION ^

 y=nt_sns1(x,nneigbors,skip,w,threshold) - sensor noise suppression

   y: denoised matrix

   x: matrix  to denoise
   nneighbors: number of channels to use in projection 
   skip: number of closest neighbors to skip (default: 0)
   w : weights (default: all ones)
   threshold: sharedness threshold (default: 2)
  
  This version of SNS first regresses out major shared components.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function x=nt_sns1(x,nneighbors,skip,w,threshold)
0002 % y=nt_sns1(x,nneigbors,skip,w,threshold) - sensor noise suppression
0003 %
0004 %   y: denoised matrix
0005 %
0006 %   x: matrix  to denoise
0007 %   nneighbors: number of channels to use in projection
0008 %   skip: number of closest neighbors to skip (default: 0)
0009 %   w : weights (default: all ones)
0010 %   threshold: sharedness threshold (default: 2)
0011 %
0012 %  This version of SNS first regresses out major shared components.
0013 
0014 
0015 if nargin<5 || isempty(threshold); threshold=2; end
0016 if nargin<4; w=[]; end
0017 if nargin<3 || isempty(skip); skip=0; end
0018 if nargin<2 || isempty(nneighbors); error('need to specify nneighbors'); end
0019 if ~isempty(w) && sum(w(:))==0; error('weights are all zero!'); end
0020 if ~isempty(find(isnan(x))); error('x contains NANs'); end
0021 if numel(nneighbors)>1 || numel(skip)>1; error('nneighbors and skip must be scalars'); end
0022 
0023 xx=nt_pca(nt_normcol(x),[],[],10^-6);   % give each sensor equal weight, PCA
0024 xx=xx(:,find(mean(nt_unfold(xx.^2))>threshold),:); % shared components
0025 
0026 if numel(xx)==0; error('!'); end
0027 
0028 xxx=nt_tsr(x,xx); % strip data of shared components
0029 clear xx
0030 
0031 xxxx=x-xxx;     % shared part
0032 %xxx=nt_sns(nt_sns(nt_sns(xxx,nneighbors,skip,w),nneighbors,skip,w),nneighbors,skip,w); % denoise non-shared part
0033 xxx=nt_sns(xxx,nneighbors,skip,w); % denoise non-shared part
0034 x=xxx+xxxx;       % restore shared part
0035 
0036 
0037 
0038

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