pick_data: Subsets EEG data by subject, sensor, time, or epoch

View source: R/helper_functions.R

pick_dataR Documentation

Subsets EEG data by subject, sensor, time, or epoch

Description

Filters an input dataset by optional constraints on subject, sensor, time, and epoch. Filters are combined with logical AND, and exact value matching (%in%) is used.

Usage

pick_data(
  data,
  subject_rg = NULL,
  sensor_rg = NULL,
  time_rg = NULL,
  epoch_rg = NULL
)

Arguments

data

A data frame, tibble or database table with input data. Required columns depend on the further parameters: setting subject_rg requires subject column etc.

subject_rg

Optional vector of subject identifiers to keep (character or numeric, matching data$subject). If NULL (default), no filtering is applied based on subject.

sensor_rg

Optional vector of sensor identifiers to keep (character or numeric, matching data$sensor). If NULL (default), no filtering is applied based on sensor.

time_rg

Optional vector of time points to keep (numeric, matching data$time). If NULL (default), no filtering is applied based on time.

epoch_rg

Optional vector of epoch identifiers to keep (character or numeric, matching data$epoch). If NULL (default), no filtering is applied based on epoch.

Details

All filters are combined conjunctively (AND). Matching uses membership (%in%) with case-sensitive comparison for character columns. On database backends, very long *_rg vectors may not translate efficiently; consider pre-filtering or semi-joins.

Value

An object of the same class as data with rows filtered by the provided criteria; columns are unchanged. If all filters are NULL, the input is returned unmodified. If no rows match, the function ends with error message.

See Also

compute_mean, baseline_correction, pick_region

Examples

# Filtering epochs 1:5 and time points 1:10 for all subjects and sensor "E45"
data_subset <- pick_data(epochdata, sensor_rg = "E45",
 time_rg = 1:10, epoch_rg = 1:5)
head(data_subset)

diegr documentation built on Nov. 5, 2025, 5:25 p.m.