Preprocessing Functions for PhysioExperiment Objects
PhysioPreprocess provides a comprehensive preprocessing toolkit for multi-modal physiological signal data. Built on top of PhysioCore, it delivers 30 exported functions covering digital filtering (Butterworth, FIR, notch), resampling and interpolation, ICA-based artifact removal, bad channel detection, baseline correction, re-referencing, and reproducible preprocessing pipelines -- all operating directly on PhysioExperiment objects.
You can install PhysioPreprocess from r-universe:
# the containers build on Bioconductor, so its repositories are needed too
install.packages("BiocManager", repos = "https://cloud.r-project.org")
install.packages("PhysioPreprocess",
repos = c("https://x-biosignal.r-universe.dev", BiocManager::repositories()))
Or install the development version from GitHub:
# install.packages("remotes", repos = "https://cloud.r-project.org")
remotes::install_github("x-biosignal/PhysioPreprocess")
library(PhysioPreprocess)
# Create sample EEG data (4 seconds, 4 channels, 250 Hz)
signal_matrix <- matrix(rnorm(1000 * 4), nrow = 1000, ncol = 4)
pe <- PhysioExperiment(
assays = list(raw = signal_matrix),
samplingRate = 250
)
# Apply a 1-40 Hz bandpass Butterworth filter
pe <- butterworthFilter(pe, low = 1, high = 40, order = 4)
# Remove 50 Hz line noise with a notch filter
pe <- notchFilter(pe, freq = 50)
# Re-reference to the average of all channels
pe <- rereference(pe, ref_type = "average")
# Check reference status
isAverageReferenced(pe) # TRUE
A full suite of frequency-domain filters for physiological signals:
butterworthFilter() -- bandpass, lowpass, highpass, and band-stop IIR filters with configurable orderfirFilter() -- finite impulse response filters for linear-phase filteringnotchFilter() -- remove power line interference (50/60 Hz) and harmonicsfilterSignals() -- moving-average smoother over a configurable sample windowdetrendSignal(), detrendSignals() -- remove linear or polynomial trends from signalsFlexible sample rate conversion and multi-rate signal support:
resample(), decimate(), interpolate() -- change sampling rates with anti-aliasingassaySamplingRates(), setAssaySamplingRate() -- manage per-assay sampling rates for mixed-rate recordingsAutomated and semi-automated artifact detection and removal:
icaDecompose(), runICA() -- decompose signals into independent components for artifact identificationicaRemove(), removeICAComponents() -- remove artifact components (e.g., eye blinks, muscle activity) and reconstruct clean signalsdetectBadChannels(), interpolateBadChannels() -- identify noisy or flat channels and interpolate from neighborsrejectBadEpochs() -- reject epochs exceeding amplitude or variance thresholdsRemove baseline drift and DC offsets:
baselineCorrect() -- subtract mean of a specified baseline window from each epochremoveBaseline() -- flexible baseline removal with configurable time windows and methodsElectrode re-referencing for EEG and related modalities:
rereference() -- re-reference to average, specific electrode(s), or linked mastoidsgetCurrentReference() -- query the current reference schemeisAverageReferenced() -- check whether average reference has been appliedBuild reproducible, shareable preprocessing chains:
createPipeline() -- define an ordered sequence of preprocessing steps with parametersapplyPipeline() -- apply a saved pipeline to new data for consistent processing across datasets# Build a reusable preprocessing pipeline
pipeline <- createPipeline(
list(fn = butterworthFilter, low = 1, high = 40),
list(fn = notchFilter, freq = 50),
list(fn = rereference, ref_type = "average")
)
# Apply to any PhysioExperiment
pe_clean <- applyPipeline(pe, pipeline)
PhysioPreprocess is part of the PhysioExperiment ecosystem, a suite of R packages for multi-modal physiological signal analysis:
| Package | Description |
|---|---|
| PhysioCore | Core data structures and accessors |
| PhysioIO | File I/O (EDF, HDF5, BIDS, CSV, MAT) |
| PhysioPreprocess | Signal preprocessing and artifact removal |
| PhysioAnalysis | Spectral analysis, epoching, statistics, visualization |
| PhysioMoCap | Motion capture data processing |
| PhysioOpenSim | OpenSim biomechanical modeling integration |
Visit the r-universe page to browse all available packages.
MIT License. See LICENSE for details.
Yusuke Matsui
Part of the Physio ecosystem. Community and policy documents (Code of Conduct, Contributing, Governance, Support, Security, and Deprecation & lifecycle) live in the umbrella repository.