0
$\begingroup$

I am working on an EEG Signal analysis problem with python. I need to remove the recordings below 1st minute and above 6th minute of the signal, and pass it through a bandpass filter. I am not familiar with MNE so used scipy for trimming and filtering after converting it into raw NumPy array format. The code is given below. Since the sampling rate is 100 Hz, I assumed the first minute will contain 6000 samples and the next five minutes will contain 30000 more samples which are why I am only taking raw_data[i][6000:36000].

filtered_data[i] = butter_bandpass_filter(raw_data[i][6000:36000], lowcut, highcut, fs, order=5)

butter_bandpass_filter is defined as follows

def butter_bandpass(lowcut, highcut, fs, order=5):
   nyq = 0.5 * fs
   low = lowcut / nyq
   high = highcut / nyq
   b, a = butter(order, [low, high], btype='band',analog=True)
   return b, a

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

But I don't feel like this is the correct method. Is there a way to do the above-mentioned task using MNE-Python instead of converting it to ndarray or using scipy?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.