process_gaze: Interpolation and smoothing of gaze-vector

View source: R/PreprocessingFunctions.R

process_gazeR Documentation

Interpolation and smoothing of gaze-vector

Description

Preprocessing of gaze vector Interpolate over gaps in data and smooth the x and y vectors using a moving average filter. The gaze vector must contain the variables timestamp, and variables containing unfiltered x and y coordinates. Default names: x.raw and y.raw. Timestamps are assumed to be in milliseconds. The unprocessed x and y variables are kept under the names x.unprocessed and y.unprocessed for comparison. The function will add the variable timestamp.t to the data frame before returning. This is a theoretical timestamp based on the detected median sample-to-sample timestamp difference as compared to the actual registered time stamps in the data. This can be useful in some validation analyses.

Usage

process_gaze(
  gaze_raw,
  max_gap_ms = 75,
  marg_ms = 30,
  filter_ms = 15,
  xcol = "x.raw",
  ycol = "y.raw"
)

Arguments

gaze_raw

Data frame containing unfiltered timestamp, x.raw and y.raw vectors.

max_gap_ms

The maximum gaps defined as subsequent NAs in the data to interpolate over in milliseconds. Default 75 ms

marg_ms

The margin in milliseconds before and after the gap to use as basis for interpolation.

filter_ms

The size of the moving average window to use in smoothing. Default 15 ms

xcol

Name of column containing unprocessed x coordinates

ycol

Name of column containing unprocessed y coordinates

Value

data frame with gaze data after interpolation and filtering

Examples

processed_gaze <- process_gaze(sample.data.unprocessed)

kollaR documentation built on April 13, 2025, 5:11 p.m.