Preprocessing#
The preprocessing module covers the full EEG pipeline, epoch preparation, rigid-body motion kinematics, and a set of lower-level signal-processing utilities that the pipeline calls internally but which are also usable standalone.
EEG pipeline#
EEGPreprocessor orchestrates the full pipeline:
ZapLine → bad-channel detection → bandpass filter → ASR → ICA/AMICA →
ICLabel classification → dipole fitting → average re-reference → bad-channel
interpolation. All steps are recorded in a provenance descriptor stored on
the mne.io.Raw object.
|
Preprocess EEG. |
Reporting#
Builds an mne.Report summarising a single EEGPreprocessor run
(bad channels, ICA, dipoles, and full-length stream traces for drop-out
inspection). Called automatically by EEGPreprocessor.run_raw() when
make_report=True (the default); can also be called directly on saved
pipeline outputs.
|
Build and return an mne.Report for EEGPreprocessor outputs. |
Bad channel detection#
Standalone bad-channel detector that combines PyPREP, FASTER, per-channel
flatline detection, and a line-noise z-score criterion. Called automatically
by EEGPreprocessor but can also be run on any
mne.io.Raw object directly.
|
Detect bad EEG channels using PyPREP, FASTER, flatline, and line noise. |
Signal cleaning#
Individual signal-processing steps that EEGPreprocessor calls
internally. Useful when building a custom pipeline or applying a single step
in isolation.
|
Remove spectral line noise from EEG using ZapLine (DSS-based). |
|
Apply ASR to the EEG channels of raw. |
|
Fit ICA on a filtered copy of raw and label components with ICLabel. |
|
Detect channels with abnormally high line noise power. |
|
Total pairwise MI reduction under the Gaussian approximation. |
|
Return a copy of raw containing only the requested subset of channels. |
Dipole fitting#
|
Fit one or two dipoles to each ICA component topography. |
|
Fraction of ICA topographies with dipole residual variance below rv_thresh. |
|
Automatically coregister head to fsaverage MRI and return the transform. |
Epoching#
Helpers for converting continuous preprocessed data into epochs, including stimulus-label renaming utilities for common BPN paradigms.
|
Prepare condition-specific epochs from a cleaned raw recording. |
|
Build an event rename map from |
Motion capture#
Rigid-body kinematics from XDF motion streams. Works on the motion data
returned by XDFLoader in
motion.
|
Detect rigid body names from channel naming conventions. |
|
Process rigid body motion capture streams. |
|
Return a dict of per-rigid-body Raw sub-objects. |
Provenance#
Lightweight provenance tracking: each pipeline step appends a JSON-serialisable
descriptor to mne.Info.description so that any saved file carries a
record of exactly how it was processed.
|
Initialise a provenance descriptor dict for a processing run. |
|
Serialise descriptor and store it in |
|
Return the provenance descriptor stored in raw, or |
|
Append a named processing step to the provenance descriptor. |
|
Return only the kwargs that match func's signature. |
Utilities#
|
Record and log wall-clock durations of named pipeline steps. |
|
Format a duration in seconds as a compact human-readable string. |
|
Return a string with full environment and version information. |