compareTemplates: Compare Performance of Templates

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/compareTemplates.R

Description

Provided a detectionList object containing results from N templates scored against the same survey with Y song events, compareTemplates will create a Y x N matrix to compare how each template scored each song event. If the song events are the sound clips used to create each template, compareTemplates may be a means of measuring overall similarity among sound events. Can be used to identify template clips that may match more than one song type.

Usage

1
compareTemplates(detection.obj, cutoff.return, cutoff.ignore, tol, n.drop = 0)

Arguments

detection.obj

Object of class detectionList.

cutoff.return

Score cutoff below which events are not returned.

cutoff.ignore

Score cutoff below which events are ignored.

tol

Tolerance (s). If a peak is within tol of a peak from another template, they are in the same event.

n.drop

Rows with this many templates or fewer will be dropped. n.drop = 0 drops none.

Details

The matrix is created by comparing the score for each event to the average score for that event. For cases in which a template does not score an event above cutoff a value of NA is placed in the matrix for that template-event junction. Similarly, if a template scores an event above cutoff but is beyond tol of the mean of other events, it will enter the matrix as its own event and an NA will be placed in the matrix for the event's junctions with other templates.

Value

A list:

times.mean

Vector of mean times for each row of the matrix.

times

Matrix of times for each event detection and template.

scores

Matrix of scores for each event detection and template.

Note

It can be difficult to make this function do the same grouping of peaks that a human might do.

Author(s)

Sasha D. Hafner

See Also

makeCorTemplate, makeBinTemplate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Load data
data(btnw)

# Write Wave objects to file (temporary directory used here)
btnw.fp <- file.path(tempdir(), "btnw.wav")

writeWave(btnw, btnw.fp)

# Make three templates to compare
btnw.1 <- makeBinTemplate(clip = btnw.fp, frq.lim = c(2.75, 7), t.lim = c(.5, 2.5), 
                          amp.cutoff = -20, name = -20)

btnw.2 <- makeBinTemplate(clip = btnw.fp, frq.lim = c(2.75, 7), t.lim = c(.5, 2.5), 
                          amp.cutoff = -27, name = -27)

btnw.3 <- makeBinTemplate(clip = btnw.fp, frq.lim = c(2.75, 7), t.lim = c(.5, 2.5), 
                          amp.cutoff = -34, name = -34)

# Combine templates
templates <- combineBinTemplates(btnw.1, btnw.2, btnw.3)

survey <- bind(btnw, btnw, btnw)

survey.fp <- file.path(tempdir(), "survey.wav")

writeWave(survey, survey.fp)

scores <- binMatch(survey = survey.fp, templates = templates, time.source = "fileinfo")

pks <- findPeaks(scores)

compareTemplates(detection.obj = pks, cutoff.return = 12, cutoff.ignore = 6, tol = 1, 
                 n.drop = 0) 

# Clean up
file.remove(btnw.fp)
file.remove(survey.fp)

monitoR documentation built on May 1, 2019, 6:28 p.m.