find_peaks
find peaks in cross-correlation scores from cross_correlation
Usage
find_peaks(xc.output, parallel = 1, cutoff = 0.4, path = NULL, pb = TRUE,
max.peak = FALSE, output = "data.frame")
Arguments
- xc.output
output of
cross_correlation
after settingoutput = "list"
.- parallel
Numeric. Controls whether parallel computing is applied. It specifies the number of cores to be used. Default is 1 (i.e. no parallel computing).
- cutoff
Numeric vector of length 1 with a value between 0 and 1 specifying the correlation cutoff for detecting peaks. Default is 0.4.
- path
Character string containing the directory path where the sound files are located. If
NULL
(default) then the current working directory is used.- pb
Logical argument to control progress bar. Default is
TRUE
.- max.peak
Logical argument to control whether only the peak with the highest correlation value is returned (if TRUE; cutoff will be ignored). Default is
FALSE
.- output
Character vector of length 1 to determine if only the detected peaks are returned ('cormat') or a list ('list') containing 1) the peaks and 2) a data frame with correlation values at each sliding step for each comparison. The list, which is also of class 'peaks.output', can be used to graphically explore detections using
full_spectrograms
.
Details
This function finds cross-correlation peaks along signals (analogous to findPeaks
).
References
Araya-Salas, M., & Smith-Vidaurre, G. (2017). warbleR: An R package to streamline analysis of animal acoustic signals. Methods in Ecology and Evolution, 8(2), 184-191.H. Khanna, S.L.L. Gaunt & D.A. McCallum (1997). Digital spectrographic cross-correlation: tests of sensitivity. Bioacoustics 7(3): 209-234
Author
Marcelo Araya-Salas marcelo.araya@ucr.ac.cr)
Examples
{
# load data
data(list = c("Phae.long4", "Phae.long2", "lbh_selec_table2", "comp_matrix"))
# save sound files
writeWave(Phae.long4, file.path(tempdir(), "Phae.long4.wav"))
writeWave(Phae.long2, file.path(tempdir(), "Phae.long2.wav"))
# run cross-correlation
xc.output <- cross_correlation(
X = lbh_selec_table2, output = "list",
compare.matrix = comp_matrix, path = tempdir()
)
# find peaks
pks <- find_peaks(xc.output = xc.output, path = tempdir())
}
#> Warning: The use of this function for signal detection (with 'compare.matrix') will be deprecated in future warbleR versions, please look at the ohun package for automatic signal detection functions (https://marce10.github.io/ohun/index.html)
#> running cross-correlation (step 1 of 1):
#> Warning: This function will be deprecated in future warbleR versions, please look at the ohun package for automatic signal detection functions (https://marce10.github.io/ohun/index.html)