Learn R Programming

warbleR (version 1.1.12)

contour_tailor: Interactive view of spectrograms to tailor selections

Description

contour_tailor produces an interactive spectrographic view (similar to manualoc) in which the start/end times and frequency range of acoustic signals listed in a data frame can be adjusted.

Usage

contour_tailor(X = NULL, wl = 512, flim = c(0,22), wn = "hanning", mar = 0.5,
 osci = TRUE, pal = reverse.gray.colors.2, ovlp = 70, auto.next = FALSE, pause = 1,
  comments = TRUE, path = NULL, frange = FALSE, fast.spec = FALSE, ext.window = TRUE,
  width = 15, height = 5, index = NULL, collevels = NULL, 
  title = c("sound.files", "selec"),...)

Arguments

X

'selection.table' object or data frame with the following columns: 1) "sound.files": name of the .wav files, 2) "selec": number of the selections, 3) "start": start time of selections, 4) "end": end time of selections. The ouptut of manualoc or autodetec can be used as the input data frame. Other data frames can be used as input, but must have at least the 4 columns mentioned above. Notice that, if an output file ("contour_tailor_output.csv") is found in the working directory it will be given priority over an input data frame.

wl

A numeric vector of length 1 specifying the spectrogram window length. Default is 512.

flim

A numeric vector of length 2 specifying the frequency limit (in kHz) of the spectrogram, as in the function spectro. Default is c(0,22).

wn

A character vector of length 1 specifying the window function (by default "hanning"). See function ftwindow for more options.

mar

Numeric vector of length 1. Specifies the margins adjacent to the start and end points of the selections to define spectrogram limits. Default is 0.5.

osci

Logical argument. If TRUE adds a oscillogram whenever the spectrograms are produced with higher resolution (see seltime). Default is TRUE. The external program must be closed before resuming analysis. Default is NULL.

pal

A color palette function to be used to assign colors in the plot, as in spectro. Default is reverse.gray.colors.2. See Details.

ovlp

Numeric vector of length 1 specifying the percent overlap between two consecutive windows, as in spectro. Default is 70.

auto.next

Logical argument to control whether the functions moves automatically to the next selection. The time interval before moving to the next selection is controled by the 'pause' argument.

pause

Numeric vector of length 1. Controls the duration of the waiting period before moving to the next selection (in seconds). Default is 1.

comments

Logical argument specifying if 'sel.comment' (when in data frame) should be included in the title of the spectrograms. Default is TRUE.

path

Character string containing the directory path where the sound files are located.

frange

Logical argument specifying whether limits on frequency range should be recorded. If NULL (default) then only the time limits are recorded.

fast.spec

Logical. If TRUE then image function is used internally to create spectrograms, which substantially increases performance (much faster), although some options become unavailable, as sc (amplitude scale). This option is indicated for signals with high background noise levels. Palette colors gray.1, gray.2, gray.3, topo.1 and rainbow.1 (which should be imported from the package monitoR) seem to work better with 'fast' spectograms. Palette colors gray.1, gray.2, gray.3 offer decreasing darkness levels.

ext.window

Logical. If TRUE then and external graphic window is used. Default dimensions can be set using the 'width' and 'height' arguments. Default is TRUE.

width

Numeric of length 1 controling the width of the external graphic window. Ignored if ext.window = FALSE. Default is 15.

height

Numeric of length 1 controling the height of the external graphic window. Ignored if ext.window = FALSE. Default is 5.

index

Numeric vector indicating which selections (rows) of 'X' should be tailored. Default is NULL. Ignored when the process is resumed. This can be useful when combined with filtersels) output (see 'index' argument in filtersels).

collevels

Numeric. Set of levels used to partition the amplitude range (see spectro).

title

Character vector with the names of the columns to be included in the title for each selection.

...

Additional arguments to be passed to the internal spectrogram creating function for customizing graphical output. The function is a modified version of spectro, so it takes the same arguments.

Value

data frame similar to X with the and a .csv file saved in the working directory with start and end time of selections.

Details

This function produces an interactive spectrographic view in which users can select new time/frequency coordinates the selections. 4 "buttons" are provided at the upper right side of the spectrogram that allow to stop the analysis ("stop"), go to the next sound file ("next"), return to the previous selection ("previous") or delete the current selection ("delete"). When a unit has been selected, the function plots dotted lines in the start and end of the selection in the spectrogram (or a box if frange = TRUE). Only the last selection is kept for each selection that is adjusted. The function produces a .csv file (contour_tailor_output.csv) with the same information than the input data frame, except for the new time coordinates, plus a new column (X$tailored) indicating if the selection has been tailored. The file is saved in the working directory and is updated every time the user moves into the next sound file (next sel "button") or stop the process (Stop "button"). It also return the same data frame as and object in the R environment. If no selection is made (by clicking on the 'next' button) the original time/frequency coordinates are kept. When resuming the process (after "stop" and re-running the function in the same working directory), the function will continue working on the selections that have not been analyzed. The function also displays a progress bar right on top of the sepctrogram. The zoom can be adjusted by setting the mar argument.

See Also

manualoc

Examples

Run this code
# NOT RUN {
#Set temporary working directory
# setwd(tempdir())

data(list = c("Phae.long1", "Phae.long2", "Phae.long3", "Phae.long4", "selec.table"))
writeWave(Phae.long1,"Phae.long1.wav")
writeWave(Phae.long2,"Phae.long2.wav")
writeWave(Phae.long3,"Phae.long3.wav")
writeWave(Phae.long4,"Phae.long4.wav")

contour_tailor(X =  selec.table, flim = c(1,12), wl = 300, auto.next = TRUE)

# Read output .csv file
contour_tailor.df <- read.csv("contour_tailor_output.csv")
contour_tailor.df

# check this directory for .csv file after stopping function
getwd()
# }

Run the code above in your browser using DataLab