Calculate the number of overlapping fixations between two fixation groups, based on a minimum distance threshold, and the percentage of overlapping fixations.
Arguments
- x
A `fixation_group` object representing the first fixation group.
- y
A `fixation_group` object representing the second fixation group.
- dthresh
A numeric value specifying the distance threshold to determine when two fixations overlap (default is 60).
- time_samples
A numeric vector of points in time at which to evaluate the overlapping fixations (default is `seq(0, max(c(x$onset, y$onset)), by = 20)`, built from both groups so that the measure is symmetric in `x` and `y`).
- dist_method
A character string specifying the distance metric to use for measuring the distance between fixations. Options are "euclidean" and "manhattan" (default is "euclidean").
Value
A list containing the following elements:
- overlap
The number of overlapping fixations between the two fixation groups.
- perc
The proportion of time points at which both groups have a fixation that overlap (time points before either group's first fixation are not counted).
Details
This function computes the number of overlapping fixations within a minimum distance for two fixation groups at specified time points. An overlap occurs when the distance between two fixations is less than the specified distance threshold.
Examples
# Create two fixation groups
fg1 <- fixation_group(x = runif(50, 0, 100), y = runif(50, 0, 100),
duration = rep(1, 50), onset = seq(1, 50))
fg2 <- fixation_group(x = runif(50, 0, 100), y = runif(50, 0, 100),
duration = rep(1, 50), onset = seq(1, 50))
# Calculate the number of overlapping fixations and the percentage of overlapping fixations
result <- fixation_overlap(fg1, fg2)
overlap <- result$overlap
perc <- result$perc