fili.js icon indicating copy to clipboard operation
fili.js copied to clipboard

Function to compute initial state for newly-created filter

Open jdpigeon opened this issue 7 years ago • 4 comments

One thing that's nice about working with scipy's linear filters is that you can compute the initial state of a filter with lfilter_zi before you pass any signal through. This eliminates ringing in many cases.

However, this functionality doesn't appear to be available in fili. I am curious what the feasibility of adding this would be?

jdpigeon avatar Feb 26 '18 20:02 jdpigeon

I'm working on this right now here: https://github.com/jdpigeon/fili.js/commit/6ff33ed68d7239eec816daff870828e8e22d24d6

jdpigeon avatar Feb 27 '18 22:02 jdpigeon

Any explanation for this functionality? How to use function? Thanks.

nikolabrdaroski avatar Oct 16 '18 18:10 nikolabrdaroski

Unfortunately, its been a while since Ive worked on this project, so I'm not entirely sure how the code I wrote integrated with fili. However, I do remember that computing the initial filter state wasn't as effective as I'd hope at reducing ringing at the beginning of the data stream in the app I was building.

I wouldn't recommend bothering going further with this idea unless you know what you're doing when ti comes to linear filter designs, but if you're interested, the computeInitialState function I wrote is functionally equivalent to this function from scipy: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.lfilter_zi.html

jdpigeon avatar Oct 16 '18 19:10 jdpigeon

At the moment there is no way to set the initial state of the filter other than 0. I could however integrate an interface that lets you do that. You can then use whatever calculation method you like to set the initial state.

markert avatar Oct 30 '18 08:10 markert