Description of the problem
While filtering a rather long recording, I came across (to me) unexpected behavior in causal filters: they do not remove the DC offset for me. I compared the behavior to the zero-phase filter and there the results are as expected. (Baseline correction is not an option for my use case.)
I discussed this briefly with @larsoner already, who suggested to test on a synthetic data example:
Steps to reproduce
import mne
import numpy as np
data = np.zeros((100, 10000))
data[:] = np.linspace(-1, 1, 100)[:, np.newaxis]
info = mne.create_info(100, 1000, ch_types='mag')
# causal filter
evoked = mne.EvokedArray(data, info, tmin=0.0)
evoked.filter(0.5, None, phase='minimum')
evoked.plot();
# non-causal filter
evoked = mne.EvokedArray(data, info, tmin=0.0)
evoked.filter(0.5, None)
evoked.plot();
Expected results
The zero-phase non-causal filter behaves as expected:

Actual results
The causal minimum phase filter does not behave as epxected:

This is in line with what I observe on actual MEG data.
Additional information
I am in a fresh conda env and on main with scipy version 1.11.4.
@larsoner predicts this to be a problem with scipy.signal.minimum_phase and that is indeed the difference in our filter.py code between causal and non-causal filters.
I can look into this more - but could use some guidance on how to decide how/where a fix would be necessary (if this is indeed in need of a fix).
Description of the problem
While filtering a rather long recording, I came across (to me) unexpected behavior in causal filters: they do not remove the DC offset for me. I compared the behavior to the zero-phase filter and there the results are as expected. (Baseline correction is not an option for my use case.)
I discussed this briefly with @larsoner already, who suggested to test on a synthetic data example:
Steps to reproduce
Expected results
The zero-phase non-causal filter behaves as expected:

Actual results
The causal minimum phase filter does not behave as epxected:

This is in line with what I observe on actual MEG data.
Additional information
I am in a fresh conda env and on
mainwithscipyversion1.11.4.@larsoner predicts this to be a problem with
scipy.signal.minimum_phaseand that is indeed the difference in ourfilter.pycode between causal and non-causal filters.I can look into this more - but could use some guidance on how to decide how/where a fix would be necessary (if this is indeed in need of a fix).