[c0,c1]=bias_hi_amp(x,exponent) - covariance with and without hi-amp bias y: high-amplitude component x: data set (2D or 3D) exponent: exponent to apply to squared difference (larger=peakier) [default: 0.5]
0001 function [c0,c1,w]=bias_hi_amp(x,exponent) 0002 %[c0,c1]=bias_hi_amp(x,exponent) - covariance with and without hi-amp bias 0003 % 0004 % y: high-amplitude component 0005 % 0006 % x: data set (2D or 3D) 0007 % exponent: exponent to apply to squared difference (larger=peakier) [default: 0.5] 0008 0009 if nargin<2; exponent=0.5; end 0010 0011 % bias function emphasizes high-amplitude 0012 w=mean((x.^2).^exponent,2); 0013 ww=squeeze(min(w,[],1)); 0014 w=nt_vecadd(squeeze(w),-ww'); % subtract minimum from each trial (sharpens the bias function) 0015 w=nt_fold(w(:),size(x,1)); 0016 0017 c0=nt_cov(x); 0018 % c1=tscov(vecmult(unfold(x),w)); 0019 % save memory: 0020 c1=zeros(size(x,2)); 0021 for k=1:size(x,3) 0022 c1=c1+nt_cov(nt_vecmult(x(:,:,k),w(:,:,k))); 0023 end