This vignette details the use of template-based detection in ohun.Template-based detection method is better suited for highly stereotyped sound events. As it is less affected by signal-to-noise ratio it’s more robust to higher levels of background noise:
The procedure for template-based detection is divided in three steps:
get_templates()
)template_correlator()
)template_detector()
)First, we need to install the package. It can be installed from CRAN as follows:
# From CRAN would be
install.packages("ohun")
#load package
library(ohun)
To install the latest developmental version from github you will need the R package remotes:
# install package
remotes::install_github("maRce10/ohun")
#load packages
library(ohun)
library(tuneR)
library(warbleR)
The package comes with an example reference table containing annotations of long-billed hermit hummingbird songs from two sound files (also supplied as example data: ‘lbh1’ and ‘lbh2’), which will be used in this vignette. The example data can be load and explored as follows:
# load example data
data("lbh1", "lbh2", "lbh_reference")
# save sound files
tuneR::writeWave(lbh1, file.path(tempdir(), "lbh1.wav"))
tuneR::writeWave(lbh2, file.path(tempdir(), "lbh2.wav"))
# select a subset of the data
lbh1_reference <-
lbh_reference[lbh_reference$sound.files == "lbh1.wav",]
# print data
lbh1_reference
Object of class 'selection_table'
* The output of the following call:
`[.selection_table`(X = lbh_reference, i = lbh_reference$sound.files == "lbh1.wav")
Contains:
* A selection table data frame with 10 rows and 6 columns:
| |sound.files | selec| start| end| bottom.freq| top.freq|
|:--|:-----------|-----:|------:|------:|-----------:|--------:|
|10 |lbh1.wav | 10| 0.0881| 0.2360| 1.9824| 8.4861|
|11 |lbh1.wav | 11| 0.5723| 0.7202| 2.0520| 9.5295|
|12 |lbh1.wav | 12| 1.0564| 1.1973| 2.0868| 8.4861|
|13 |lbh1.wav | 13| 1.7113| 1.8680| 1.9824| 8.5905|
|14 |lbh1.wav | 14| 2.1902| 2.3417| 2.0520| 8.5209|
|15 |lbh1.wav | 15| 2.6971| 2.8538| 1.9824| 9.2513|
... and 4 more row(s)
* A data frame (check.results) with 10 rows generated by check_sels() (as attribute)
created by warbleR < 1.1.21
We can also plot the annotations on top of the spectrograms to further explore the data (this function only plots one wave object at the time, not really useful for long files):
# print spectrogram
label_spectro(wave = lbh1, reference = lbh1_reference, hop.size = 10, ovlp = 50, flim = c(1, 10))