Interpolate short missing gaps in Gazepoint pupil data
Source:R/interpolate_gazepoint_pupil.R
interpolate_gazepoint_pupil.RdPerforms linear interpolation over short internal gaps in Gazepoint pupil
data. This function is intended to be used after flag_gazepoint_pupil() or
flag_gazepoint_pupil_artifacts(). When available, pupil_clean is used as
the preferred default input column, followed by pupil_for_preprocessing.
Leading gaps, trailing gaps, long gaps, non-finite time values, and groups
with too few valid pupil samples are not interpolated.
Usage
interpolate_gazepoint_pupil(
data,
pupil_col = NULL,
time_col = NULL,
group_cols = c("subject", "media_id"),
max_gap_ms = 150,
max_gap_samples = Inf,
min_valid_points = 2
)Arguments
- data
A Gazepoint master table, preferably after
flag_gazepoint_pupil()orflag_gazepoint_pupil_artifacts().- pupil_col
Optional name of the pupil column to interpolate. If
NULL, the function detects one ofpupil_clean,pupil_for_preprocessing,mean_pupil,pupil,pupil_raw,left_pupil, orright_pupil.- time_col
Optional name of the time column. If
NULL, the function detects one oftime_ms,time,time_orig, ortime_orig_ms.- group_cols
Character vector of grouping columns used to keep interpolation within independent time series. Defaults to
c("subject", "media_id")using internally standardised names. Usecharacter(0)for global interpolation.- max_gap_ms
Maximum duration, in milliseconds, of a gap that may be interpolated. The duration is measured between the valid samples immediately before and after the gap. Defaults to
150.- max_gap_samples
Maximum number of consecutive missing samples that may be interpolated. Defaults to
Inf.- min_valid_points
Minimum number of valid samples required within a group before interpolation is attempted. Defaults to
2.
Examples
if (FALSE) { # \dontrun{
flagged <- flag_gazepoint_pupil(master)
interpolated <- interpolate_gazepoint_pupil(flagged)
dplyr::count(interpolated, pupil_interpolation_status)
artifact_flagged <- flag_gazepoint_pupil_artifacts(master)
artifact_interpolated <- interpolate_gazepoint_pupil(artifact_flagged)
dplyr::count(artifact_interpolated, pupil_interpolation_status)
} # }