%伪迹减法
clear;clc;
load for_den
seg=80000:90000-1;
sig(1:6,:)=xx(2:7,seg);
noise=sig(1,:);
max_value=max(abs(noise));
i=0;
while i<=length(noise)
flag=0;
k=1;
temp=0;
while flag==0 && i+k<=length(noise)
if abs(noise(i+k))<0.1*max_value
noise(i+k)=0;
noise(i+1:i+k)=temp/k;
flag=1;
else
temp=temp+noise(i+k);
k=k+1;
end
end
i=i+k;
if i>length(noise(:))
break;
end
end
for elc=2:6
c=mean((sig(elc,:)-mean(sig(elc,:))).*(noise-mean(noise)));
d=var(noise);
b=c/d;
den_sig=sig(elc,:)-b*sig(1,:);
figure(1)
subplot(5,1,elc-1);title('observed EEG');plot(sig(elc,:));
% subplot(3,1,2);title('horizontal EOG');plot(sig(1,:));
figure(2)
subplot(5,1,elc-1);title('denoise processed');plot(den_sig);
end