Skip to contents

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.

Installation

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")

Quick Start

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

Features

Digital Filters

A full suite of frequency-domain filters for physiological signals:

  • Butterworth: butterworthFilter() – bandpass, lowpass, highpass, and band-stop IIR filters with configurable order
  • FIR: firFilter() – finite impulse response filters for linear-phase filtering
  • Notch: notchFilter() – remove power line interference (50/60 Hz) and harmonics
  • Smoothing: filterSignals() – moving-average smoother over a configurable sample window
  • Detrending: detrendSignal(), detrendSignals() – remove linear or polynomial trends from signals

Resampling

Flexible sample rate conversion and multi-rate signal support:

Artifact Handling

Automated and semi-automated artifact detection and removal:

Baseline Correction

Remove baseline drift and DC offsets:

  • baselineCorrect() – subtract mean of a specified baseline window from each epoch
  • removeBaseline() – flexible baseline removal with configurable time windows and methods

Re-referencing

Electrode re-referencing for EEG and related modalities:

Pipeline API

Build reproducible, shareable preprocessing chains:

  • createPipeline() – define an ordered sequence of preprocessing steps with parameters
  • applyPipeline() – 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)

Dependencies

  • R (>= 4.2)
  • PhysioCore – core data structures
  • signal – DSP primitives
  • methods, SummarizedExperiment, S4Vectors, stats
  • Suggests: fastICA, testthat, knitr, rmarkdown

PhysioExperiment Ecosystem

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.

License

MIT License. See LICENSE for details.

Author

Yusuke Matsui

Governance & support

Part of the Physio ecosystem. Community and policy documents (Code of Conduct, Contributing, Governance, Support, Security, and Deprecation & lifecycle) live in the umbrella repository.