Skip to content

← signal_processing package

IIRFilter

Apply IIR filter to signal.

Together with the FIR filter, this is one of the two default ways to select or remove frequency bands in a signal. The IIR filter delays the signal less than the FIR filter, at the cost of increased signal phase distortion, especially in the region between passband (retained frequencies) and stopband (suppressed frequencies). The IIR filter is also less CPU intensive for the same amount of filtering. This filter maintains internal state to filter seamlessly across chunk boundaries. On the first few samples the filter will exhibit some minor artifacts, but is initialized to have minimal step response. Note that filter instability is not a concern with this implementation, since it is realized as a cascade of second-order sections (or biquads), rather than a simple direct-form I or II filter design. More Info... Version 1.1.0

Ports/Properties

data

Data to process.

verbose name
Data
default value
None
port type
DataPort
value type
Packet (can be None)
data direction
INOUT

axis

Axis along which to filter. Rarely anything other than 'time' is used here.

verbose name
Filter Along Axis
default value
time
port type
ComboPort
value type
str (can be None)

order

Filter order. If unspecified, this will be auto-determined based on the tightness of the transition bands and the desired attenuation strength, except for the 'freeform' filter mode and the 'Bessel' filter design, where it must be given. A larger order (e.g., 8 or higher) will result in larger signal delay, but can handle steeper and more complex frequency responses.

verbose name
Filter Order
default value
None
port type
IntPort
value type
int (can be None)

frequencies

Transition frequencies. For a lowpass/highpass filter, you can either give the cutoff frequency, or two freqencies to determine the rolloff curve. For a bandpass/bandstop filter, you can give two cutoff frequencies, or 4 frequencies to determine the rolloff curve. The syntax for 'free-form' filters is [(frequency1, gain1), (frequency2, gain2), ...], and you can use the special frequency value -1 as a stand-in for the highest frequency at which a filter can be designed for the given sampling rate (the signal's Nyquist frequency).

verbose name
Frequencies
default value
[0.1, 0.5, 45, 50]
port type
ListPort
value type
list (can be None)

mode

Filter mode. Low/highpass lets low/high frequencies through, bandpass lets frequencies in a limited band through, and bandstop (a.k.a. notch) removes frequency in a limited band. The freeform mode (rarely used) can design arbitrary filters by specifying frequencies in the spectrum and corresponding desired gain factors.

verbose name
Filter Mode
default value
bandpass
port type
EnumPort
value type
str (can be None)

design

Filter design rule to use. A Butterworth filter has a flat passband response, Chebychev Type-I has a steeper rolloff than Butterworth at the expense of larger passband ripples, and Chebychev Type-II also has steeper rolloff but larger stopband ripples. The Elliptic filter has maximally steep rolloff at the cost of larger ripple in both stopband and passband. The Bessel filter has a maximally linear phase response, meaning that the signal in the rolloff region is least distorted. For a freeform filter, the Yule-Walker method is always used and the design parameter is ignored.

verbose name
Filter Design
default value
butter
port type
EnumPort
value type
str (can be None)

stop_atten

Minimum attenuation in stopband. This is the minimum acceptable attenuation, in dB, in the stopband, which is ideally infinitely suppressed, but in practice 30-80 dB are enough, depending on the amplitudes of the signals to attenuate.

verbose name
Min Stopband Attenuation
default value
50.0
port type
FloatPort
value type
float (can be None)

pass_loss

Maximum attenuation in passband. This is the maximum amount of signal attenuation, in dB, that is tolerated in the passband (which is ideally flat, i.e., 0 dB deviation).

verbose name
Max Passband Attentuation
default value
3.0
port type
FloatPort
value type
float (can be None)

ignore_nans

If activated the channels containing nan values are ignored.

verbose name
Ignore Channels With Nan Values
default value
False
port type
BoolPort
value type
bool (can be None)

offline_filtfilt

If the signal is not streaming (i.e ., offline), then perform a zero-phase filtfilt operation. As a result, the signal experiences zero time shift, and consequently no time-stamp correction is necessary.

verbose name
Forward-Backward Filtering (Noncausal)
default value
False
port type
BoolPort
value type
bool (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

verbose name
Set Breakpoint (Debug Only)
default value
False
port type
BoolPort
value type
bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

verbose name
Metadata
default value
{}
port type
DictPort
value type
dict (can be None)