Does `nilearn.signal.butterworth` pad the signal with 0s?

Does nilearn.signal.butterworth pad the signal with 0s (how many?) prior to applying the butterworth filter, and then remove them afterwards? This is important (Boore, 2005). If so, can the documentation be amended to include this detail? If not, why is the signal not padded?

Hi Ellyn,

The source code for that function is here: nilearn/ at 98a3ee060b55aa073118885d11cc6a1cecd95059 · nilearn/nilearn · GitHub

You can see that it is essentially a wrapper around scipy.signal.filtfilt. It looks like the function does not change from the default padding, which you can read more about on the scipy link in the previous sentence. I am not a scipy or nilearn developer, so I cannot say exactly what it is being padded with, but I think it is safe to say the signal is padded with a length that is dependent on the length of the coefficient vectors that define the filter. Hope that helps.


Hi @butellyn ,

@Steven provided the correct place to look for the answer to your question.

If you feel this is needed to be addressed in the documentation, or a different default value other than the scikit-learn default is needed, feel free to open an issue and pull request on the nilearn repository! If you have questions on how to contribute, we are here to help.



Looks like there is 0 padding by default: scipy.signal.filtfilt — SciPy v1.9.2 Manual