maad.rois.spectrogram_local_max
- maad.rois.spectrogram_local_max(Sxx, tn, fn, ext, min_distance, threshold_abs, display=False, **kwargs)[source]
Find peaks on spectrogram as coordinate list in time and frequency
- Parameters:
- Sxxndarray
Spectrogram of audio signal.
- tn1d array
Time vector of target audio, which results from the maad.sound.spectrogram function.
- fn1d array
Frecuency vector of target audio, which results from the maad.sound.spectrogram function.
- extlist of scalars [left, right, bottom, top]
Extent keyword arguments controls the bounding box in data coordinates for the spectrogram of the target audio, which results from the maad.sound.spectrogram function.
- min_distanceint
Minimum number of time-frequency coefficients (or pixels) separating peaks. This parameter controls how close peaks can be to each other. Peaks that are closer than min_distance will be merged into a single peak.
- threshold_absfloat
Minimum amplitude threshold for peak detection. Must be above Sxx.min().
- displaybool, optional
Option to display the resulting figure.
- Returns:
- peak_time: numpy.array
The temporal coordinates of local peaks (maxima) in a spectrogram.
- peak_frequency: numpy.array
The spectral coordinates of local peaks (maxima) in a spectrogram.
Examples
>>> from maad import sound, rois, util >>> s, fs = sound.load('../data/spinetail.wav') >>> Sxx, tn ,fn ,ext = sound.spectrogram (s, fs, nperseg=512, noverlap=256) >>> Sxx_db = util.power2dB(Sxx, db_range=80) >>> peak_time, peak_freq = rois.spectrogram_local_max(Sxx_db, tn, fn, ext, min_distance=1, threshold_abs=-40, display=True)