You can supply timestamps to min_time and max_time (e.g timestamp of begin escape) to average over only a period.

extract_pupil(
  df,
  min_time = min(df$time),
  max_time = max(df$time),
  method = "mean",
  combination = "best",
  openness_required = 0.55,
  na_proportion_tolerance = 0.1
)

Arguments

df

A movement or eyetracker data frame. Expected columns are either eye_openness_left, eye_openness_right, pupil_diameter_left and pupil_diameter_right

min_time

minimum time in s (default: trial start)

max_time

maximum time in s (default: trial end)

method

One of the strings "mean" "max" or "min". Specifies statistic (default is mean)

combination

One of the strings "best", "combined", "left" or "right". (default is best)

openness_required

Openness of eye required to include measurement. (default is 0.55)

na_proportion_tolerance

Difference in NA proportions between left and right eye tolerated in combination = combined.

Value

A statistic (mean, min, max) from pupil diameter as specified in method. numeric

Details

Data contains pupil diameters of the left and right eyes. So data to be used specified in the combination parameter. Default is "best" and this utilizes the pupil measurements of the eye with fewer NA. Setting combination to "combined" causes it to take the average. "left" or "right" can be specified as well

In "combined" mode, if the proportion of NAs found in the left and right eyes differ by na_proportion_tolerance (Default is 0.1 i.e 10%) then a warning is generated and combination defaults to best