trim_fixations: Adjust the onset and offset of fixations to avoid...

View source: R/FixationFilterFunctions.R

trim_fixationsR Documentation

Adjust the onset and offset of fixations to avoid misclassification of saccade samples as belonging to fixations

Description

Adjust the onset and offset of all fixations in a data frame (The function adjust_fixation_timing does this for a single fixation).

Shrink the period classified as a fixation by removing samples at the onset and offset with excessive differences from the fixation center or which are missing (X or Y are NA). This reduces the risk that samples belonging to saccades are misclassified as belonging to a fixation. Please note that this procedure is included by default in the event classification algorithm 'alogorithm_i2mc' (see documentation for this function for details)

The procedure starts by calculating the median (MD) and MAD of the absolute distances from the fixation center of all included samples. The fixation onset is shifted forwards to the first sample with a distance to the fixation center under t* MAD + MD where t is specified by the input parameter threshold. Analogously, fixation offset is shifted backwards to the last included sample with distance to the fixation center under t* MAD + MD

trim_fixations will look for variables called 'fixation.algorithm' and 'threshold' in the data frame 'fixations'. These columns are produced by kollaR event classification algorithms. If they are found, they will be transfered to the output data frame.

Usage

trim_fixations(
  fixations,
  gaze,
  xcol = "x.raw",
  ycol = "y.raw",
  threshold = 3,
  one_degree = 40
)

Arguments

fixations

Data frame with fixations to trim. The data frame must include the variables 'firstline' (index of first row in the sample-by-sample data belonging to each fixation), 'lastline' (index of last row in the sample-by-sample data belonging to each fixation). The function works with the fixation output from kollaR event classification algorithms the fixation)

gaze

Data frame with sample-to-sample data. Must include timestamps in milliseconds specified by the variable timestamp, and X and Y coordinates specified by the parameters 'xcol' and 'ycol'.

xcol

Variable in the sample-to-sample data frame where X coordinates (before event classification) are found

ycol

Variable in the sample-to-sample data frame where X coordinates (before event classification) are found

threshold

Threshold for highest accepted distance from fixation center in MADs from the median. Default 3. If NA, just remove NAs at the onset and offest of fixation but ignore deviations from fixation center

one_degree

One degree of the visual field in the units of the X and Y coordinates (which is typically pixels or degrees of the visual field)

Value

data frame with fixations after adjustment of onset and offset


kollaR documentation built on June 8, 2025, 10:03 a.m.