This function implements transient artifact removal by
identifying and removing samples that exceed a speed-based threshold.
The threshold is computed based on the constant n
, which defaults to
the value 16
.
This function is called by the exposed wrapper detransient()
.
detransient_pupil(x, prev_op, n, mad_thresh)
A numeric vector of the same length as the input data with transient artifacts removed (set to NA)
A data frame containing pupil data with columns time_secs
and
the previous operation's pupil column
The name of the previous operation's pupil column
The constant used to compute the median absolute deviation (MAD)
threshold. Defaults to 16
The threshold used to identify transient artifacts.
Defaults to NULL
The function works by:
Calculating the speed of pupil changes using finite differences
Identifying samples that exceed a speed-based threshold
Removing these samples from the pupil data