pyntbci.envelope.envelope_gammatone

pyntbci.envelope.envelope_gammatone(audio: ndarray[Any, dtype[_ScalarType_co]], fs: int, fs_inter: int = 8000, fs_target: int = 32, power: float = 0.6, lowpass: float = 9.0, fmin: float = 150.0, fmax: float = 4000.0, spacing: float = 1.5) ndarray[Any, dtype[_ScalarType_co]][source]

Compute the envelope of audio using a gammatone filterbank.

Developed in collaboration with Hanneke Scheppink. Adapted from: https://zenodo.org/records/3377911 preprocess_data.m (Neetha Das) Deviations:

  • Use of gammatone filterbank from scipy

  • Use of a lowpass rather than a bandpass on the envelope

  • Use of a butterworth filter rather than an equiripple

  • No downsample before the lowpass, as it seems redundant

Parameters:
  • audio (NDArray) – A vector containing the raw audio sampled at fs.

  • fs (int) – The sampling frequency in Hz of the raw audio.

  • fs_inter (int (default: 8000)) – The sampling frequency in Hz to which the audio will be downsampled for computational efficiency.

  • fs_target (int (default: 32)) – The sampling frequency in Hz to which the envelope will be downsampled.

  • power (float (default: 0.6)) – The power law coefficient applied to the envelope.

  • lowpass (float (default: 9.0)) – The lowpass cutoff frequency in Hz to lowpass filter the envelope.

  • fmin (float (default: 150.0)) – The minimum center frequency.

  • fmax (float (default: 4000.0)) – The maxmum center frequency.

  • spacing (float (default: 1.5)) – The bandwidth or spacing between center frequencies.

Returns:

envelope – The envelope for each of the subbands in the gammatone filterbank of shape (samples, subbands).

Return type:

NDArray