Introduction to warbleR

warbleR logo

The warbleR package is intended to facilitate the analysis of the structure of the animal acoustic signals in R. Users can enter their own data into a workflow that facilitates spectrographic visualization and measurement of acoustic parameters warbleR makes use of the fundamental sound analysis tools of the seewave package, and offers new tools for acoustic structure analysis. These tools are available for batch analysis of acoustic signals.

 

The main features of the package are:

  • The use of loops to apply tasks through acoustic signals referenced in a selection table
  • The production of image files with spectrograms that let users organize data and verify acoustic analyzes

 

warbleR image loop

 

The package offers functions for:

  • Browse and download recordings of Xeno-Canto
  • Explore, organize and manipulate multiple sound files
  • Create spectrograms of complete recordings or individual signals
  • Run different measures of acoustic signal structure
  • Evaluate the performance of measurement methods
  • Catalog signals
  • Characterize different structural levels in acoustic signals
  • Statistical analysis of duet coordination
  • Consolidate databases and annotation tables

Most of the functions allow the parallelization of tasks, which distributes the tasks among several cores to improve computational efficiency. Tools to evaluate the performance of the analysis at each step are also available. All these tools are provided in a standardized workflow for the analysis of the signal structure, making them accessible to a wide range of users, including those without much knowledge of R. warbleR is a young package (officially published in 2017) currently in a maturation stage.

 

Input acoustic data in warbleR

Most warbleR functions take as input annotation tables. An annotation table (or selection table in Raven’s and warbleR’s terminology) is a data set that contains information about the location in time (and sometimes in frequency) of the sounds of interest in one or more sound files. warbleR can take sound file annotations represented in the following R objects:

  • Data frames
  • Selection tables
  • Extended selection tables

The data “lbh_selec_table” that comes with the package provides a good example will on the annotation data format used in warbleR:

data("lbh_selec_table")

lbh_selec_table
sound.files channel selec start end bottom.freq top.freq
Phae.long1.wav 1 1 1.169 1.342 2.22 8.60
Phae.long1.wav 1 2 2.158 2.321 2.17 8.81
Phae.long1.wav 1 3 0.343 0.518 2.22 8.76
Phae.long2.wav 1 1 0.160 0.292 2.32 8.82
Phae.long2.wav 1 2 1.457 1.583 2.28 8.89
Phae.long3.wav 1 1 0.627 0.758 3.01 8.82
Phae.long3.wav 1 2 1.974 2.104 2.78 8.89
Phae.long3.wav 1 3 0.123 0.255 2.32 9.31
Phae.long4.wav 1 1 1.517 1.662 2.51 9.22
Phae.long4.wav 1 2 2.933 3.077 2.58 10.23
Phae.long4.wav 1 3 0.145 0.290 2.58 9.74

 

Take a look at the vignette ‘Annotation data format’ for more details on annotation data formats.

warbleR functions and the workflow of analysis in bioacoustics

Bioacoustic analyzes generally follow a specific processing sequence and analysis. This sequence can be represented schematically like this:

analysis workflow

 

We can group warbleR functions according to the bioacoustic analysis stages.

 

Get and prepare recordings

The query_xc() function allows you to search and download sounds from the free access database Xeno-Canto. You can also convert .mp3 files to .wav, change the sampling rate of the files and correct corrupt files, among other functions.

Function Description Works on Output
check_sound_files verify if sound files can be read multiple wave files data frame
consolidate consolidate sound files in a single folder multiple wave files data frame and wave files
fix_wavs fix waves that cannot be read in R multiple wave files wave files
mp32wav convert multiple mp3 files to wav format multiple mp3 files wave files
query_xc Search and download mp3 files from Xeno-Canto Scientific names/data frame mp3 files
resample_est resample wave objects in ext. selection tables extended selection tables extended selection tables
remove_channels remove channels in multiple wave files multiple wave files wave files
remove_silence remove silences in multiple wave files multiple wave files wave files
duration_sound_files measures duration in multiple wave files multiple wave files data frame
info_sound_files extract recording parameters from multiple wave files multiple wave files data frame

 

Annotating sound

It is recommended to make annotations in other programs and then import them into R (for example in Raven and import them with the Rraven package). However, warbleR offers some functions to facilitate manual or automatic annotation of sound files, as well as the subsequent manipulation:

Function Description Works on Output
freq_range detect frequency range in selection tables multiple wave files data frame
tailor_sels interactive tailoring of selections selection tables selection tables

 

Organize annotations

The annotations (or selection tables) can be manipulated and refined with a variety of functions. Selection tables can also be converted into the compact format extended selection tables:

Function Description Works on Output
tailor_sels interactive tailoring of selections selection tables selection tables
sort_colms order columns in an intuitive way selection tables selection tables
cut_sels save selections as individual wave files selection tables wave files
filter_sels subset selection tables based on filtered image files selection tables, ext. selection tables, images selection tables, ext. selection tables
fix_extended_selection_table add wave objects to extended selection tables selection tables extended selection tables
selection_table create selection tables and extended selection tables selection tables selection tables, ext. selection tables
song_analysis measures acoustic parameters at higher structural levels of organization selection tables, ext. selection tables data frame, selection tables

 

Measure acoustic signal structure

Most warbleR functions are dedicated to quantifying the structure of acoustic signals listed in selection tables using batch processing. For this, 4 main measurement methods are offered:

  1. Spectrographic parameters
  2. Cross correlation
  3. Dynamic time warping (DTW)
  4. Statistical descriptors of cepstral coefficients

Most functions gravitate around these methods, or variations of these methods:

Function Description Works on Output
freq_range detect frequency range in selection tables multiple wave files data frame
song_analysis measures acoustic parameters at higher structural levels of organization selection tables, ext. selection tables data frame, selection tables
compare_methods compare the performance of methods to measure acoustic structure selection tables, ext. selection tables images
freq_DTW measures dynamic time warping (DTW) on dominant/fundamental frequency contours selection tables, ext. selection tables (di)similarity matrix, images
freq_ts mesaures dominant/fundamental frequency contours selection tables, ext. selection tables data frame with frequency contours
inflections measures number of inflections in frequency contours data frame with frequency contours data frame
mfcc_stats measures statistical descriptors of Mel cepstral coefficients selection tables, ext. selection tables data frame
multi_DTW measures dynamic time warping (DTW) on multiple contours selection tables, ext. selection tables (di)similarity matrix
sig2noise measures signal-to-noise ratio selection tables, ext. selection tables selection tables, ext. selection tables
spectro_analysis measures spectrographic parameters selection tables, ext. selection tables data frame
cross_correlation measurec spectrographic cross-correlation selection tables, ext. selection tables (di)similarity matrix

 

Verify annotations

Functions are provided to detect inconsistencies in the selection tables or modify selection tables. The package also offers several functions to generate spectrograms showing the annotations, which can be organized by annotation categories. This allows you to verify if the annotations match the previously defined categories, which is particularly useful if the annotations were automatically generated.

Function Description Works on Output
check_sels double-check selection tables selection tables selection tables
overlapping_sels finds (time) overlapping selections selection tables, ext. selection tables selection tables, ext. selection tables
catalog creates spectrogram catalog selection tables, ext. selection tables images
catalog2pdf convert catalogs to .pdf images images
spectrograms create spectrogram images selection tables, ext. selection tables images
full_spectrograms create spectrograms of whole sound files multiple wave files, selection tables, ext. selection tables images
full_spectrogram2pdf convert full spectrograms to .pfg images images

 

Visually inspection of annotations and measurements

Function Description Works on Output
snr_spectrograms plots spectrograms highlighting areas where signal-to-noise ratio is measured selection tables, ext. selection tables images
spectrograms create spectrogram images selection tables, ext. selection tables images
track_freq_contour create spectrogram images including frequency contours selection tables, ext. selection tables images
plot_coordination create schematic plots of coordinated signals data frame images
full_spectrograms create spectrograms of whole sound files multiple wave files, selection tables, ext. selection tables images

 

Additional functions

Finally, warbleR offers functions to simplify the use of extended selection tables, organize large numbers of images with spectrograms and generate elaborated signal visualizations:

Function Description Works on Output
is_extended_selection_table check if object is extended selection tables data frame TRUE/FALSE
is_selection_table check if object is selection tables data frame TRUE/FALSE
catalog2pdf convert catalogs to .pdf images images
move_imgs moves images among folders images images
map_xc created maps from Xeno-Canto recordings data frame images
test_coordination test statistical significance of vocal coordination data frame data frame
full_spectrogram2pdf convert full spectrograms to .pfg images images
color_spectro highlight signals with colors in a spectrogram wave object plot in R
freq_range_detec detect frequency range in wave objetcs wave object data frame, plot in R
open_wd open working directory
phylo_spectro plots phylogenetic trees with spectrograms selection tables plot in R
read_sound_file read sound files and wave objects selection tables, ext. selection tables wave object
simulate_songs simulate songs wave object, wave file and selection table
tweak_spectro creates mosaic plots with spectrograms with different display parameters selection tables, ext. selection tables images
warbleR_options define global parameters for warbleR functions

 


References

  1. Araya-Salas M, G Smith-Vidaurre & M Webster. 2017. Assessing the effect of sound file compression and background noise on measures of acoustic signal structure. Bioacoustics 4622, 1-17
  2. Araya-Salas M, Smith-Vidaurre G (2017) warbleR: An R package to streamline analysis of animal acoustic signals. Methods Ecol Evol 8:184-191.

 


Session information

R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=C               LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rmarkdown_2.28     kableExtra_1.4.0   warbleR_1.1.32     NatureSounds_1.0.4 knitr_1.48        
[6] seewave_2.2.3      tuneR_1.4.7       

loaded via a namespace (and not attached):
 [1] viridis_0.6.5     utf8_1.2.4        sass_0.4.9        shinyBS_0.61.1    bitops_1.0-8     
 [6] xml2_1.3.6        stringi_1.8.4     digest_0.6.37     magrittr_2.0.3    grid_4.4.1       
[11] evaluate_1.0.0    iterators_1.0.14  soundgen_2.7.0    fastmap_1.2.0     foreach_1.5.2    
[16] jsonlite_1.8.8    brio_1.1.5        gridExtra_2.3     fansi_1.0.6       viridisLite_0.4.2
[21] scales_1.3.0      pbapply_1.7-2     codetools_0.2-20  jquerylib_0.1.4   cli_3.6.3        
[26] rlang_1.1.4       fftw_1.0-8        munsell_0.5.1     cachem_1.1.0      yaml_2.3.10      
[31] tools_4.4.1       parallel_4.4.1    ggplot2_3.5.1     colorspace_2.1-1  buildtools_1.0.0 
[36] vctrs_0.6.5       R6_2.5.1          proxy_0.4-27      lifecycle_1.0.4   dtw_1.23-1       
[41] stringr_1.5.1     MASS_7.3-61       pkgconfig_2.0.3   pillar_1.9.0      gtable_0.3.5     
[46] bslib_0.8.0       glue_1.7.0        Rcpp_1.0.13       systemfonts_1.1.0 tibble_3.2.1     
[51] xfun_0.47         highr_0.11        rstudioapi_0.16.0 sys_3.4.2         rjson_0.2.23     
[56] htmltools_0.5.8.1 svglite_2.1.3     maketools_1.3.0   testthat_3.2.1.1  signal_1.8-1     
[61] compiler_4.4.1    RCurl_1.98-1.16