ezmsg.sigproc.filterbank#
Parallel filterbank processing with convolution, FFT, or automatic mode selection.
Functions
- filterbank(kernels, mode=FilterbankMode.CONV, min_phase=MinPhaseMode.NONE, axis=None, new_axis='kernel')[source]#
- Perform multiple (direct or fft) convolutions on a signal using a bank of kernels.
This is intended to be used during online processing, therefore both direct and fft convolutions use the overlap-add method.
Returns:
FilterbankTransformer.- Parameters:
mode (FilterbankMode)
min_phase (MinPhaseMode)
axis (str | None)
new_axis (str)
- Return type:
Classes
- class Filterbank(*args, settings=None, **kwargs)[source]#
Bases:
BaseTransformerUnit[FilterbankSettings,AxisArray,AxisArray,FilterbankTransformer]- Parameters:
settings (Settings | None)
- SETTINGS#
alias of
FilterbankSettings
- class FilterbankMode(*values)[source]#
Bases:
OptionsEnumThe mode of operation for the filterbank.
- CONV = 'Direct Convolution'#
- FFT = 'FFT Convolution'#
- AUTO = 'Automatic'#
- class FilterbankSettings(kernels: list[NDArray] | tuple[NDArray, ...], mode: ezmsg.sigproc.filterbank.FilterbankMode = <FilterbankMode.CONV: 'Direct Convolution'>, min_phase: ezmsg.sigproc.util.minphase.MinPhaseMode = <MinPhaseMode.NONE: 'No kernel modification'>, compensate_delay: bool = False, startup: ezmsg.sigproc.util.startup.StartupMode = <StartupMode.CONSTANT: "Constant pre-history at the first sample's value">, startup_max_dur: float | None = 1.0, axis: str | None = None, new_axis: str = 'kernel', bands: list[tuple[float, float]] | None = None)[source]#
Bases:
Settings- Parameters:
mode (FilterbankMode)
min_phase (MinPhaseMode)
compensate_delay (bool)
startup (StartupMode)
startup_max_dur (float | None)
axis (str | None)
new_axis (str)
- mode: FilterbankMode = 'Direct Convolution'#
“conv”, “fft”, or “auto”. If “auto”, the mode is determined by the size of the input data. fft mode is more efficient for long kernels. However, fft mode uses non-overlapping windows and will incur a delay equal to the window length, which is larger than the largest kernel. conv mode is less efficient but will return data for every incoming chunk regardless of how small it is and thus can provide shorter latency updates.
- min_phase: MinPhaseMode = 'No kernel modification'#
If not NONE, convert the kernels to minimum-phase equivalents with
min_phase_kernel(). HILBERT and HOMOMORPHIC return half-length kernels with the square root of the original magnitude response; HOMOMORPHICFULL keeps the length and magnitude response. Complex kernels support the homomorphic modes only.
- compensate_delay: bool = False#
each kernel’s delay is measured with
kernel_delay(), leading zeros are prepended so all kernels share the largest delay (to within half a sample), and that delay is subtracted from the stream axis offset. Withmin_phase=HOMOMORPHICFULLonly the kernels that would otherwise set the common delay are converted; the rest stay linear phase. HILBERT and HOMOMORPHIC still convert every kernel, since they change the magnitude response.- Type:
If True, put every kernel on one time base and stamp the output with it
- startup: StartupMode = "Constant pre-history at the first sample's value"#
What the filterbank assumes before the first sample.
CONSTANT (default): the first sample’s value held for the length of the longest kernel, so a DC offset does not ring through as a step. Every kernel starts at its steady state for that value.
ZERO: a zero pre-history, so the start of a stream matches an offline convolution.
FIRST_CHUNK, BUFFERED: an odd reflection of the first samples; see
ezmsg.sigproc.filter.FilterBaseSettings.startup, including why that suits low-pass kernels and not band-pass ones. CONV mode only: in FFT mode (including AUTO resolving to FFT) they raiseValueError.
- startup_max_dur: float | None = 1.0#
Upper limit, in seconds, on the start-up pad; None for no limit.
- axis: str | None = None#
Deprecated since version 3.8.
Scheduled for removal in 4.0. The dimension messages accumulate along now comes from
stream_dim; seeezmsg.sigproc.util.deprecation.
- bands: list[tuple[float, float]] | None = None#
Optional
(lo, hi)pass-band edges in Hz, one per kernel. If given, the output carries aCoordinateAxisonnew_axiswhose data is a structured array with fieldsloandhi. Purely descriptive; the kernels are not checked.
- __init__(kernels, mode=FilterbankMode.CONV, min_phase=MinPhaseMode.NONE, compensate_delay=False, startup=StartupMode.CONSTANT, startup_max_dur=1.0, axis=None, new_axis='kernel', bands=None)#
- Parameters:
mode (FilterbankMode)
min_phase (MinPhaseMode)
compensate_delay (bool)
startup (StartupMode)
startup_max_dur (float | None)
axis (str | None)
new_axis (str)
- Return type:
None
- class FilterbankState[source]#
Bases:
object- windower: WindowTransformer | None = None#
- mode: FilterbankMode | None = None#
- class FilterbankTransformer(*args, **kwargs)[source]#
Bases:
BaseStatefulTransformer[FilterbankSettings,AxisArray,AxisArray,FilterbankState]