FFT filter to analyze data

Hello, so I am using the MNE as a tool to analyze my data and I was looking at the structure of the filter function in github and saw that the “method” parameter has the option to do a FFT, but from what I understood it does a FIR filter. Could you explain to me why it works that way please? If you guys used FFT as a way to make the filter faster or something else, because I wanted to do a FFT in my data using MNE but I’m a little confused how I could do that. @larsoner

Yes the method='fft' is just a backward compatible shortcut for method='fir' (they should share the same code path and do the same thing).

Whenever a FIR filter is used, all we are doing is something mathematically equivalently (under the hood) to a time-domain convolution of the FIR filter kernel and the signal. There are lots of ways to do this quickly, such as direct convolution, fft-based convolution in the frequency domain, or overlap-add convolution, which correspond to the following SciPy functions:

In MNE what we do is the overlap-add approach, just using our own code rather than SciPy’s. I’m not sure of a good resource to understand all of these options other than a textbook like Oppenheim and Shafer’s Discrete-time Signal Processing.

For what it’s worth, none of these (equivalent) approaches implements a frequency-domain brick-wall filter (i.e., take the FFT of the entire signal, zero out components, and inverse transform) if that’s what you were thinking of, because this has some undesirable properties (e.g., bad ringing, assumes signal periodicity) that are better to avoid if possible.

2 Likes