Skip to content

PyGaborSTM

core

High-level user-facing class for PyGaborSTM.

Wraps :class:AuditorySpectrogram and :class:GaborFilterbank behind a single object so users don't have to manage the two stages by hand.

PyGaborSTM

PyGaborSTM(config: Config | None = None)

Main interface for spectro-temporal modulation analysis.

Holds an :class:AuditorySpectrogram and a :class:GaborFilterbank configured from the same :class:Config, and exposes both per-stage methods (:meth:spectrogram, :meth:rsf) and full-pipeline convenience methods (:meth:compute, :meth:compute_device).

PARAMETER DESCRIPTION
config

Configuration object. If None, uses defaults.

TYPE: Config DEFAULT: None

ATTRIBUTE DESCRIPTION
config

The configuration used to build both internal stages.

TYPE: Config

Examples:

>>> import pygaborstm as stm
>>> model = stm.PyGaborSTM(config=stm.Config(use_gpu=True))
>>> spec = model.spectrogram(audio)
>>> rsf = model.rsf(spec)

Or chained without an intermediate host transfer:

>>> rsf = model.compute(audio)

spectrogram

spectrogram(audio: ndarray) -> Spectrogram

Compute the auditory spectrogram and return it on host.

PARAMETER DESCRIPTION
audio

1D audio signal.

TYPE: ndarray

RETURNS DESCRIPTION
Spectrogram

Spectrogram with data and axis metadata on the host.

rsf

rsf(spec: Spectrogram) -> RSF

Compute the RSF representation from a spectrogram, on host.

PARAMETER DESCRIPTION
spec

Auditory spectrogram, typically produced by :meth:spectrogram.

TYPE: Spectrogram

RETURNS DESCRIPTION
RSF

RSF representation with data and axis metadata on the host.

compute_device

compute_device(audio: ndarray)

Run the full pipeline on device with no intermediate host transfer.

Spectrogram output stays on the device and feeds directly into the Gabor stage. Use this when you do not need the intermediate :class:Spectrogram dataclass.

PARAMETER DESCRIPTION
audio

1D audio signal.

TYPE: ndarray

RETURNS DESCRIPTION
ndarray or ndarray

RSF tensor of shape (n_frames, n_rates, n_scales, n_freq) on the active backend.

compute

compute(audio: ndarray) -> RSF

Run the full pipeline and return an RSF dataclass on host.

Chains both stages on device with no intermediate host transfer, then copies the final result to host and wraps it in an :class:RSF.

PARAMETER DESCRIPTION
audio

1D audio signal.

TYPE: ndarray

RETURNS DESCRIPTION
RSF

Host-side RSF with data and axis metadata.