knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
eyeris
was intentionally designed for intuitive, flexible preprocessing of
pupillometry data, with support for event-based epoching and BIDS-style
organization for reproducible workflows.
In this vignette, we’ll walk through a typical use case:
We'll also demonstrate a unique feature we designed to maximize both your
productivity as well as data quality: interactive HTML reports
, which include
a record of the steps used to preprocess / epoch any given dataset -- and, for
epoched data -- an interactive "gallery" view to quickly skim through trial-level
data from each step of the preprocessing pipeline to make quality control and
assurance intuitive and accessible for any dataset (without needing to write any
additional code)!
# Load eyeris library(eyeris) # Load the example memory task file and run default glassbox preproc workflow eye <- system.file("extdata", "memory.asc", package = "eyeris") |> glassbox()
epoch()
enables flexible extraction of trials using:
Extract a 2-second window centered around each "PROBE" event.
eye_1a <- eye |> epoch(events = "PROBE*", limits = c(-1, 1))
Now, if you take a look at eye
, you'll notice there's a new list element
within this eyeris
object: epoch_probe
.
eye_1a$epoch_probe
By default, the resulting eyeris
object will contain the epoched data frame
within a list element called epoch_xyz
where xyz
will be a sanitized version
of the original start
event string you supplied for the pattern matching
procedure.
However, you have the ability to customize this label, by passing a value to the
label
argument within epoch()
.
Extract the 1-second window after "PROBE_START" and apply a custom label to the resulting epoch set.
eye_1b <- eye |> epoch( events = "PROBE_START_{trial}", limits = c(0, 1), label = "probeAfter" ) eye_1b |> purrr::pluck("epoch_probeAfter") |> head()
eye_1b |> purrr::pluck("epoch_probeAfter") |> purrr::pluck("block_1") |> dplyr::select(template:trial) |> head(5)
Use the 1-second window before
"DELAY_STOP"
as a baseline and apply it to the epoch data.
eye_1c <- eye |> epoch( events = "PROBE_START_{trial}", limits = c(0, 1), label = "probeEpochs", calc_baseline = TRUE, apply_baseline = TRUE, baseline_type = "sub", baseline_events = "DELAY_STOP_*", baseline_period = c(-1, 0) )
In this example, we're extracting 1-second epochs following each "PROBE_START"
event and applying subtractive baseline correction. The baseline is computed
from the 1-second window before each corresponding "DELAY_STOP"
event.
In other words, this means each pupil trace is normalized by subtracting the average pupil size from the pre-probe delay period (i.e., the baseline period).
Manually define start and end times for two trials:
start_events <- data.frame( time = c(11334491, 11338691), msg = c("TRIALID 22", "TRIALID 23") ) end_events <- data.frame( time = c(11337158, 11341292), msg = c("RESPONSE_22", "RESPONSE_23") ) eye_1d <- eye |> epoch( events = list(start_events, end_events, 1), # 1 = block number label = "manualTrials" )
Once epoched, your data is ready to be exported with bidsify()
, which saves
the raw and epoched data in a structured, BIDS
-inspired format.
bidsify( eyeris = eye_1c, bids_dir = "~/Documents/eyeris", participant_id = "001", session_num = "01", task_name = "assocmem", run_num = "01", save_raw = TRUE, # Also save raw timeseries html_report = TRUE # Generate a preprocessing summary )
Which will create a directory structure like this:
eyeris └── derivatives └── sub-001 └── ses-01 ├── eye │ ├── sub-001_ses-01_task-assocret_run-01_desc-timeseries_pupil.csv │ └── sub-001_ses-01_task-assocret_run-01_epoch-prePostProbe_desc-preproc_pupil.csv ├── source │ └── figures │ └── run-01 │ ├── epoch_prePostProbe │ │ ├── run-01_PROBE_START_22_1.png │ │ ├── run-01_PROBE_START_22_2.png │ │ ├── run-01_PROBE_START_22_3.png │ │ ├── run-01_PROBE_START_22_4.png │ │ ├── run-01_PROBE_START_22_5.png │ │ ├── run-01_PROBE_START_22_6.png │ │ ├── ... │ │ ├── run-01_PROBE_STOP_22_1.png │ │ ├── run-01_PROBE_STOP_22_2.png │ │ ├── run-01_PROBE_STOP_22_3.png │ │ ├── run-01_PROBE_STOP_22_4.png │ │ ├── run-01_PROBE_STOP_22_5.png │ │ ├── run-01_PROBE_STOP_22_6.png │ │ ├── ... │ ├── run-01_fig-1_desc-histogram.jpg │ ├── run-01_fig-1_desc-timeseries.jpg ├── sub-001_epoch-prePostProbe_run-01.html └── sub-001.html 9 directories, 80 files
See the 🔎 QC with Interactive Reports vignette for more details.
This vignette demonstrated how to:
.asc
(EyeLink) pupil data files using eyeris
.Check out the function documentation for epoch()
and bidsify()
to learn more
about other customization options that may be useful for your specific workflow.
eyeris
citation("eyeris")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.