带有scipy的butterworth-bandpass-filter

时间:2013-08-11 15:14:28

标签: python scipy

我的butterworth带通滤波器有问题。我有一个用250Hz记录的1D阵列(eeg信号)。截止频率为6和11 Hz。 我现在拥有的是这个,它不起作用:

import numpy as np
import matplotlib.pyplot as plt
from pylab import *
import scipy.io
import scipy.signal
import scipy.fftpack
from scipy.signal import butter, lfilter
def butter_bandpass(lowcut, highcut, fs, order=6):
    nyq = 0.5 * fs
    low = lowcut / nyq
    high = highcut / nyq
    b, a = butter(order, [low, high], btype='band')
    return b, a


def butter_bandpass_filter(data, lowcut, highcut, fs, order=6):
    b, a = butter_bandpass(lowcut, highcut, fs, order=order)
    y = lfilter(b, a, data)
    return y


if __name__ == "__main__":
    fs = 250.0
    lowcut = 6.0
    highcut = 11.0
    t = range(len(eeg))
    x = eeg[t]
    y = butter_bandpass_filter(x, lowcut, highcut, fs, order=6)
    plt.plot(t, y)
    plt.show() 

出了什么问题?

由于 麦克

0 个答案:

没有答案