python中的savitzky-Golay过滤器,错误的窗口大小

时间:2021-04-08 09:37:14

标签: python numpy signal-processing

我有一个时间序列数据,我想使用 Savitzgy Golay 过滤器进行平滑处理。根据这里的研究: https://arxiv.org/ftp/arxiv/papers/1808/1808.10489.pdf

窗口大小应为 n+2,其中 n -> 多阶。 我对我的数据进行了这样的平滑处理,但我看不到信号的结果。我是否选择了错误的窗口大小?

我的数据是具有 (50858, 2) 形状的 EMG 信号,具有 temg 列,其中 emg 是要降噪的值。这是它的头。

enter image description here

过滤器实现:

Y= data.iloc[:,1].values
Y_filtered= savgol_filter(Y, window_length = 5, polyorder = 3) 并绘制它:


plt.subplot(1, 2, 1)
plt.plot(Y[-1000:])
plt.title("EMG with noise")


plt.subplot(1, 2, 2)
plt.plot(Y_filtered[-1000:])
plt.title("SG filter applied ")
plt.tight_layout()
plt.show()

enter image description here

1 个答案:

答案 0 :(得分:1)

窗口大小不限于n+2。不过,这一定很奇怪。我试过 window_size=21polyorder=3 并且它有效。 我认为您不太可能在数千个样本信号中看到窗口大小 = 5 的结果,因为您的噪声可能跨越更多样本。尝试使用更大的窗口大小。

相关问题