Sep-26-2019, 05:10 AM
I am posting my digital filter code below:
from scipy import signal from EEG import eeg_data import array as arr sample_rate = 250 nyquist_rate = sample_rate/2 gMax_Blocks = 32 gMax_Samples = 8 gMax_Channel = 4 # Cofficient for IIR filters b2 = arr.array('d',[0.965080986344733, -0.242468320175764, 1.94539149412878, -0.242468320175764, 0.965080986344733]) a2 = arr.array('d',[1, -0.246778261129785, 1.94417178469135, -0.238158379221743, 0.931381682126902]) b = arr.array('d',[0.200138725658073, 0, -0.400277451316145, 0, 0.200138725658073]) a = arr.array('d',[1, -2.35593463113158, 1.94125708865521, -0.784706375533419, 0.199907605296834]) def apply_filter(): fc = 0.5 # Cut-off frequency of the filter w = fc / (sample_rate / 2) # Normalize the frequency b, a = signal.butter(2, w, 'high') for line in eeg_data: output = arr.arry('d',[signal.filtfilt(b, a, line)])