## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 7,
  fig.height = 4.5
)
library(gp3bayes)

## ----prep-example-------------------------------------------------------------
sim <- simulate_pupil_timecourse(
  n_participants = 5,
  trials_per_participant = 4,
  sampling_frequency = 20,
  time_window = c(-0.5, 1.5),
  seed = 14
)
contract <- create_pupil_contract(
  outcome_col = "pupil_mm",
  participant_col = "participant_id",
  trial_col = "trial_id",
  item_col = "item_id",
  condition_col = "condition",
  time_col = "event_time",
  pupil_unit = "millimetres",
  sampling_frequency = 20,
  eye = "combined",
  blink_col = "blink",
  interpolation_col = "interpolated",
  gaze_x_col = "gaze_x",
  gaze_y_col = "gaze_y",
  luminance_col = "luminance",
  baseline_window = c(-0.5, 0),
  baseline_method = "none",
  preprocessing_provenance = "deterministic synthetic example"
)
prepared <- prepare_pupil_timecourse(sim$data, contract)
prepared

## ----prep-baseline------------------------------------------------------------
baseline_prepared <- prepare_pupil_timecourse(
  sim$data,
  contract,
  baseline_operation = "subtract",
  baseline_window = c(-0.5, 0)
)
head(baseline_prepared$transformation_log)

## ----readiness----------------------------------------------------------------
readiness <- audit_pupil_readiness(prepared)
pupil_readiness_table(readiness, "summary")
head(pupil_readiness_table(readiness, "participant"))
head(pupil_readiness_table(readiness, "trial"))

## ----measurement--------------------------------------------------------------
measurement <- audit_pupil_measurement_context(prepared)
pupil_measurement_audit_table(measurement)

