# Scipy.signal.iirfilter equivalent in DSP.jl and more

**URL:** <https://discourse.julialang.org/t/scipy-signal-iirfilter-equivalent-in-dsp-jl-and-more/110783>\
**Category:** Signal and Image Processing\
**Created:** [February 26, 2024, 2:44pm UTC](https://discourse.julialang.org/t/scipy-signal-iirfilter-equivalent-in-dsp-jl-and-more/110783 "2024-02-26T14:44:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scelles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scelles/32/220408_2.png) [@scelles](https://discourse.julialang.org/u/scelles)\
**Post date:** [February 26, 2024, 2:44pm UTC](https://discourse.julialang.org/t/scipy-signal-iirfilter-equivalent-in-dsp-jl-and-more/110783/1 "2024-02-26T14:44:02Z")

</div>

Hello,

I did some DSP about 20 years ago but didn’t tackled that field recently.  
In order to get back to it I’m planning to build some Pluto.jl notebooks in this field.

I found this blog post [Applying digital filters in Python - Samuel Pröll - Homepage](https://www.samproell.io/posts/yarppg/digital-filters-python/) which deals with IIR filters with Python

I wonder what is scipy.signal.iirfilter equivalent in Julia / DSP.jl.

I also wonder if some efforts have been made to build “live” digital filters as suggested in [Digital filters for live signal processing in Python - Samuel Pröll - Homepage](https://www.samproell.io/posts/yarppg/yarppg-live-digital-filter/)  
I wonder if OnlineStats.jl couldn’t be a nice “framework” for this kind of implementation.

Kind regards

---

<div class="post-metadata">

**Author:** ![mgkuhn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgkuhn/32/6276_2.png) [@mgkuhn](https://discourse.julialang.org/u/mgkuhn)\
**Post date:** [February 26, 2024, 3:13pm UTC](https://discourse.julialang.org/t/scipy-signal-iirfilter-equivalent-in-dsp-jl-and-more/110783/2 "2024-02-26T15:13:26Z")

</div>

> I wonder what is scipy.signal.iirfilter equivalent in Julia / [DSP.jl](https://juliahub.com/ui/Packages/General/DSP).

If you provide a complete example call to `scipy.signal.iirfilter`, we can try to offer equivalent `DSP.jl` method invocations.

For example

```julia
vf = filt(digitalfilter(Lowpass(bw; fs), Butterworth(3)), v)

```

applies a 3-rd order Butterworth filter with cut-off frequency `bw` to signal vector `v` with sampling frequency `fs`, in case that helps.

The [manual](https://docs.juliadsp.org/stable/filters/) unfortunately doesn’t contain much in terms of examples for beginners right now, except for a couple hidden [at the end of that filters page](https://docs.juliadsp.org/stable/filters/#Examples).

---

<div class="post-metadata">

**Author:** ![scelles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scelles/32/220408_2.png) [@scelles](https://discourse.julialang.org/u/scelles)\
**Post date:** [February 26, 2024, 5:55pm UTC](https://discourse.julialang.org/t/scipy-signal-iirfilter-equivalent-in-dsp-jl-and-more/110783/3 "2024-02-26T17:55:25Z")

</div>

Thanks @mgkuhn. Sorry my question wasn’t clear enough.

I did a Pluto notebook to test that.

Here is a screenshot showing how to process a vector of input values

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/6/a6be761e38e84add9f92b3d58386252b87374e7c.png)

and an other one showing how it performs with “live” incoming data

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/d/ed8437beb185c1d7ff51b4e7848eb938bf09a050.png)

Here is code [Some experiments with DSP.jl and filtering · GitHub](https://gist.github.com/scls19fr/0ae16d92ca39d3eb9c42cc0fc618c723)

In this implementation `filt` calculates output of filter for input which is a vector using

```
output_values_signal_1 = filt(filter, cb_input_signal_1)

```

I don’t think that’s a good idea when performing “live” signal processing.

I wonder if (more exactly how) I can feed `filter` with only one value at a time (ie not a vector or a circular buffer).

I tried

```
output_signal_1 = filt(filter, input_signal_1)

```

but it raises a `StackOverflowError`

Any idea?

---

<div class="post-metadata">

**Author:** ![scelles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scelles/32/220408_2.png) [@scelles](https://discourse.julialang.org/u/scelles)\
**Post date:** [February 26, 2024, 8:46pm UTC](https://discourse.julialang.org/t/scipy-signal-iirfilter-equivalent-in-dsp-jl-and-more/110783/4 "2024-02-26T20:46:15Z")

</div>

One problem of the current implementation can be shown here (input signal is rolling)

![image](https://global.discourse-cdn.com/julialang/original/3X/1/8/18cf034f1f6dfc9207b0673cbbf02fe15d6c6872.png)

orange signal (filtered signal) starts from 0, it should start from it’s previous value (so nearer from -1).

filter should “keep” an internal state
