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/JAMICA →
ICLabel classification → dipole fitting → bad-channel interpolation →
average re-reference. All steps are recorded in a provenance descriptor stored on
the mne.io.Raw object.
Outputs are named after BIDS: get_derivative_paths() lists the
derivative files written for a given fname_out, and the untouched input is
written to the raw part of the BIDS dataset.
|
Preprocess EEG. |
|
Return the paths of all derivatives |
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 (NaN/flat, deviation,
high-frequency noise, correlation and RANSAC), FASTER’s correlation and
variance criteria, and an optional line-noise z-score criterion. It works on
a 1 Hz high-passed, average-referenced copy (flat channels are found before
referencing) and warns when more than a fifth of the channels is flagged.
Called automatically by EEGPreprocessor but can also be run on any
mne.io.Raw object directly.
|
Detect bad EEG channels using PyPREP, FASTER and optionally 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. |
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.
|
Prepare condition-specific epochs from a cleaned raw recording. |
|
Build an event rename map from |
Motion capture#
Rigid-body kinematics from motion capture channels in a Raw object, e.g.
motion streams that XDFLoader merged into
MultimodalRecording.raw as special streams. Channel names follow the
<body>_quat_[xyzw], <body>_eul_[xyz] and <body>_pos_[xyz]
convention.
|
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. |