maad.util.format_features

maad.util.format_features(df, tn, fn)[source]

Format features such as bounding box coordinates and centroids coordinates to predifined format : time-frequency to pixels or pixels to time-frequency units.

Parameters:
dfpandas DataFrame

df with bounding box coordinates and/or centroids coordinates array must have a valid input format with column names.

  • bounding box: min_y, min_x, max_y, max_x

  • time frequency: min_f, min_t, max_f, max_t

  • centroid tf : centroid_f, centroid_t

  • centroid pixels : centroid_y, centroid_x

tnndarray

vector with temporal indices, output from the spectrogram function (in seconds)

fn: ndarray

vector with frequencial indices, output from the spectrogram function (in Hz)

Returns:
df: pandas DataFrame

df with bounding box coordinates and/or centroids coordinates in pixels and time-frequency units

See also

select_rois, centroid_features, read_audacity_annot, overlay_rois
overlay_centroid

Notes

Use this function after using functions such as maad.rois.select_rois, maad.features.centroid_features, maad.util.read_audacity_annot, or before using functions such as maad.util.overlay_rois, maad.util.overlay_centroid in order to format the coordinates into pixels and/or time-frequency units.

Examples

>>> s, fs = maad.sound.load('../data/cold_forest_daylight.wav')
>>> Sxx_power, tn, fn, ext = maad.sound.spectrogram(s, fs)
>>> df_rois = maad.util.read_audacity_annot('../data/cold_forest_daylight_label.txt') 
>>> list(df_rois)
>>> df_rois = maad.util.format_features(df_rois, tn, fn)
>>> list(df_rois)