This allows the user to set a threshold for velocity and remove anything classed as a blink as a result
detect_blinks_by_velocity(
data,
pupil,
threshold = 0.1,
extend_forward = 0,
extend_back = 0
)
dataset of class PupillometryR
column name for pupil data
velocity threshold for blink detection
number of observations to remove forward of blink
number of obervations to remove behind blink
returns dataframe with blinks removed including forward and back, and data in blink column.
Sdata <- make_pupillometryr_data(data = pupil_data,
subject = ID,
trial = Trial,
time = Time,
condition = Type)
Sdata2 <- detect_blinks_by_velocity(data = Sdata,
pupil = pupil_data,
threshold = 0.1,
extend_forward = 0,
extend_back = 0)
#> Creating column pupil_in_blink
#> Error in mutate(., .diff1 = c(diff(!!sym(pupil)), NA), .diff2 = c(diff(!!sym(time)), NA), .vel = .diff1/.diff2, pupil_in_blink = ifelse(.vel > threshold | .vel < -threshold, 1, 0), pupil_in_blink = ifelse(is.na(!!sym(pupil)), 1, pupil_in_blink), pupil_in_blink = ifelse(is.na(pupil_in_blink), lag(pupil_in_blink), pupil_in_blink)): ℹ In argument: `.diff1 = c(diff(pupil_data), NA)`.
#> ℹ In group 1: `ID = "1"`, `Trial = Easy1`.
#> Caused by error in `r[i1] - r[-length(r):-(length(r) - lag + 1L)]`:
#> ! non-numeric argument to binary operator