我正在尝试做fft来去除信号中的噪声。在这样做的同时,我得到了类似于此Freq_域的频域:
因此,当对信号的峰值频率应用黄油通滤波器时,会像原始图像一样过度平滑:
应用黄油通过过滤器后的图像:
所以我被困在这个问题上,想找出减少信号过度平滑的解决方案
for i in range(data_first_interval.shape[0]):
ppgwave=data_first_interval.loc[i]
ppg_fit=fftpack.fft(np.array(ppgwave))
ppgarr=np.array(ppgwave)
amp=2 / time_vec.size*np.abs(ppg_fit)
sample_freq=fftpack.fftfreq(2100,0.001)
signal_amplitude = pd.Series(amp).nlargest(2).round(0).astype(int).tolist()
magnitudes = abs(ppg_fit[np.where(sample_freq >= 0)])
#Get index of top 2 frequencies\
peak_frequency = np.sort((np.argpartition(magnitudes, -2)[-2:])/2.1)
cutoff = peak_frequency[1]
y = butter_lowpass_filter(ppgarr, cutoff, fs, order)
data_first_interval.loc[i]=y
我的低通滤波器定义如下
fs = 1000.0
order = 2
def butter_lowpass_filter(data, cutoff, fs, order):
print("Cutoff freq " + str(cutoff))
nyq = 0.5 * fs # Nyquist Frequency
normal_cutoff = cutoff / nyq
# Get the filter coefficients
b, a = butter(order, normal_cutoff, btype='low', analog=False)
y = filtfilt(b, a,data)
return y
谁能帮我找出哪里出了问题
通常,产生“较少平滑”的方法是提高截止频率
使用平滑过滤器,可以使用两个参数:
截断:截断值越高,平滑度越低;较低的截止值产生更多的平滑
阶数(与“滚降”相关):阶数越高,低频失真越小,但可能导致振铃。低阶振铃较少,但可能会使截止频率以下的频率失真。这也可能表现为过度平滑
相关问题 更多 >
编程相关推荐