Flag Gazepoint pupil artifacts before interpolation
Source:R/flag_gazepoint_pupil_artifacts.R
flag_gazepoint_pupil_artifacts.RdAdds pupil-specific artifact flags for blink/trackloss contamination,
physiological implausibility when pupil units are millimetres, pupil-speed
outliers, left-right binocular pupil disagreement, and temporal padding
around bad samples. The function preserves raw pupil columns and creates
pupil_clean, which can be used as input for interpolation.
Usage
flag_gazepoint_pupil_artifacts(
data,
pupil_col = NULL,
left_pupil_col = NULL,
right_pupil_col = NULL,
time_col = NULL,
blink_col = NULL,
trackloss_col = NULL,
missing_pupil_col = NULL,
pupil_unit_col = NULL,
group_cols = c("subject", "media_id"),
registry = NULL,
blink_padding_pre_ms = NULL,
blink_padding_post_ms = NULL,
pupil_min_mm = NULL,
pupil_max_mm = NULL,
pupil_speed_mad_k = NULL,
binocular_mad_k = NULL,
max_physio_outlier_prop = 0.8,
flag_speed_outliers = TRUE,
flag_binocular_disagreement = TRUE,
flag_physiological_outliers = TRUE
)Arguments
- data
A Gazepoint master table or pupil-processing table.
- pupil_col
Optional name of the pupil column to clean. If
NULL, the function detects one ofmean_pupil,pupil_raw,pupil,left_pupil, orright_pupil.- left_pupil_col
Optional left-pupil column. If
NULL,left_pupilis used when available.- right_pupil_col
Optional right-pupil column. If
NULL,right_pupilis used when available.- time_col
Optional time column. If
NULL, the function detects one oftime_ms,time,time_orig, ortime_orig_ms.- blink_col
Optional blink column. If
NULL,blinkis used when available.- trackloss_col
Optional trackloss column. If
NULL, one oftracklossorTracklossis used when available.- missing_pupil_col
Optional missing-pupil column. If
NULL,missing_pupilis used when available.- pupil_unit_col
Optional pupil-unit column. If
NULL,pupil_unitis used when available.- group_cols
Character vector of grouping columns used for speed outlier detection and artifact-padding windows. Defaults to
c("subject", "media_id"). Usecharacter(0)for global processing.- registry
Optional preprocessing registry created by
create_gazepoint_preprocessing_registry().- blink_padding_pre_ms
Padding before bad samples, in milliseconds. If
NULL, taken fromregistryor defaults to100.- blink_padding_post_ms
Padding after bad samples, in milliseconds. If
NULL, taken fromregistryor defaults to100.- pupil_min_mm
Minimum plausible pupil value when units are millimetres. If
NULL, taken fromregistryor defaults to1.- pupil_max_mm
Maximum plausible pupil value when units are millimetres. If
NULL, taken fromregistryor defaults to9.- pupil_speed_mad_k
MAD multiplier for pupil-speed outlier detection. If
NULL, taken fromregistryor defaults to6.- binocular_mad_k
MAD multiplier for binocular-disagreement detection. If
NULL, taken fromregistryor defaults to6.- max_physio_outlier_prop
Maximum allowed proportion of non-missing millimetre-labelled pupil samples that may be rejected by the physiological rule before the rule is automatically suppressed. Defaults to
0.80. This prevents raw-unit Gazepoint exports from being silently erased when the unit label suggests millimetres but the numeric scale is not compatible with ordinary 1–9 mm thresholds.- flag_speed_outliers
Logical. If
TRUE, pupil-speed outliers are flagged. Defaults toTRUE.- flag_binocular_disagreement
Logical. If
TRUE, left-right pupil disagreement is flagged when both eyes are available. Defaults toTRUE.- flag_physiological_outliers
Logical. If
TRUE, millimetre-based physiological thresholds are applied only when the pupil unit is identified as millimetres. Defaults toTRUE.
Examples
if (FALSE) { # \dontrun{
registry <- create_gazepoint_preprocessing_registry()
artifact_pupil <- flag_gazepoint_pupil_artifacts(
master,
registry = registry
)
dplyr::count(artifact_pupil, pupil_artifact_reason)
} # }