Hello. I finished the chapter on the Hilbert transformation from the ANTS book recently and was wondering about filters other than FIR (
In my legacy pipeline, the filter applied is the Butterworth filter which is used as a band-pass filter from 1-30Hz. When I plot the filtered data, it is nicely placed on the “0-line” (green line). I asked around why this happens exactly, and I found out that the filter subtracts the mean of the data time series at each data point. I plotted the same data but this time with the mean added to get the black data time series.
My pipeline is supposed to baseline correct after this filtering step from the pre-stimulus period (t = 0-500 in this case, sorry about the badly labelled axis) so:
- Am I supposed to manually fix the output in green so it does not have this offset? Stated differently, when I read in papers “a band-pass filter was applied to the data” would the resulting signal look like the green one (bandpass with DC offset) or the black one (bandpass with DC offset removed after filtering)?
- Is this offset actually what I think it is (offset from mean of the whole signal)—or is it just due to removal of very low frequency signals?
Hi Asimio. Yes, you can use the Hilbert transform with IIR filters as well. IIR and FIR filtered results are mostly very comparable. In general, FIR filters tend to have less distortion with phase values. IIR filters were preferred a long time ago because they are more computationally efficient. But modern computers can easily handle FIR filters, so other than “legacy” (i.e., it’s what your 80-year-old advisor did in the 80s ) reasons, I usually recommend FIR filters.
As for the mean-centering: Yes, your observation is correct that any filter involving a high-pass will remove the mean. The reason is that the average value of the signal is encoded in the 0 Hz frequency. So if you filter from 1-30 Hz, you’re removing 0 Hz, which means you’re removing the mean.
You do not need to “fix” that per se, but it’s completely fine to add back the DC offset. The way to do that is to compute the mean of the pre-filtered signal and then add that constant back to the post-filtered signal.
Great. Thanks a lot for the explanation, I had not appreciated what it meant to filter 0hz until now . We are actually transitioning away from using BESA (software for MEG recordings) and to make the transition smooth we wanted to use filters similar to BESA. Unfortunately, they do not reveal their methods (a good reason not to use the software imo) and so some of my colleagues tried a bunch of different filter methods and Butterworth seemed to match it the best. Next step is to “upgrade” to FIR filters, thanks again!