detect.and.assign {callsync}R Documentation

detect.and.assign

Description

Traces the fundamental frequency from a wave object. Also applies smoothening to trace.

Usage

detect.and.assign(
  all_files = NULL,
  path_chunks = NULL,
  path_calls = NULL,
  ffilter_from = 1100,
  threshold = 0.4,
  msmooth = c(1000, 95),
  min_dur = 0.1,
  max_dur = 0.3,
  step_size = 0.01,
  wing = 6,
  save_files = TRUE,
  quiet = FALSE,
  save_extra = 0
)

Arguments

all_files

character vector or 'NULL'. Character vector should contain all the paths to the raw recordings that should be considered. If 'NULL' files are loaded from 'path_chunks'.

path_chunks

character, path to where the chunks are stored.

path_calls

character, path to where to store the results.

ffilter_from

numeric, frequency in Hz for the high-pass filter.

threshold

numeric, threshold (fraction of the maximum) for amplitude envelope when detecting call.

msmooth

used as argument for the 'seewave::env' function. *A vector of length 2 to smooth the amplitude envelope with a mean sliding window. The first component is the window length (in number of points). The second component is the overlap between successive windows (in %).* Default is 'c(500, 95)'.

min_dur

numeric, the minimal duration in seconds for a detection to be saved. Default is '0.1'.

max_dur

numeric, the maximal duration in seconds for a detection to be saved. Default is '0.3'.

step_size

numeric, duration in seconds of the bins for signal compression before cross correlation. Default is '0.01'.

wing

numeric, the duration in seconds to load before and after each detection to improve alignment. This is not saved with the aligned call.

save_files

logical, if 'TRUE' the files are stored in the 'path_chunks' location. Results are also returned.

quiet

logical, if 'TRUE' no messages are printed.

save_extra

numeric, how much to add to start and end time in seconds. Can be used to make sure the whole vocalisation is included.

Value

Returns a data frame with start = start time in samples and end = end time in samples for each detection.

Examples

require(callsync)
require(seewave)
require(tuneR)
path_git = 'https://raw.githubusercontent.com'
path_repo = '/simeonqs/callsync/master/tests/testthat/files'
file_1 = '/chunk@1@1@1@1.wav'
file_2 = '/chunk@2@1@1@1.wav'
url_1 = paste0(path_git, path_repo, file_1)
url_2 = paste0(path_git, path_repo, file_2)
local_file_1 = paste(tempdir(), file_1, sep = '/')
local_file_2 = paste(tempdir(), file_2, sep = '/')
if(!file.exists(local_file_1))
  download.file(url_1, destfile = local_file_1, mode = 'wb',)
if(!file.exists(local_file_2))
  download.file(url_2, destfile = local_file_2, mode = 'wb')
all_files = c(local_file_1, local_file_2)
## Not run: 
result = detect.and.assign(all_files = all_files,
                           quiet = TRUE,
                           save_files = FALSE)
                           
## End(Not run)


[Package callsync version 0.2.1 Index]