Home > NoiseTools > nt_dss_repeat_cluster.m

nt_dss_repeat_cluster

PURPOSE ^

y=nt_dss_repeat_cluster(x,nkeep,cluster_size) - dss within clusters

SYNOPSIS ^

function x=nt_dss_repeat_cluster(x,nkeep,cluster_size)

DESCRIPTION ^

 y=nt_dss_repeat_cluster(x,nkeep,cluster_size) - dss within clusters
 to emphasize repeatability

   y: denoised matrix

   x: matrix  to denoise (time * channels * trials)
   nkeep: number of components to keep for each cluster
   cluster_size: target cluster size [default: size(x,1)/2]

 NoiseTools

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001  function x=nt_dss_repeat_cluster(x,nkeep,cluster_size)
0002 % y=nt_dss_repeat_cluster(x,nkeep,cluster_size) - dss within clusters
0003 % to emphasize repeatability
0004 %
0005 %   y: denoised matrix
0006 %
0007 %   x: matrix  to denoise (time * channels * trials)
0008 %   nkeep: number of components to keep for each cluster
0009 %   cluster_size: target cluster size [default: size(x,1)/2]
0010 %
0011 % NoiseTools
0012 nt_greetings;
0013 
0014 
0015 if nargin<3; cluster_size=[]; end
0016 if nargin<2; nkeep=ceil(cluster_size/2); end
0017 
0018 if ndims(x)~=3; error('!'); end
0019 
0020 x0=x;
0021 
0022 if isempty(cluster_size); cluster_size=round(size(x,1)/2); end
0023 
0024 if size(x,2)<=cluster_size
0025     todss=nt_dss1(x);
0026     fromdss=pinv(todss);
0027     nkeep=min(nkeep,size(todss,2));
0028     x=nt_mmat(x,(todss(:,1:nkeep)*fromdss(1:nkeep,:)));
0029 else
0030     NCLUSTERS=2;
0031     [C,A]=vl_kmeans(nt_unfold(x),NCLUSTERS,'algorithm', 'elkan','initialization','plusplus','numrepetitions', 100);
0032     if numel(find(A==1)) && numel(find(A==2))
0033         xA=nt_dss_repeat_cluster(x(:,find(A==1),:),nkeep,cluster_size);
0034         xB=nt_dss_repeat_cluster(x(:,find(A==2),:),nkeep,cluster_size);
0035         x(:,find(A==1),:)=xA;
0036         x(:,find(A==2),:)=xB;
0037     end % else no split, return
0038 end
0039 x1=x;
0040 
0041 
0042 verbose=0;
0043 if nargout==0 || verbose;
0044     disp(['cluster size: ', num2str(size(x,2)), ',  power ratio: ',num2str(nt_wpwr(x1)/nt_wpwr(x0))]);
0045 end
0046 
0047

Generated on Wed 27-Nov-2019 09:49:00 by m2html © 2005