Level 3 L3.6

Single-trial approaches

ERP images, RT sorting, single-trial regression (rERP), and linear deconvolution for overlapping events.

~45 min Notebook: nb-3-6-erp-image

Prerequisites: L3.5 · SNR, trial counts and design

1 claim on this page is unverified. TODO(confirm) marks a specific statement the author has not yet checked against a primary source. Everything else on this page has been reviewed. Treat a marked claim as provisional and go to the cited source rather than quoting the sentence.

Objectives

  • Build ERP images
  • Sort trials by RT
  • Run single-trial regression (rERP)
  • Describe linear deconvolution for overlapping events

Why this matters

The average is a summary, and like every summary it is ambiguous: a component that is small in the average may be small on every trial, present on half of them, or present on all of them at wildly varying latencies. Those are different claims about the brain, and the average cannot distinguish them. Looking at the trials — as an image, as a regression, as a deconvolution — recovers the distinctions, and turns trial-level variables such as reaction time from nuisance into data.

Concepts

What the average hides

Write the trials as a stimulus-locked response plus noise, as L3.2 did, and then relax the assumption that the response is identical:

  • Latency jitter. If the same sharp component occurs at a different time on each trial, the average is a broad, low deflection. Amplitude in the average has fallen, but nothing about the single-trial amplitude has.
  • Trial-to-trial amplitude variation. A component present on 40% of trials with large amplitude, and a component present on every trial at 40% of that amplitude, give the same average.
  • Ordering effects. Habituation, fatigue and learning change the response across the session; the average of a non-stationary sequence is a number no individual trial resembles.

None of these is exotic; all three are the normal condition of real data. The ERP image is the standard first look at them.

The ERP image

An ERP image is the epoch matrix drawn as a picture: one row per trial, time on the horizontal axis, amplitude as colour, with the average plotted beneath it on the same time axis. Three conventions make it readable:

  • Sort the rows by something meaningful (below), never by acquisition order unless order is the variable of interest.
  • Smooth vertically across a small number of neighbouring trials. Single trials are dominated by noise; a moving average over, say, a few dozen neighbouring rows makes a consistent feature visible without touching the time axis. State the smoothing width, because it is a filter across trials and it can manufacture apparent structure if it is wide relative to the sorting variable’s range.
  • Fix the colour scale in µV and state it, for the same reason a topography needs a stated scale (L3.4).

What you are looking for: a band of colour that runs straight across the image (a response at constant latency), a band that slopes (latency covarying with the sorting variable), a band present in only part of the image (the response occurring on a subset of trials), and horizontal streaks confined to a few rows (artifacts that survived rejection).

Sorting, and what a sorted image shows

Sorting by reaction time is the standard case. Plot the reaction time itself as a curve on top of the image and the question answers itself visually: a component that is time-locked to the stimulus stays vertical as the reaction-time curve slopes away from it; a component time-locked to the response follows the curve. Components can also do something in between — the P3 is the classic case, often shifting with reaction time but by less than the reaction time itself, which is exactly the kind of statement a single number cannot capture.

Other useful sorts: by trial number (habituation and drift), by pre-stimulus alpha power or another state variable (L4.x), by accuracy, by stimulus property, or by the amplitude of another component in the same trial.

Two cautions. Sorting by a variable and then observing that the image varies with it is not a test — the image is exploratory, and the statistical claim has to be made on the measurements (L3.7, L6.2). And sorting by a variable that is itself correlated with data quality (movement, time on task) will show a gradient that is an artifact gradient.

Single-trial regression: rERP

Instead of averaging within condition, fit a linear model at every time point and every channel, with one observation per trial:

amplitude(t, channel) ~ b0(t) + b1(t)·condition + b2(t)·rt + …

The estimated coefficients, plotted against time, are regression ERPs: b0(t) is an intercept waveform, and each b_k(t) is the waveform of the effect of that predictor, in µV per unit of the predictor. Averaging is the special case in which the only predictor is a categorical condition and the design is balanced.

What this buys:

  • Continuous predictors — reaction time, stimulus frequency, trial number, a pre-stimulus state measure — without binning them into artificial groups. Binning a continuous variable throws away information and makes the result depend on the bin edges.
  • Several predictors at once, so that partially confounded variables can be separated: the effect of word frequency estimated while controlling for word length, the effect of condition while controlling for reaction time.
  • Unbalanced designs handled by the model rather than by subsampling.
  • A natural route to the group level: per-subject coefficient waveforms are the input to the same second-level tests as condition averages (L3.7), and the trial-level version goes into mixed models (L6.2).

What it costs: a model, with the model’s assumptions — linearity in the predictors, and the usual consequences of collinearity between them. Reaction time and condition are often strongly correlated, and a regression cannot invent the information needed to separate two predictors that move together.

Linear deconvolution for overlapping events

L3.1 left overlapping trials as an unsolved problem when the interval is fixed or when it differs between conditions. Linear deconvolution is the general solution. Model the continuous recording as the sum of responses to every event, each one a waveform of unknown shape placed at that event’s time:

EEG(t) = Σ_events  response_type(t − onset_event) + noise(t)

Written as a design matrix with one column per (event type × time lag) and one row per sample, this is an ordinary linear regression over the continuous data, and its solution is the set of overlap-corrected response waveforms. Combining it with the regression idea above gives the general framework — regression over continuous data with deconvolution — implemented in the unfold toolbox and described by (Ehinger, 2019) , which also covers the extension to non-linear predictor effects via basis functions.

What it can do: recover the response to each event type when stimulus, response and eye-movement events overlap in time; handle intervals that differ between conditions; remove the contribution of the preceding trial from the baseline interval.

What it cannot do: invent an interval that never varies. If two event types always occur at exactly the same lag, their responses are not separately identifiable, and the model will distribute activity between them in a way determined by the regularisation rather than by the data. Some jitter in the design is the precondition for deconvolution, which returns the argument to L3.5: the fix is cheapest at design time.

What single-trial methods do not fix

They do not make a noisy recording clean. A single trial has the signal-to-noise ratio of a single trial, and every method here either smooths across trials (the ERP image), pools them through a model (rERP), or pools them across time and events (deconvolution). What changes is what you can ask: whether a component’s latency covaries with behaviour, whether an effect is amplitude or probability, whether an apparent component belongs to the preceding event. Those are questions the average cannot answer, and none of them requires a cleaner recording than the average needed.

The data behind this lesson

  • ds-erpcore P3, CC BY 4.0, open access, per-subject downloadable; 30 EEG + 3 EOG channels, 1024 Hz, CMS reference, 60 Hz mains, no software filters, 40 participants per paradigm. The P3 paradigm records a response on target trials, so reaction time is available per trial — which is what makes it the right dataset for this lesson. TODO(confirm): the author mirrors the ERP CORE entry into the catalogue registry and signs off the dataset page (§10.11 item 8); the shipped asset sidecars also record a licence conflict in the source — the OSF node record says CC BY 4.0, the per-paradigm component’s own LICENSE file says CC BY-SA 4.0 and its dataset_description.json says CC0 — which the author reconciles (§13 item 22).
  • The epoch metadata built in L3.1 is the input here: reaction time, accuracy and trial index must already be attached to the epochs, aligned through rejection.

Explore

This lesson has no widget. The exploration is the ERP image itself, built in the notebook and read in this order:

  • Unsorted first, in acquisition order, to see the artifacts and any drift across the session before anything is rearranged;
  • sorted by reaction time, with the reaction-time curve drawn over the image, asking of each visible band whether it stays vertical (stimulus-locked), follows the curve (response-locked), or slopes less steeply than the curve (partially latency-tracking);
  • at two smoothing widths, to confirm that a feature is in the data and not in the vertical smoothing;
  • response-locked, re-epoching on the response instead of the stimulus, which turns the same trials into a picture of what is time-locked to the action rather than to the stimulus;
  • beside the average, to name what the average lost: a band that slopes in the image is a broad, low deflection in the average below it.

Practice

Single-trial approaches: an ERP image sorted by reaction time, single-trial P3 latency against reaction time, and a regression ERP nb-3-6-erp-image

Level 3 ~5 min
notebooks/L3/nb-3-6-erp-image.ipynb

Downloads from ds-erpcore.

Open in Colab Download Read it here

The notebook builds ERP images from ds-erpcore P3 epochs sorted by reaction time, then fits a single-trial regression with reaction time as a continuous predictor and plots the coefficient waveforms. Its final cell prints the correlation this lesson’s exercise asks for.

Exercises

Exercise ex-3-6-p3-latency-rt

Numeric

For the subject the notebook uses, what is the correlation across trials between single-trial P3 latency and reaction time?

Accepted within ±0.05.

Exercise ex-3-6-image-reading

Multiple choice

In an ERP image sorted by reaction time, with the reaction-time curve drawn on top, a band of positive colour follows the reaction-time curve closely rather than staying vertical. What does that indicate?

Options

Exercise ex-3-6-what-the-average-hid

Free response

The average shows a small, broad positivity. The ERP image shows a sharp band of the same polarity that slopes across the trials. Say what the average got wrong, and what you would report instead.

Pitfalls

No pitfall for this lesson: Spec §6 lists no pitfall for this lesson (§5.3 exemption).

In other tools

In other toolsEEGLAB — names only

The equivalents of what this lesson does, for a reader who works in another toolbox. Function names only: their own documentation is the place to learn how to call them.

EEGLAB

  • erpimageEEGLAB
  • pop_erpimageEEGLAB
  • pop_rerprERP plugin (install separately)

Names checked 2026-09-18 against EEGLAB 2026.0.0 (plugins at the versions in EEGLAB’s own plugin list).

Reading

  1. Ehinger & Dimigen (2019). Unfold. unverified