annotation_overlap: calculate overlap between two binary annotation sets

Description Usage Arguments Details Value Examples

View source: R/annotation_overlap.R

Description

calculate overlap between two binary annotation sets

Usage

1
2
annotation_overlap(x1, x2, seg_length = NULL, overlap_res = 100,
  return_raw = FALSE)

Arguments

x1

data.frame or matrix with annotations, needs columns named "start" and "end"

x2

data.frame or matrix with annotations, needs columns named "start" and "end"

seg_length

numeric, total duration of the data (default is NULL, i.e. it's guessed from the data), see details

overlap_res

numeric, resolution for overlap (default is 100), see details

return_raw

logical, by default FALSE, i.e. return the proportion. Otherwise return a 0/1 vector where 1 indicates a congruent comparison.

Details

The function works like this. The total duration is segmented into overlap_res segments. The midpoints of these segments serve as test values. For example, if the resolution is 100 and the duration is 60 seconds, we will obtain 100 segments of 0.6 seconds each. The test values lay in the center of each segment, i.e. at 0.3, 0.9, 1.2 etc. Now, for each of these test values, check in x1 and x2 whether an annotation exists.

Also, this function is more of a 'helper' function, that primarily is used inside the evaluate_sad function.

Value

a numeric value of overlap proportion, or a 0/1 vector.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
x1 <- data.frame(start = c(1, 4, 7), end = c(2.3, 4.2, 8))
x2 <- data.frame(start = c(0, 5), end = c(4, 6))
annotation_overlap(x1, x2)
annotation_overlap(x1, x2, seg_length = 60)
# one annotation set is empty
x3 <- x2[0, ]
annotation_overlap(x1, x3)
# with 'real' data
x1 <- read_rttm(system.file("noisemesSAD_synthetic_speech.rttm", package = "avutils"))
x2 <- read_elan(system.file("synthetic_speech.eaf", package = "avutils"))
annotation_overlap(x1, x2, overlap_res = 10)
annotation_overlap(x1, x2, overlap_res = 10, return_raw = TRUE)

gobbios/avutils documentation built on Feb. 19, 2020, 9:44 a.m.