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 if nargin<4||isempty(keep2); keep2=10.^-9; end
0024 if nargin<3; keep1=[]; end
0025 if nargin<2; error('needs at least two arguments'); end
0026 
0027 if size(c0)~=size(c1); error('C0 and C1 should have same size'); end
0028 if size(c0,1)~=size(c0,2); error('C0 should be square'); end
0029 
0030 if any(find(isnan(c0)))
0031     error('NaN in c0');
0032 end
0033 if any(find(isnan(c1)))
0034     error('NaN in c1');
0035 end
0036 if any(find(isinf(c0)))
0037     error('INF in c0');
0038 end
0039 if any(find(isinf(c1)))
0040     error('INF in c1');
0041 end
0042 % PCA and whitening matrix from the unbiased covariance
0043 [topcs1,evs1]=nt_pcarot(c0,keep1,keep2);
0044 evs1=abs(evs1);
0045 
0046 % truncate PCA series if needed
0047 if ~isempty(keep1); topcs1=topcs1(:,1:keep1); evs1=evs1(1:keep1); end
0048 if ~isempty(keep2); idx=find(evs1/max(evs1)>keep2); topcs1=topcs1(:,idx); evs1=evs1(idx);  end
0049 
0050 % apply PCA and whitening to the biased covariance
0051 N=diag(sqrt(1./(evs1)));     
0052 c2=N'*topcs1'*c1*topcs1*N;
0053 
0054 % matrix to convert PCA-whitened data to DSS
0055 [topcs2,evs2]=nt_pcarot(c2,keep1,keep2);
0056 
0057 % DSS matrix (raw data to normalized DSS)
0058 todss=topcs1*N*topcs2;
0059 N2=diag(todss'*c0*todss);
0060 todss=todss*diag(1./sqrt(N2)); % adjust so that components are normalized
0061 
0062 
0063 % power per DSS component
0064 pwr0=sqrt(sum((c0'*todss).^2)); % unbiased
0065 pwr1=sqrt(sum((c1'*todss).^2)); % biased
0066 
0067 
0068

Generated on Mon 30-Jan-2017 18:59:11 by m2html © 2005