Below is comprehensive documentation for all internal functions in
the eyeris
R
package. These functions are
primarily intended for advanced users and developers who need to
customize the preprocessing pipeline or understand the internal workings
of the package.
The eyeris
package is built with a modular architecture
where each preprocessing step is implemented through both public
(exported) and internal functions. The public functions provide the
user-facing API, while the internal functions contain the core
processing logic.
Note: Functions marked with
@keywords internal
are not exported and should be accessed
using the :::
operator (e.g.,
eyeris:::function_name()
). Use these functions at your own
discretion as they may change without notice in future versions.
deblink_pupil()
File: R/pipeline-deblink.R
Description: Internal function to remove blink
artifacts from pupil data by extending NA padding around detected
blinks.
Parameters:
x
: A data frame containing pupil dataprev_op
: The name of the previous operation’s pupil
columnextend
: Number of samples to extend padding
before/after blinksReturns: A numeric vector with blink artifacts removed (set to NA)
detransient_pupil()
File: R/pipeline-detransient.R
Description: Internal function to remove transient
artifacts from pupil data using speed-based thresholding.
Parameters:
x
: A data frame containing pupil data with columns
time_secs
and the previous operation’s pupil columnprev_op
: The name of the previous operation’s pupil
columnn
: The constant used to compute the median absolute
deviation (MAD) threshold (default: 16)mad_thresh
: Optional threshold overrideReturns: A numeric vector with transient artifacts removed (set to NA)
interpolate_pupil()
File: R/pipeline-interpolate.R
Description: Interpolate missing pupil data using
linear interpolation.
Parameters:
x
: A data frame containing pupil dataprev_op
: The name of the previous operation’s pupil
columnverbose
: Logical, whether to print verbose outputReturns: A vector of interpolated pupil values
lpfilt_pupil()
File: R/pipeline-lpfilt.R
Description: Internal function to apply low-pass
filtering to pupil data using Butterworth filter design.
Parameters:
x
: A data frame containing pupil dataprev_op
: Previous operation’s pupil column namewp
: Passband frequency (Hz)ws
: Stopband frequency (Hz)rp
: Maximum ripple in passband (dB)rs
: Minimum attenuation in stopband (dB)fs
: Sampling frequencyplot_freqz
: Whether to plot frequency responseReturns: A vector of filtered pupil data
downsample_pupil()
File: R/pipeline-downsample.R
Description: Internal function to downsample pupil data
with anti-aliasing filtering.
Parameters:
x
: Data frame containing pupil dataprev_op
: Previous operation’s column nametarget_fs
: Target sampling frequencyplot_freqz
: Whether to plot frequency responsecurrent_fs
: Current sampling frequencyrp
, rs
: Filter design parametersReturns: A list containing the downsampled data and the decimated sample rate
bin_pupil()
File: R/pipeline-bin.R
Description: Bin pupil data into specified time bins
using averaging or other methods.
Parameters:
x
: Data frame containing pupil dataprev_op
: Previous operation’s column namebins_per_second
: Number of bins per secondmethod
: Binning method (“mean”, “median”, etc.)current_fs
: Current sampling frequencyReturns: A data frame with binned pupil data
detrend_pupil()
File: R/pipeline-detrend.R
Description: Internal function to detrend pupil data
using linear regression.
Parameters:
x
: Data frame containing pupil dataprev_op
: Previous operation’s column nameReturns: A list containing the fitted values, coefficients, and residuals
zscore_pupil()
File: R/pipeline-zscore.R
Description: Internal function to z-score normalize
pupil data.
Parameters:
x
: Data frame containing pupil dataprev_op
: Previous operation’s column nameReturns: A numeric vector of z-scored pupil data
epoch_pupil()
File: R/pipeline-epoch.R
Description: Main epoching and baselining logic that
coordinates the epoching process.
eyeris:::epoch_pupil(x, prev_op, evs, lims, label, c_bline, a_bline, bline_type, bline_evs, bline_per, hz, verbose)
Parameters:
x
: Data frame containing pupil dataprev_op
: Previous operation’s column nameevs
: Event specification (start/end messages or
timestamps)lims
: Time limits around eventslabel
: Epoch labelc_bline
, a_bline
:
Deprecated baseline calculation and application
optionsbline_type
: Baseline type (“divisive”,
“subtractive”)bline_evs
: Baseline eventsbline_per
: Baseline periodhz
: Sampling frequencyverbose
: Verbose outputReturns: A list containing epoch and baseline results
epoch_and_baseline_block()
File: R/pipeline-epoch.R
Description: Block-by-block epoch and baseline handler
for multi-block data.
eyeris:::epoch_and_baseline_block(x, blk, lab, evs, lims, msg_s, msg_e, c_bline, a_bline, bline_type, bline_evs, bline_per, hz, verbose)
Returns: A list containing epoch and baseline results for the specified block
epoch_manually()
File: R/pipeline-epoch.R
Description: Manually epoch using provided start/end
dataframes of timestamps.
epoch_only_start_msg()
File: R/pipeline-epoch.R
Description: Epoch based on a single event message
without explicit limits.
epoch_start_msg_and_limits()
File: R/pipeline-epoch.R
Description: Epoch using a start message with fixed
limits around it.
get_confounds_for_step()
File: R/pipeline-confounds.R
Description: Calculate comprehensive confounding
variables for a single pupil data processing step.
Parameters:
pupil_df
: Data frame containing pupil datapupil_vec
: Vector of pupil values for current stepscreen_width
, screen_height
: Screen
dimensions in pixelshz
: Sampling frequencyReturns: A data frame containing confounds metrics for the current step
tag_blinks()
File: R/pipeline-confounds.R
Description: Tag blinks in pupil data based on missing
values and physiological constraints.
Returns: A data frame with added column:
is_blink
calc_euclidean_dist()
File: R/pipeline-confounds.R
Description: Calculate Euclidean distance between
consecutive gaze points.
Returns: A numeric vector of Euclidean distances
normalize_gaze_coords()
File: R/pipeline-confounds.R
Description: Normalize gaze coordinates to
screen-relative units (0-1 range).
Returns: A data frame with added normalized coordinate columns
export_confounds_to_csv()
File: R/pipeline-confounds.R
Description: Export confounds data to CSV files and/or
database with comprehensive error handling.
eyeris:::export_confounds_to_csv(confounds_list, output_dir, filename_prefix, verbose, run_num, csv_enabled, db_con, sub, ses, task, eye_suffix, epoch_label)
Returns: Invisibly returns a vector of created file paths
get_log_timestamp()
File: R/core-logging.R
Description: Generate formatted timestamp for logging
messages.
Returns: Character string with current timestamp in
format [YYYY-MM-DD HH:MM:SS]
log_message()
File: R/core-logging.R
Description: Core logging function with timestamp and
glue
-style string interpolation.
Parameters:
level
: Log level (“INFO”, “SUCCESS”, “WARN”,
“ERROR”)...
: Message components (supports glue
syntax)verbose
: Whether to display the messagewrap
: Whether to wrap long messages.envir
: Environment for variable evaluationlog_info()
, log_success()
,
log_warn()
, log_error()
File: R/core-logging.R
Description: Specialized logging functions for
different message types.
eyeris:::log_info(..., verbose = TRUE, wrap = TRUE, .envir = parent.frame())
eyeris:::log_success(..., verbose = TRUE, wrap = TRUE, .envir = parent.frame())
eyeris:::log_warn(..., verbose = TRUE, wrap = TRUE, .envir = parent.frame())
eyeris:::log_error(..., wrap = TRUE, .envir = parent.frame())
check_input()
File: R/utils-checks.R
Description: Check if input argument is provided and
not NULL
.
check_data()
File: R/utils-checks.R
Description: Comprehensive validation of
eyeris
object data structure.
check_time_monotonic()
File: R/utils-checks.R
Description: Verify that time series data is
monotonically increasing.
connect_eyeris_database()
File: R/utils-database.R
Description: Connect to eyeris
DuckDB
database with comprehensive error handling.
Returns: DuckDB
connection object or
NULL
on failure
create_table_name()
File: R/utils-database.R
Description: Generate standardized table names for
eyeris
project database storage.
Returns: A standardized table name string
write_eyeris_data_to_db()
File: R/utils-database.R
Description: Write eyeris
data to
DuckDB
database with error handling and validation.
eyeris:::write_eyeris_data_to_db(data, db_con, data_type, sub, ses, task, run, eye_suffix, epoch_label, verbose)
Returns: TRUE
if successful,
FALSE
otherwise
write_csv_and_db()
File: R/utils-database.R
Description: Write data to both CSV file and database
with fallback handling.
eyeris:::write_csv_and_db(data, csv_path, csv_enabled, db_con, data_type, sub, ses, task, run, eye_suffix, epoch_label, verbose)
Returns: TRUE
if at least one write
operation succeeded
create_temp_eyeris_database()
File: R/utils-database.R
Description: Create temporary database for parallel
processing with unique naming.
Returns: List with temporary database path and connection info
merge_temp_database()
File: R/utils-database.R
Description: Merge temporary database into main
database with file locking.
Returns: TRUE
if merge successful,
FALSE
otherwise
clean_string()
File: R/utils-parsers.R
Description: Clean and sanitize strings for use in
filenames or labels.
Returns: Cleaned string with special characters removed/replaced
make_bids_fname()
File: R/pipeline-bidsify.R
Description: Generate BIDS-compatible filenames for
data export.
eyeris:::make_bids_fname(sub_id, task_name, run_num, desc, ses_id, epoch_name, epoch_events, baseline_events, baseline_type, eye_suffix)
Returns: A BIDS-compatible filename string
run_bidsify()
File: R/pipeline-bidsify.R
Description: Internal function to run bidsify operation
on a single eye’s data.
eyeris:::run_bidsify(eyeris, save_all, epochs_list, bids_dir, participant_id, session_num, task_name, run_num, save_raw, html_report, ...)
Returns: An eyeris
object (typically
for chaining)
progress_bar()
File: R/utils-progress_bar.R
Description: Create a customizable progress bar for
long-running operations.
Returns: A progress bar object from the progress package
counter_bar()
File: R/utils-progress_bar.R
Description: Create a simple counter-style progress
bar.
render_report()
File: R/utils-render_report.R
Description: Render an R Markdown
report
to HTML
with proper error handling.
Many internal functions are designed to work within the pipeline architecture:
All internal functions include comprehensive error handling:
When using internal functions: