If you have a question or issue with MNE-Python, please include the following info:
MNE version: 1.7.1
operating system: Windows 10
Hi,
I am new to MNE-python and I apologise if this is an elementary question. I am trying to apply a stopband over a passband. I want to achieve this:
Continuous EEG signals were bandpass filtered (standard non-causal two-pass Butterworth filters) between 0.1 and 100 Hz and bandstop filtered (48–52 and 98–102 Hz) to remove line noise at 50 and 100 Hz.
What I planned to do was first do the bandpass filter and then the two bandstop filter. Then I tried to use the following code:
I recommend that you use raw.filter() directly, there should be no need for .get_data(). I’d also apply the three filters sequentially. Furthermore, since you want a Butterworth filter, you should provide the method="iir" argument.
raw_eeg_subj2.filter(0.1, 100, method="iir")
These operations work in place, so after applying the first filter, you can apply the notch filters:
These two notch filters use the default FIR method, but of course you can change it with the method argument if that’s not what you want. If you still get an error message regarding the stop band, let us know here!
I haven’t looked at the implementation, but raw.notch_filter() allows you to specify multiple frequencies to filter (e.g. harmonics), so this is very convenient. I would expect that both methods should work, but raw.notch_filter() should probably be preferred in most cases.
Thank you very much for the answer and for mentioning how to apply a Butterworth filter! I tried both the filter() and notch_filter(). With the notch_filter(), it works:
To be honest, I don’t know why raw.filter() does not work for a notch filter. In my opinion, it should be possible to use it as well (for example because the documentation includes band stop filters), so it’s maybe because of some parameters not working out (both methods internally dispatch to mne.filter.filter_data()). @larsoner do you have an idea and/or an opinion? If there is really a conceptual issue why notch filters cannot be applied with raw.filter(), there should at the very least be a note in the docs.