matlab 带通滤波器出现奇怪的失真,可能是什么问题?

ykejflvf  于 2023-02-23  发布在  Matlab
关注(0)|答案(1)|浏览(299)

我正试着带通滤波一个脑电图信号,没什么特别的,但它出来相当失真。脑电图数据取自前额。采样率是250赫兹。截止频率是2.5赫兹和120赫兹。
在matlab和python中尝试,得到相同的结果。
Matlab代码:

data = load("rawdata.mat");
data = data.data;
figure
bandpass(data,[2.5 120],250)

Matlab filtered data, click here to see plot
下面是python代码:

Fs = 250
lowcut = 2.5
highcut = 120
order=5

plotbutterworth(lowcut, highcut, Fs, order)

plt.figure()
fr, y_m = Fourier(250, data)
plt.stem(fr, y_m, use_line_collection = True)
plt.title('Freq CH7')
plt.xlabel("Frequency (Hz)")
plt.ylabel("Amplitude (microvolts)")

filtered = butter_bandpass_filter(data, lowcut, highcut, Fs, order)

plt.figure()
fr, y_m = Fourier(250, filtered)
plt.stem(fr, y_m, use_line_collection= True)
plt.title('Freq CH7 -- without EKG')
plt.xlabel("Frequency (Hz)")
plt.ylabel("Amplitude (microvolts)")

plt.figure()
plt.plot(data)
plt.plot(filtered)
plt.xlabel("Time")
plt.ylabel("Amplitude (microvolts)")
plt.legend(['original','filtered'],loc='best')

Python butterworth bandpass filter
fft of original data
fft of filtered data
raw & filtered data in time domain
尝试过改变截止频率,使其不太接近边缘(如5Hz和110 Hz),但没有发现任何明显的改善

ct2axkht

ct2axkht1#

通过减去平均值删除直流偏移!

相关问题