- class FilterBank(fs: float, channels: int, f_min: float, f_max: float, order: int, filter_type: Literal['butterworth', 'gammatone', 'sos'] = 'butterworth', **kwargs)[source]¶
Bases:
ABCA filter bank for decomposing signals into frequency components.
This class decomposes input signals into frequency components using filter banks. Supported filter types are Butterworth, Gammatone, and second-order section (SOS) filters. The filter bank automatically computes center frequencies and frequency bands for each channel.
Code Example:
import numpy as np from spikify.filters import FilterBank fs = 1000 signal = np.random.randn(1000) filterbank = FilterBank(fs=fs, channels=4, f_min=100, f_max=800, order=2) freq_components = filterbank.decompose(signal)
- Parameters:
fs (float) – Sampling frequency of the input signal.
channels (int) – Number of filter channels.
f_min (float) – Minimum frequency for the filter bank.
f_max (float) – Maximum frequency for the filter bank.
order (int) – Order of the filters.
filter_type (str) – Type of filter (‘butterworth’, ‘gammatone’, ‘sos’).
kwargs (dict) – Additional filter parameters.
- Raises:
ValueError – If filter_type is not supported.
- Attributes:
center_frequenciesCenter frequencies for each filter channel.
Methods
decompose(signal)Decompose input signal into frequency components using the filter bank.
- decompose(signal: ndarray) ndarray[source]¶
Decompose input signal into frequency components using the filter bank.
This method applies each filter in the bank to the input signal and returns the filtered outputs for all channels.
- Parameters:
signal (numpy.ndarray) – Input signal to be decomposed. Should be a 1D or 2D numpy array. If 2D, shape should be (timestamps, features).
- Returns:
Array of filtered signals with shape (timestamps, channels, features).
- Return type: