简体   繁体   English

这个巴特沃斯滤波器有什么问题

[英]what is the problem in this butterworth filter

i am trying to remove the base wander noise from ecg signal, base wander noise is low-frequency artefact of around 0.5Hz, for that i tried a digital butterworth highpass filter:我试图从 ecg 信号中去除基漂移噪声,基漂移噪声是大约 0.5Hz 的低频伪像,为此我尝试了数字巴特沃斯高通滤波器:

code of filter过滤器代码

在此处输入图像描述

frequency response频率响应

在此处输入图像描述

the ecg signal used is the record 100 from mit bih arrhythmia data base ( record sampled at 360 samples per second), first i read the record using wfdb package and then i applied the filter on it, but the result looks something like this:使用的 ecg 信号是来自 mit bih 心律失常数据库的记录 100(以每秒 360 个样本采样的记录),首先我使用 wfdb package 读取记录,然后我对其应用过滤器,但结果看起来像这样:

code of filtering the signal信号过滤代码

在此处输入图像描述

the result结果

在此处输入图像描述

the result looks kinda off.结果看起来有点不对劲。 i want to know where is the problem?我想知道问题出在哪里?

I think the problem is that your filter does not know the time step of your dataset, particularly in your call to bilinear where you explicitly give a sampling frequency of 1.我认为问题在于您的过滤器不知道数据集的时间步长,特别是在您对bilinear的调用中,您明确给出了 1 的采样频率。

To demonstrate, let's start with a pretty strong signal:为了演示,让我们从一个非常强的信号开始:

import numpy as np
import matplotlib.pyplot as plt

N = 1_000
T = 4.
tau = 0.25 # period of signal, frequency of 4 Hz
f = 1 / tau # frequency
omega = 2 * np.pi * f # angular frequency

t, dt = np.linspace(0, T, N, endpoint = False, retstep = True)
fs = 1 / dt # sampling frequency in Hz

noise = np.random.random(N)
sig = np.sin(t * omega)
x = 0.2 * noise + sig

plt.plot(t, x)
plt.xlabel('time')

signal_only

Now let's start with the filter you've developed.现在让我们从您开发的过滤器开始。 My wave is higher frequency than your cutoff so it should be caught, but it isn't.我的波的频率高于你的截止频率,所以它应该被捕获,但事实并非如此。

from scipy import signal
b, a = signal.butter(4, 0.5, 'high', analog = True, output = 'ba')
z, p = signal.bilinear(b, a, 1.)

x_filt = signal.lfilter(z, p, x)
plt.figure()
plt.plot(t, x)
plt.plot(t, x_filt)
plt.xlabel('time')

信号_2

Note that in your call to bilinear you are setting a sampling frequency of 1. Let's instead use our sampling frequency (defined above as fs ).请注意,在您对bilinear的调用中,您将采样频率设置为 1。让我们改为使用我们的采样频率(上面定义为fs )。

z, p = signal.bilinear(b, a, fs)
x_filt = signal.lfilter(z, p, x)
plt.figure()
plt.plot(t, x)
plt.plot(t, x_filt)
plt.xlabel('time')

时间步长

As a last note, you may sometimes observe a phase shift with Butterorth filters.最后一点,您有时可能会观察到 Butterorth 滤波器的相移。 Again, I am not an expert and have only ever used them in cases where I was not worried about the phase, but see here for suggestion on using a different type of filter if this is an issue.同样,我不是专家,只在我不担心相位的情况下才使用它们,但如果这是一个问题, 请参阅此处以获取有关使用不同类型过滤器的建议。 The comments here also suggest using a different filter for this reason.出于这个原因, 此处的评论还建议使用不同的过滤器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM