function uu=despik(uz)
disp('despik');
[np,a]=size(uz);

uu2=sortrows(uz,1);
uu=uu2(1:np,1);
mp=floor(np/2);
mu=uu(mp);
sp=floor(.84*np);
sm=floor(.16*np);
sig=(uu(sp)-uu(sm))/2;
dsig=max(4*sig,.5);
im=1;
while abs(mu-uu(im))>dsig;
   im=im+1;
end;
ip=np;
while abs(uu(ip)-mu)>dsig;
   ip=ip-1;
end;
pct=(im+np-ip)/np*100;
disp(['total spikes= ' num2str(pct) ' %    median=  ' num2str(mu) '  sigma= ' num2str(sig)] );
uu2(1:im,1)=mu;
uu2(ip:np,1)=mu;
uy=sortrows(uu2,2);
uu=uy(1:np,1)';


