GaborFilterbank¶
gabor
¶
Gabor Filterbank and RSF Extraction
Implements 2D Gabor filters for spectro-temporal modulation analysis, following Bellur & Elhilali (2017).
Pipeline: 1. Cached: 2D Gabor kernels tuned to (rate, scale) pairs, plus their FFTs 2. Hot path: FFT input spectrogram → broadcast multiply → batch IFFT → magnitude → frame integration
Memory-adaptive: at high resolutions the kernel FFT cache can exceed GPU memory. When it would, falls back to streaming mode (kernels are rebuilt and FFT'd per chunk inside the compute loop). Slower per call but works on any GPU, including lower-memory devices like the Jetson Orin Nano.
PARAM_OPTIONS
module-attribute
¶
PARAM_OPTIONS = {'sigma_t': array([1 / 1.4, 1 / 1.6, 1 / 1.8, 1 / 2.0, 1 / 2.2, 1 / 2.4, 1 / 2.6]), 'sigma_f': array([1 / 1.4, 1 / 1.6, 1 / 1.8, 1 / 2.0, 1 / 2.2, 1 / 2.4, 1 / 2.6]), 'theta': radians(array([-4.5, -3.0, -1.5, 0.0, 1.5, 3.0, 4.5])), 'alpha': array([0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3])}
Per-kernel Gabor parameter options for adaptive (GA) tuning.
Each entry is a discrete grid of candidate values. A genetic algorithm
or other tuner emits a 4-column integer array indexing into these
grids, which :meth:GaborFilterbank.compute decodes per kernel.
DEFAULT_PARAM_IDX
module-attribute
¶
Index into each :data:PARAM_OPTIONS grid that selects the canonical
(untuned) Gabor parameters used by the default cached path.
GaborFilterbank
¶
GaborFilterbank(config: Config | None = None)
2D Gabor filterbank for spectro-temporal modulation analysis.
Each filter is tuned to a (rate, scale) pair, where rate is
the temporal modulation in Hz and scale is the spectral
modulation in cycles/octave.
Dispatch is memory-adaptive. If the full kernel-FFT cache fits in
the available memory budget (see :data:_CACHE_MEMORY_BUDGET), the
cached batched path is used. Otherwise the filterbank emits a
:class:ResourceWarning and falls back to a streaming path that
rebuilds and FFTs kernels per chunk — slower per call, but works at
arbitrary resolution and on low-memory devices.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Configuration object. If
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
rates |
Temporal modulation rates in Hz, length
TYPE:
|
scales |
Spectral modulation scales in cycles/octave, length
TYPE:
|
use_gpu |
Whether GPU acceleration is active.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
| WARNS | DESCRIPTION |
|---|---|
ResourceWarning
|
At construction time if the chosen resolution produces more
than :data: |
compute_device
¶
Process a device-resident spectrogram and return RSF on device.
Hot path. Memory-adaptive dispatch:
- Default mode (
params is None): try to cache kernel FFTs. If they fit, use the batched cached path. If not, fall back to streaming. - GA mode (
paramsgiven): always stream. Kernels change per call, so caching has no benefit, and this avoids GA's own OOM risk at high resolution.
| PARAMETER | DESCRIPTION |
|---|---|
spec_device
|
Spectrogram of shape
TYPE:
|
params
|
Per-kernel parameter indices of shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ndarray or ndarray
|
RSF tensor of shape |
compute
¶
compute(spectrogram: Spectrogram, params: ndarray | None = None) -> RSF
Compute the RSF representation from a spectrogram, returning a host dataclass.
Wraps :meth:compute_device with the necessary input transfer
and a host copy of the result.
| PARAMETER | DESCRIPTION |
|---|---|
spectrogram
|
Auditory spectrogram. If a raw 2D array is passed, it is
assumed to be in
TYPE:
|
params
|
Per-kernel parameter indices of shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RSF
|
Host-side RSF with |