View source: R/pipeline-handler.R
pipeline_handler | R Documentation |
eyeris
pipelinepipeline_handler
enables flexible integration of custom data
processing functions into the eyeris
pipeline. Under the hood,
each preprocessing function in eyeris
is a wrapper around a
core operation that gets tracked, versioned, and stored using this
pipeline_handler
method. As such, custom pipeline steps must conform
to the eyeris
protocol for maximum compatibility with the downstream
functions we provide.
pipeline_handler(eyeris, operation, new_suffix, ...)
eyeris |
An object of class |
operation |
The name of the function to apply to the timeseries data.
This custom function should accept a dataframe |
new_suffix |
A chracter string indicating the suffix you would like to be appended to the name of the previous operation's column, which will be used for the new column name in the updated preprocessed dataframe(s). |
... |
Additional (optional) arguments passed to the |
Following the eyeris
protocol also ensures:
all operations follow a predictable structure, and
that new pupil data columns based on previous operations in the chain are able to be dynamically constructed within the core timeseries data frame.
An updated eyeris
object with the new column added to the
timeseries
dataframe and the latest
pointer updated to the name of the
most recently added column plus all previous columns (ie, the history "trace"
of preprocessing steps from start-to-present).
For more details, please check out the following vignettes:
Anatomy of an eyeris Object
vignette("anatomy", package = "eyeris")
Building Your Own Custom Pipeline Extensions
vignette("custom-extensions", package = "eyeris")
# first, define your custom data preprocessing function
winsorize_pupil <- function(x, prev_op, lower = 0.01, upper = 0.99) {
vec <- x[[prev_op]]
q <- quantile(vec, probs = c(lower, upper), na.rm = TRUE)
vec[vec < q[1]] <- q[1]
vec[vec > q[2]] <- q[2]
vec
}
# second, construct your `pipeline_handler` method wrapper
winsorize <- function(eyeris, lower = 0.01, upper = 0.99) {
pipeline_handler(
eyeris,
winsorize_pupil,
"winsorize",
lower = lower,
upper = upper
)
}
# and voilà, you can now connect your custom extension
# directly into your custom `eyeris` pipeline definition!
custom_eye <- system.file("extdata", "memory.asc", package = "eyeris") |>
eyeris::load_asc(block = "auto") |>
eyeris::deblink(extend = 50) |>
winsorize()
plot(custom_eye, seed = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.