有几种方法可以去除基线漂移。
1.matlab内置函数detrend
不适合非线性复杂的信号
2 .通过小波变换去除基线漂移小波
函数将DeBaseline_Wavelet定义为缩放函数
功能y=de baseline _ wavelet (x )
s=x; 获取要%处理的信号。 x是上面. mat中的参数
%信号整体长度
n=numel(s;
%小波分解;
maxlev=7; %分解6标尺7层
wavename='db6 '; %小波函数名称(根据信号) ) ) ) ) )。
[C,l]=wavedec(s,maxlev,wavename );
%提取分解后的近似系数和详细系数
a7=appcoef(c,l,wavename,7 );
D1=detcoef(C,l,1 );
D2=detcoef(C,l,2 );
D3=detcoef(C,l,3 );
D4=detcoef(C,l,4 );
D5=detcoef(C,l,5 );
D6=detcoef(C,l,6 );
D7=detcoef(C,l,7 );
D1=Zeros(1,Length ) D1 ) '; %高频去噪
D2=Zeros(1,Length ) D2 ) ';
A7=Zeros(1,Length ) A7 );
C2=[A7、D7 '、D6 '、D5 '、D4 '、D3 '、D2 '、D1']; %新系数
y=(waverec(C2,l,wavename ) ) ); %重新配置解除基线后的信号
结束
3 .低通滤波器
首先进行低通滤波,从原信号中减去而得到的趋势信号是解除趋势后的信号
sig_raw=lfp4;
nlen=Length(SIG_raw;
fs=1000; %采样频率可通过软件设置
Ts=1/fs; %时间间隔是采样频率的倒数
fmaxd=5; %截止频率为3Hz
fmaxn=fmaxd/(fs/2 );
[b,a]=butter(1,fmaxn,' low ' );
DD=文件文件(b、a、lfp4 ); 通过5Hz低通滤波器的信号
Y1=lfp4-dd; %去除该信号,得到去除基线偏移的信号
%绘图
subplot (3,1,1 ),plot ) LFP4,' b ' ); 原始信号;
subplot (3,1,2 ),plot ) DD,' b ' ); 趋势线;
subplot (3,1,3 ),plot ) y1,' b ' ); xlabel (“去除基线偏移的信号”)
4 .高通滤波器
直接设置高通滤波器去除小于3Hz的信号即可
使用%高通滤波器移除基线偏移
清除器
加载(x; %load your raw sinal
sig_raw=x;
nlen=Length(SIG_raw;
fs=1000; %采样频率可通过软件设置
Ts=1/fs; %时间间隔是采样频率的倒数
%高通过滤器
[bbw,abw ]=cheb y1 (4,0.5,1.5/180,' high ' );
y1=文件文件(bbw、abw、lfp4 );
figure(1)。
subplot (2,1,1 ),plot ) SIG_raw; 原始信号;
subplot (2,1,2 )、plot (y1); xlabel (“去除基线偏移的信号”)