✦ Day 05 · Preprocessing

Artifact Subspace
Reconstruction

An automatic, principled method that learns the statistical fingerprint of clean EEG and reconstructs any window that deviates beyond a threshold — no manual component inspection required.

🧹 Automatic Cleaning 📊 PCA Subspace ⏱ Sliding Window 🎯 Cutoff Tuning 🐍 asrpy / meegkit

Artifact Subspace Reconstruction (ASR) is a principled, automatic method for removing high-amplitude transient artifacts from continuous EEG — muscle bursts, electrode pops, sudden head movements — without requiring manual inspection of every component. Originally developed for real-time brain–computer interfaces (BCI), it has become a mainstay in offline preprocessing pipelines.


1

The Core Intuition
Clean Brain Has Predictable Statistics

The fundamental assumption behind ASR: genuine brain signals have a stable, predictable covariance structure, while transient artifacts are statistical outliers that violate that structure.

Imagine you have learned the “normal heartbeat” of your EEG — the typical spatial pattern of voltage across all channels during a clean segment. When a muscle artifact strikes, some directions in channel-space suddenly explode in variance. ASR identifies those anomalous directions and “reconstructs” the data as if the artifact never happened.

Analogy: Think of ASR as a building inspector. The inspector first measures the structural parameters of a healthy building (calibration). Then, room by room (sliding window), the inspector checks whether any wall is bulging beyond tolerance. If so, only the bulging wall is reconstructed — the rest of the building is left untouched.


2

The Algorithm Step-by-Step
Calibrate → Window → PCA → Reconstruct

Step 1 — Calibration: Find a clean segment of data (typically 30–60 seconds) and compute the reference covariance matrix Cref. This defines “normal.”

Step 2 — Sliding window: Move a short window (~500 ms) across the continuous recording.

Step 3 — PCA decomposition: In each window, decompose the multichannel signal into principal components. Compare each component’s variance against the reference.

Step 4 — Threshold & reconstruct: If a component’s variance exceeds the reference by more than the cutoff parameter (in standard deviations), it is identified as artifact. The artifactual subspace is removed and the “clean” portion is projected back to sensor space.

Python
from asrpy import ASR

# High-pass filter first (ASR requires zero-mean data)
raw.filter(l_freq=1.0, h_freq=None)

# Fit ASR on a clean calibration segment
asr = ASR(sfreq=raw.info['sfreq'], cutoff=20)
asr.fit(raw)

# Transform the entire recording
raw_clean = asr.transform(raw)

3

The Cutoff Parameter
Conservative vs. Aggressive Cleaning

The cutoff parameter controls how aggressively ASR cleans. It is measured in standard deviations of the reference distribution:

Aggressive (cutoff = 5–10)

Removes more artifact but risks removing genuine brain activity. Good for heavily contaminated data or BCI applications.

Conservative (cutoff = 20–30)

Only removes the most extreme artifacts. Preserves more brain signal. Recommended starting point for research pipelines.

Prerequisites: ASR needs the data to be high-pass filtered (≥0.5 Hz) and not common-average re-referenced beforehand (this reduces rank and confuses the PCA step).


4

ASR vs. ICA
When to Use Each

ASR and ICA are complementary, not competing. ASR excels at removing transient, non-stereotypical artifacts (bumps, pops, isolated muscle bursts) that ICA struggles with because they don’t have a consistent spatial pattern across the recording. ICA excels at removing stereotypical, recurring artifacts (eye blinks, heartbeats) that have a stable spatial signature.

Many modern pipelines run ASR first, then ICA — ASR handles the outliers so ICA can focus on the systematic components.

References: Mullen et al. (2015) — original ASR paper. Chang et al. (2020) — comprehensive ASR parameter evaluation. asrpy and meegkit.asr for Python implementations.