Home > NoiseTools > nt_dss1.m

nt_dss1

PURPOSE ^

[todss,pwr0,pwr1]=nt_dss1(x,w,keep1,keep2) - evoked-biased DSS denoising

SYNOPSIS ^

function [todss,pwr0,pwr1]=nt_dss1(x,w,keep1,keep2)

DESCRIPTION ^

[todss,pwr0,pwr1]=nt_dss1(x,w,keep1,keep2) - evoked-biased DSS denoising

  todss: denoising matrix
  pwr0: power per component (raw)
  pwr1: power per component (averaged)

  x: data to denoise (time * channels * trials)
  w: weight
  keep1: (in DSS0) number of PCs to retain (default: all)
  keep2: (in DSS0) ignore PCs smaller than keep2 (default: 10.^-12)

  The data mean is NOT removed prior to processing.

 NoiseTools

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [todss,pwr0,pwr1]=nt_dss1(x,w,keep1,keep2)
0002 %[todss,pwr0,pwr1]=nt_dss1(x,w,keep1,keep2) - evoked-biased DSS denoising
0003 %
0004 %  todss: denoising matrix
0005 %  pwr0: power per component (raw)
0006 %  pwr1: power per component (averaged)
0007 %
0008 %  x: data to denoise (time * channels * trials)
0009 %  w: weight
0010 %  keep1: (in DSS0) number of PCs to retain (default: all)
0011 %  keep2: (in DSS0) ignore PCs smaller than keep2 (default: 10.^-12)
0012 %
0013 %  The data mean is NOT removed prior to processing.
0014 %
0015 % NoiseTools
0016 
0017 if nargin<4; keep2=10.^-12; end
0018 if nargin<3; keep1=[]; end
0019 if nargin<2; w=[]; end
0020 if nargin<1; error('!'); end
0021 
0022 if ndims(x)<3; error('x should be 3D'); end
0023 if ~isa(x,'double'); warning('x is not double precision'); end
0024 
0025 x=x(:,:,:); % collapse higher dims
0026 
0027 [m,n,o]=size(x);
0028 
0029 if isempty(w)   % average over trials (--> bias function for DSS)
0030     [c0,nc0]=nt_cov(x);
0031     c0=c0/nc0;
0032     [c1,nc1]=nt_cov(mean(x,3)); 
0033     c1=c1/nc1;
0034 else
0035     % weighted average over trials (--> bias function for DSS)
0036     xx=nt_wmean(x,w,3);
0037     ww=min(w,[],2);
0038     % covariance of raw and biased data
0039     [c0,nc0]=nt_cov(x,[],w);
0040     c0=c0/nc0;
0041     [c1,nc1]=nt_cov(xx,[],ww); 
0042     c1=c1/nc1;
0043 end
0044 
0045 % derive DSS matrix
0046 [todss,pwr0,pwr1]=nt_dss0(c0,c1,keep1,keep2);
0047 
0048 if nargout==0
0049     
0050     figure(100); clf; 
0051     subplot 221; 
0052     plot(pwr1./pwr0,'.-');
0053     xlabel('component'); ylabel('score');
0054     z=nt_mmat(x,todss(:,1:3));
0055     for iComp=1:3;
0056         subplot(2,2,iComp+1);
0057         nt_bsplot(z(:,iComp,:));
0058         title(iComp);
0059         xlabel('sample');
0060     end
0061     
0062     clear todss pwr0 pwr1
0063 end
0064

Generated on Tue 09-Oct-2018 10:58:04 by m2html © 2005