Home > NoiseTools > nt_dss1.m

nt_dss1

PURPOSE ^

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

SYNOPSIS ^

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

DESCRIPTION ^

[todss,pwr0,pwr1]=nt_dss1(x,w,keep1,keep2,sns_flag) - 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)
  sns_flag: if true, apply sns to average

  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,sns_flag)
0002 %[todss,pwr0,pwr1]=nt_dss1(x,w,keep1,keep2,sns_flag) - 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 %  sns_flag: if true, apply sns to average
0013 %
0014 %  The data mean is NOT removed prior to processing.
0015 %
0016 % NoiseTools
0017 
0018 if nargin<5; sns_flag=[]; end
0019 if nargin<4; keep2=10.^-12; end
0020 if nargin<3; keep1=[]; end
0021 if nargin<2; w=[]; end
0022 if nargin<1; error('!'); end
0023 
0024 if ndims(x)<3; error('x should be 3D'); end
0025 if ~isa(x,'double'); warning('x is not double precision'); end
0026 
0027 [m,n,o]=size(x);
0028 %[x,mn]=nt_demean(x,w);                            % remove weighted mean
0029 
0030 if isempty(w)% weighted average over trials (--> bias function for DSS)
0031     [c0,nc0]=nt_cov(x);
0032     c0=c0/nc0;
0033     [c1,nc1]=nt_cov(mean(x,3)); 
0034     c1=c1/nc1;
0035 else
0036     % weighted average over trials (--> bias function for DSS)
0037     if 1
0038         [xx,ww]=nt_mean_over_trials(x,w);
0039         if ~isempty(sns_flag); xx=nt_sns(xx,10,[],w); end
0040         ww=min(ww,[],2);
0041     else
0042         xx=mean(x,3);
0043         ww=ones([m,1]);
0044     end
0045     % covariance of raw and biased data
0046     [c0,nc0]=nt_cov(x,[],w);
0047     c0=c0/nc0;
0048     [c1,nc1]=nt_cov(xx,[],ww); 
0049     c1=c1/nc1;
0050 end
0051 
0052 % derive DSS matrix
0053 [todss,pwr0,pwr1]=nt_dss0(c0,c1,keep1,keep2);
0054 
0055 if nargout==0
0056     
0057     figure(100); clf; 
0058     subplot 221; 
0059     plot(pwr1./pwr0,'.-');
0060     xlabel('component'); ylabel('score');
0061     z=nt_mmat(x,todss(:,1:3));
0062     for iComp=1:3;
0063         subplot(2,2,iComp+1);
0064         nt_bsplot(z(:,iComp,:));
0065         title(iComp);
0066         xlabel('sample');
0067     end
0068     
0069     clear todss pwr0 pwr1
0070 end
0071

Generated on Mon 27-Feb-2017 15:36:07 by m2html © 2005