Getting strange distortion with bandpass filter, what could be issue?

69 views Asked by At

I am trying to bandpass filter an EEG signal, nothing fancy but it's coming out pretty distorted. EEG data is taken from forehead. Sampling rate is 250 Hz. Cutoff is 2.5 Hz & 120 Hz.

Tried in both matlab & python, getting same results.

Matlab code:

data = load("rawdata.mat");
data = data.data;
figure
bandpass(data,[2.5 120],250)

Matlab filtered data, click here to see plot

Here is the python code:

Fs = 250
lowcut = 2.5
highcut = 120
order=5

plotbutterworth(lowcut, highcut, Fs, order)

plt.figure()
fr, y_m = Fourier(250, data)
plt.stem(fr, y_m, use_line_collection = True)
plt.title('Freq CH7')
plt.xlabel("Frequency (Hz)")
plt.ylabel("Amplitude (microvolts)")

filtered = butter_bandpass_filter(data, lowcut, highcut, Fs, order)

plt.figure()
fr, y_m = Fourier(250, filtered)
plt.stem(fr, y_m, use_line_collection= True)
plt.title('Freq CH7 -- without EKG')
plt.xlabel("Frequency (Hz)")
plt.ylabel("Amplitude (microvolts)")

plt.figure()
plt.plot(data)
plt.plot(filtered)
plt.xlabel("Time")
plt.ylabel("Amplitude (microvolts)")
plt.legend(['original','filtered'],loc='best')

Python butterworth bandpass filter

fft of original data

fft of filtered data

raw & filtered data in time domain

Have tried changing cutoff frequencies slighting so less close to edge (like 5Hz and 110 Hz) but haven't found any noticeable improvement

1

There are 1 answers

1
Iluv BCI On

Remove DC offset by subtracting mean!