from scipy.signal import butter, lfilter
# 带通滤波器
def butter_bandpass_filter(data, lowcut, highcut, fs, order):
low = lowcut * 2 / fs
high = highcut * 2 / fs
b, a = butter(order, [low, high], btype='bandpass')
y = lfilter(b, a, data)
return y
# 初始信号 data: NumPy Tensor (Sample, EEG Channels, Time Length)
data = np.ndarray([200, 20, 3840])
data = butter_bandpass_filter(data, 0.5, 50, 128, 4) # 0.5-50Hz 带通滤波
标签:butter,fs,signal,highcut,0.5,scipy,data,bandpass
From: https://blog.51cto.com/u_13946099/6236734