Home > NoiseTools > nt_dss0.m

nt_dss0

PURPOSE ^

[todss,pwr1,pwr2]=nt_dss0(c0,c1,keep1,keep2) - dss from covariance

SYNOPSIS ^

function [todss,pwr0,pwr1]=nt_dss0(c0,c1,keep1,keep2)

DESCRIPTION ^

[todss,pwr1,pwr2]=nt_dss0(c0,c1,keep1,keep2) - dss from covariance

 todss: matrix to convert data to normalized DSS components
 pwr0: power per component (baseline)
 pwr1: power per component (biased)

 c0: baseline covariance
 c1: biased covariance
 keep1: number of PCs to retain (default: all)
 keep2: ignore PCs smaller than keep2 (default: 10.^-9)

 Cite:
 de Cheveign\'e, A. and Simon J.Z. (2008), "Denoising 
 based on spatial filtering", J Neurosci Methods 171: 331-339.
 and:
 J. S\"arel\"a, J. and Valpola, H. (2005), Denoising source separation. 
 Journal of Machine Learning Research 6: 233-272.

 NoiseTools

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [todss,pwr0,pwr1]=nt_dss0(c0,c1,keep1,keep2)
0002 %[todss,pwr1,pwr2]=nt_dss0(c0,c1,keep1,keep2) - dss from covariance
0003 %
0004 % todss: matrix to convert data to normalized DSS components
0005 % pwr0: power per component (baseline)
0006 % pwr1: power per component (biased)
0007 %
0008 % c0: baseline covariance
0009 % c1: biased covariance
0010 % keep1: number of PCs to retain (default: all)
0011 % keep2: ignore PCs smaller than keep2 (default: 10.^-9)
0012 %
0013 % Cite:
0014 % de Cheveign\'e, A. and Simon J.Z. (2008), "Denoising
0015 % based on spatial filtering", J Neurosci Methods 171: 331-339.
0016 % and:
0017 % J. S\"arel\"a, J. and Valpola, H. (2005), Denoising source separation.
0018 % Journal of Machine Learning Research 6: 233-272.
0019 %
0020 % NoiseTools
0021 nt_greetings;
0022 
0023 
0024 if nargin<4||isempty(keep2); keep2=10.^-9; end
0025 if nargin<3; keep1=[]; end
0026 if nargin<2; error('needs at least two arguments'); end
0027 
0028 if size(c0)~=size(c1); error('C0 and C1 should have same size'); end
0029 if size(c0,1)~=size(c0,2); error('C0 should be square'); end
0030 
0031 if any(find(isnan(c0)))
0032     error('NaN in c0');
0033 end
0034 if any(find(isnan(c1)))
0035     error('NaN in c1');
0036 end
0037 if any(find(isinf(c0)))
0038     error('INF in c0');
0039 end
0040 if any(find(isinf(c1)))
0041     error('INF in c1');
0042 end
0043 % PCA and whitening matrix from the unbiased covariance
0044 [topcs1,evs1]=nt_pcarot(c0,keep1,keep2);
0045 evs1=abs(evs1);
0046 
0047 % truncate PCA series if needed
0048 if ~isempty(keep1); topcs1=topcs1(:,1:keep1); evs1=evs1(1:keep1); end
0049 if ~isempty(keep2); idx=find(evs1/max(evs1)>keep2); topcs1=topcs1(:,idx); evs1=evs1(idx);  end
0050 
0051 % apply PCA and whitening to the biased covariance
0052 N=diag(sqrt(1./(evs1)));     
0053 c2=N'*topcs1'*c1*topcs1*N;
0054 
0055 % matrix to convert PCA-whitened data to DSS
0056 [topcs2,evs2]=nt_pcarot(c2,keep1,keep2);
0057 
0058 % DSS matrix (raw data to normalized DSS)
0059 todss=topcs1*N*topcs2;
0060 N2=diag(todss'*c0*todss);
0061 todss=todss*diag(1./sqrt(N2)); % adjust so that components are normalized
0062 
0063 
0064 % power per DSS component
0065 pwr0=sqrt(sum((c0'*todss).^2)); % unbiased
0066 pwr1=sqrt(sum((c1'*todss).^2)); % biased
0067 
0068 
0069

Generated on Mon 28-Nov-2016 20:12:47 by m2html © 2005