0001 function [todss,pwr0,pwr1]=nt_dss1(x,w,keep1,keep2)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
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(:,:,:);
0026
0027 [m,n,o]=size(x);
0028
0029 if isempty(w)
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
0036 xx=nt_wmean(x,w,3);
0037 ww=min(w,[],2);
0038
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
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