maad.features.spectral_activity

maad.features.spectral_activity(Sxx_dB, dB_threshold=6)[source]

Compute the acoustic activity on a spectrogram.

Acoustic activity corresponds to the portion of the spectrogram above a threshold frequency per frequency along time axis [1] [2]

The function computes for each frequency bin:

  • ACTfract : proportion (fraction) of points above the threshold

  • ACTcount : number of points above the threshold

  • ACTmean : mean value (in dB) of the portion of the signal above the threhold

Parameters:
Sxx_dB2D array of floats

Spectrogram 2D in dB. Usually, better to work with spectrogram without stationnary noise in order to measure only acoustic activity above the background noise

dB_thresholdscalar, optional, default is 6dB

data >Threshold is considered to be an activity

Returns:
ACTspfract :ndarray of scalars

proportion (fraction) of points above the threshold for each frequency bin

ACTspcount: ndarray of scalars

number of points above the threshold for each frequency bin

ACTspmean: scalar

mean value (in dB) of the portion of the signal above the threhold

References

[1]

TOWSEY, Michael W. The calculation of acoustic indices derived from long-duration recordings of the natural environment. 2017. https://eprints.qut.edu.au/110634/1/QUTePrints110634_TechReport_Towsey2017August_AcousticIndices%20v3.pdf

[2]

QUT : https://github.com/QutEcoacoustics/audio-analysis. Michael Towsey, Anthony Truskinger, Mark Cottman-Fields, & Paul Roe. (2018, March 5). Ecoacoustics Audio Analysis Software v18.03.0.41 (Version v18.03.0.41). Zenodo. http://doi.org/10.5281/zenodo.1188744

Examples

>>> import maad
>>> import numpy as np
>>> s, fs = maad.sound.load('../data/cold_forest_daylight.wav')
>>> Sxx_power, tn, fn, ext = maad.sound.spectrogram (s, fs)  
>>> Sxx_noNoise= maad.sound.median_equalizer(Sxx_power, display=True, extent=ext) 
>>> Sxx_dB_noNoise = maad.util.power2dB(Sxx_noNoise)
>>> ACTspfract_per_bin, ACTspcount_per_bin, ACTspmean_per_bin = maad.features.spectral_activity(Sxx_dB_noNoise)  
>>> print('Mean proportion of spectrogram above threshold : %2.2f%%' %np.mean(ACTspfract_per_bin)) 
Mean proportion of spectrogram above threshold : 0.07%