sig2noise measures signal-to-noise ratio across multiple files.
sig2noise(X, mar, parallel = 1, path = NULL, pb = TRUE, type = 1, eq.dur = FALSE, in.dB = TRUE, before = FALSE, lim.dB = TRUE, bp = NULL, wl = 10)
| X | object of class 'selection_table', 'extended_selection_table' or any data frame with columns
for sound file name (sound.files), selection number (selec), and start and end time of signal
(start and end). The output of |
|---|---|
| mar | numeric vector of length 1. Specifies the margins adjacent to the start and end points of selection over which to measure noise. |
| 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). It can also be
set globally using the 'parallel' option (see |
| path | Character string containing the directory path where the sound files are located.
If |
| pb | Logical argument to control if progress bar is shown. Default is |
| type | Numeric. Determine the formula to be used to calculate the signal-to-noise ratio (S = signal , N = background noise):
|
| eq.dur | Logical. Controls whether the noise segment that is measured has the same duration
than the signal (if |
| in.dB | Logical. Controls whether the signal-to-noise ratio is returned in decibels (20*log10(SNR)).
Default is |
| before | Logical. If |
| lim.dB | Logical. If |
| bp | Numeric vector of length 2 giving the lower and upper limits of a frequency bandpass filter (in kHz). Default is |
| wl | A numeric vector of length 1 specifying the window length of the spectrogram for applying bandpass. Default
is 10. Ignored if |
Data frame similar to autodetec output, but also includes a new variable
with the signal-to-noise values.
Signal-to-noise ratio (SNR) is a measure of the level of a desired signal compared to
background noise. The function divides the mean amplitude of the signal by
the mean amplitude of the background noise adjacent to the signal.
A general margin to apply before and after the acoustic signal must
be specified. Setting margins for individual signals that have been
previously clipped from larger files may take some optimization, as
for calls within a larger file that are irregularly separated. When
margins overlap with another acoustic signal nearby, the signal-to-noise
ratio (SNR) will be inaccurate. Any SNR less than or equal to one suggests
background noise is equal to or overpowering the acoustic signal.
snrspecs can be used to troubleshoot different noise margins.
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. Wikipedia: Signal-to-noise ratio
{ data(list = c("Phae.long1","lbh_selec_table")) writeWave(Phae.long1, file.path(tempdir(), "Phae.long1.wav")) #save sound files # specifying the correct margin is important # use snrspecs to troubleshoot margins for sound files sig2noise(lbh_selec_table[grep("Phae.long1", lbh_selec_table$sound.files), ], mar = 0.2, path = tempdir()) # this smaller margin doesn't overlap neighboring signals sig2noise(lbh_selec_table[grep("Phae.long1", lbh_selec_table$sound.files), ], mar = 0.1, path = tempdir()) }#> | | 0 % ~calculating |+++++++++++++++++ | 33% ~00s |++++++++++++++++++++++++++++++++++ | 67% ~00s |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s #> | | 0 % ~calculating |+++++++++++++++++ | 33% ~00s |++++++++++++++++++++++++++++++++++ | 67% ~00s |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s#> sound.files channel selec start end bottom.freq top.freq sel.comment #> 1 Phae.long1.wav 1 1 1.16935 1.34239 2.2201 8.6044 c24 #> 2 Phae.long1.wav 1 2 2.15841 2.32146 2.1694 8.8071 c25 #> 3 Phae.long1.wav 1 3 0.34334 0.51826 2.2183 8.7566 c26 #> rec.comment SNR #> 1 NA 23.558 #> 2 NA 22.813 #> 3 NA 21.129