Skip to contents

Linear interpolation of time series data. The intended use of this method is for filling in missing pupil samples (NAs) in the time series. This method uses "na.approx()" function from the zoo package, which implements linear interpolation using the "approx()" function from the stats package. Currently, NAs at the beginning and the end of the data are replaced with values on either end, respectively, using the "rule = 2" argument in the approx() function.

Usage

interpolate(eyeris, verbose = TRUE)

Arguments

eyeris

An object of class eyeris dervived from load().

verbose

A flag to indicate whether to print detailed logging messages. Defaults to TRUE. Set to FALSE to suppress messages about the current processing step and run silently.

Value

An eyeris object with a new column in timeseries: pupil_raw_{...}_interpolate.

Details

This function is automatically called by glassbox() by default. Use glassbox(interpolate = FALSE) to disable this step as needed.

Users should prefer using glassbox() rather than invoking this function directly unless they have a specific reason to customize the pipeline manually.

Note

This function is part of the glassbox() preprocessing pipeline and is not intended for direct use in most cases. Use glassbox(interpolate = TRUE).

Advanced users may call it directly if needed.

See also

glassbox() for the recommended way to run this step as part of the full eyeris glassbox preprocessing pipeline.

Examples

demo_data <- eyelink_asc_demo_dataset()

demo_data |>
  # set to FALSE to skip (not recommended)
  eyeris::glassbox(interpolate = TRUE) |>
  plot(seed = 0)
#>  [  OK  ] - Running eyeris::load_asc()
#>  [  OK  ] - Running eyeris::deblink()
#>  [  OK  ] - Running eyeris::detransient()
#>  [  OK  ] - Running eyeris::interpolate()
#>  [  OK  ] - Running eyeris::lpfilt()

#> ! [ SKIP ] - Skipping eyeris::detrend()
#>  [  OK  ] - Running eyeris::zscore()
#> ! Plotting block 1 from possible blocks: 1