I have EEG data recorded with a sampling rate of 256 Hz. Each recording contains 19 EEG channels. Other channels (like ECG data) are ignored. The recordings of 10 patients are 20 minutes long each, recordings of 2 other patients cover a period of 24 hours each. The long recordings contain sections where the recording device obviousely was turned off, so that flat lines appeared in the recording. I cut those recordings in smaller chunks at these flat-line sections, so that no chunk contains flat lines. But some of the chunks still are longer than 6 hours.
Some recordings are contaminated by 50 Hz mains hum that was not properly filtered out during recording. And in almost all recordings the means value of many channels is far away from 0 mV, so there is a constant voltage added to the channels.
In my research I am interested in short spikes that have a duration of typically 0.3 to 0.5 seconds. These skipes look similar to Morlet wavelets or Ricker wavelets. I want to detect these spikes with methods of machine learning.
To get rid of that 50 Hz main hum and to also eliminate that constant voltage and very low frequencies, I applied a butterworth band pass filter with these parameters:
- lowcut = 0.3
- highcut = 25
- order = 10
- nyquistFreq = 128
from scipy.signal import butter, sosfilt low = lowcut / nyquistFreq high = highcut / nyquistFreq sos = butter(order, [low, high], btype='bandpass', output='sos') # data is a numpy array containing the samples of one EEG channel filtered = sosfilt(sos, data) # filtered is the filtered version of data
The problem that I have now, is that in the resulting signals there is an overshoot signal at the beginning and also at some positions inside the signal where I have no idea why it appears there. But the more severe problem is, that the spikes I'm interested in are hard to see in the filtered signal. Harder than in the original signal. I hoped, that the spikes would appear more prominent in the filtered signal.
- Is butterworth a good filter for my task? Which other filter would be better?
- Which parameters should I use?
- Did I anything wrong in my python code?
Sorry, I have only very rudimentary knowledge about signal processing. This is not the main topic of my profession. (I come from the research fields machine learning, computer science and statistics.)