freq_DTW | R Documentation |
freq_DTW
calculates acoustic dissimilarity of frequency contours using dynamic
time warping. Internally it applies the dtwDist
function from the dtw
package.
freq_DTW(
X = NULL,
type = "dominant",
wl = 512,
wl.freq = 512,
length.out = 20,
wn = "hanning",
ovlp = 70,
bp = NULL,
threshold = 15,
threshold.time = NULL,
threshold.freq = NULL,
img = TRUE,
parallel = 1,
path = NULL,
ts.df = NULL,
img.suffix = "dfDTW",
pb = TRUE,
clip.edges = TRUE,
window.type = "none",
open.end = FALSE,
scale = FALSE,
fsmooth = 0.1,
adjust.wl = TRUE,
max.obs.per.core = 20,
...
)
X |
object of class 'selection_table', 'extended_selection_table' or data frame containing columns for sound file name (sound.files), selection number (selec), and start and end time of signal (start and end). |
type |
Character string to determine the type of contour to be detected. Three options are available, "dominant" (default), "fundamental" and "entropy". |
wl |
A numeric vector of length 1 specifying the window length of the spectrogram, default is 512. |
wl.freq |
A numeric vector of length 1 specifying the window length of the spectrogram for measurements on the frequency spectrum. Default is 512. Higher values would provide more accurate measurements. |
length.out |
A numeric vector of length 1 giving the number of measurements of frequency desired (the length of the time series). |
wn |
Character vector of length 1 specifying window name. Default is
"hanning". See function |
ovlp |
Numeric vector of length 1 specifying % of overlap between two
consecutive windows, as in |
bp |
A numeric vector of length 2 for the lower and upper limits of a
frequency bandpass filter (in kHz). Default is |
threshold |
amplitude threshold (%) for frequency detection. Default is 15. |
threshold.time |
amplitude threshold (%) for the time domain. Use for frequency detection. If |
threshold.freq |
amplitude threshold (%) for the frequency domain. Use for frequency range detection from the spectrum (see 'frange.detec'). If |
img |
Logical argument. If |
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). In this function parallelization improves performance only if the number of rows in 'X' is at least twice the number of cores to be used. |
path |
Character string containing the directory path where the sound files are located.
If |
ts.df |
Optional. Data frame with frequency contour time series of signals to be compared. If provided "X" is ignored. |
img.suffix |
A character vector of length 1 with a suffix (label) to add at the end of the names of
image files. Default is |
pb |
Logical argument to control progress bar. Default is |
clip.edges |
Logical argument to control whether edges (start or end of signal) in
which amplitude values above the threshold were not detected will be removed. If
|
window.type |
|
open.end |
|
scale |
Logical. If |
fsmooth |
A numeric vector of length 1 to smooth the frequency spectrum with a mean
sliding window (in kHz) used for frequency range detection (when |
adjust.wl |
Logical. If |
max.obs.per.core |
Numeric. Maximum number of observations per core to be used in parallel computing. Default is 100. Reduce this value if you have memory issues. |
... |
Additional arguments to be passed to |
This function extracts the dominant frequency values as a time series and
then calculates the pairwise acoustic dissimilarity using dynamic time warping.
The function uses the approx
function to interpolate values between dominant
frequency measures. If 'img' is TRUE
the function also produces image files
with the spectrograms of the signals listed in the input data frame showing the
location of the dominant frequencies.
A matrix with the pairwise dissimilarity values. If img is
FALSE
it also produces image files with the spectrograms of the signals listed in the
input data frame showing the location of the dominant frequencies.
Marcelo Araya-Salas (marcelo.araya@ucr.ac.cr)
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.
spectrograms
for creating spectrograms from selections,
snr_spectrograms
for creating spectrograms to
optimize noise margins used in sig2noise
and freq_ts
, freq_ts
, for frequency contour overlaid spectrograms.
Other spectrogram creators:
color_spectro()
,
multi_DTW()
,
phylo_spectro()
,
snr_spectrograms()
,
spectrograms()
,
track_freq_contour()
{
# load data
data(list = c("Phae.long1", "Phae.long2", "lbh_selec_table"))
writeWave(Phae.long2, file.path(tempdir(), "Phae.long2.wav")) # save sound files
writeWave(Phae.long1, file.path(tempdir(), "Phae.long1.wav"))
# dominant frequency
freq_DTW(lbh_selec_table,
length.out = 30, flim = c(1, 12), bp = c(2, 9),
wl = 300, path = tempdir()
)
# fundamental frequency
freq_DTW(lbh_selec_table,
type = "fundamental", length.out = 30, flim = c(1, 12),
bp = c(2, 9), wl = 300, path = tempdir()
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.