maad.features.spectral_events
- maad.features.spectral_events(Sxx_dB, dt, dB_threshold=6, rejectDuration=None, display=False, **kwargs)[source]
Compute acoustic events from a spectrogram [1] [2].
An acoustic event corresponds to the period of the signal above a threshold. An acoustic event could be short (at list one point if rejectDuration is None) or very long (the duration of the entire audio). Two acoustic events are separated by a period with low audio signal (ie below the threshold). Acoustic events are calculated frequency by frequency along time axis This function computes:
EVNspFraction : Fraction of events duration over total duration
EVNspmean : mean events duration (s)
EVNspcount : number of events per s
EVNsp : binary vector or matrix with 1 corresponding to event position
- Parameters:
- Sxx_dB2D array of floats
2D in dB. Usually, better to work with spectrogram without stationnary noise in order to measure only acoustic activity above the background noise
- dtfloat
time resolution in s (ie tn[1]-tn[0])
- dB_thresholdscalar, optional, default is 6dB
data >Threshold is considered to be an event if the length is > rejectLength
- rejectDurationscalar, optional, default is None
event shorter than rejectDuration are discarded duration is in s
- displayboolean, optional, default is false
Display a plot with the number of events per s (EVNspCount) and a binary image with the detected events.
- kwargsoptional. See matplotlib documentation
- Returns:
- EVNspFract :scalar
Fraction: events duration over total duration
- EVNspMean: scalar
mean events duration in s
- EVNspCount: scalar
number of events per s
- EVNsp: ndarray of floats
binary matrix. 1 corresponds to event 0 corresponds to background
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) >>> Sxx_dB_noNoise = maad.util.power2dB(Sxx_noNoise) >>> EVNspFract_per_bin, EVNspMean_per_bin, EVNspCount_per_bin, EVNsp = maad.features.spectral_events(Sxx_dB_noNoise, dt=tn[1]-tn[0], dB_threshold=6, rejectDuration=0.1, display=True, extent=ext) >>> print('Mean proportion of spectrogram with events: %2.2f%%' %np.mean(EVNspFract_per_bin)) Mean proportion of spectrogram with events: 0.01%