Pipeline
EEG: ERPs, measures and statistics
The EEG Analysis window takes EEG that was already cleaned, one file per participant, averages the trials of each condition into ERPs, measures a component in a time window and compares the conditions across participants. It works for scalp EEG and for rodent skull-screw recordings.
The five steps
1 Load EEG→2 ERPs→3 Measure→4 Statistics→5 Save
- Load EEG: click Load EEG files… and choose one file per participant (select several at once for a group), or Try demo data. EEGLAB .set, FieldTrip .mat and BrainVision .vhdr files are read as they are; for a plain .mat file a short form asks which variable holds the numbers, the sampling rate and the order of channels, samples and trials. A continuous recording with events is cut into trials: set Trial from / to (ms) and click Cut into trials.
- Read the Overview tab: for every participant it lists the channels, trials per condition, reference, electrode positions and what was already done to the data (filters, re-referencing, ICA, rejected trials, interpolated channels), read from the file. Nothing in the file is run.
- ERPs: keep Subtract a baseline (−200 to 0 ms by default) unless the data are already baseline-corrected, type the Channels to plot (for example
Pz, orCz, FCzto average them) and click Show ERPs. Above the plot, choose a participant or the grand average and the view: Conditions, All channels (butterfly) or Difference wave. - Measure: Mean amplitude (recommended) or Peak amplitude with its direction, in a time window at the chosen channels. The Measures tab has one row per participant and condition. A peak on the edge of the window is flagged, because it may not be a real peak.
- Statistics (two or more participants): Parametric or Nonparametric, then Compare conditions. Participants are matched across conditions: a paired t-test (or Wilcoxon) for two conditions, a repeated-measures ANOVA with post hoc tests (or Friedman) for three or more.
- Save: Export results… writes a .csv with one row per participant and condition, or a .mat with everything. Save session…, Report (PDF)… and Methods text… keep the analysis.
Methods
ERPs
- The ERP of a condition is the mean of its trials, per channel. With Subtract a baseline, the mean of the baseline window is first subtracted from every trial and channel.
- The grand average is the mean of the participants' ERPs, so every participant counts once whatever their number of trials. Its shade is the SEM across participants; for one participant the shade is the SEM across trials.
- Several channels typed together are averaged into one waveform (a region of interest).
Measures
- Mean amplitude: the average voltage in the window. It is robust to noise and does not depend on the number of trials, so it is the usual choice.
- Peak amplitude: the largest positive or negative value in the window and its latency. Peaks grow with noise, so compare them only between conditions with similar numbers of trials.
- Choose the window before looking at condition differences, from the grand average of all conditions or from the literature. Choosing it where the conditions differ most, and then testing that difference, inflates the effect ("double dipping").
Statistics
- One value per participant and condition, compared within participants. Three or more conditions: repeated-measures ANOVA with Mauchly's test and the Greenhouse–Geisser correction when needed, then Holm-corrected paired t-tests. The other test family runs as a robustness check. The computations are in
core/EEGAnalysis.mandcore/GroupStats.m(base MATLAB, no toolboxes).
Inputs and outputs
In (one file per participant)
- EEGLAB .set (numbers inside, or in a .fdt file next to it): trials or a continuous recording with events, channel names and positions, and the EEGLAB history
- FieldTrip .mat (raw or timelock data): trials with trialinfo, channel names, electrode positions and the cfg history
- BrainVision .vhdr from Brain Products Recorder or Analyzer (and exports from EEGLAB or MNE), read with its .vmrk and .eeg files from the same folder: continuous recordings with their markers, or segments exported from Analyzer, with units and the amplifier filters
- A plain .mat with the numbers and a sampling rate; a form asks what each variable is. Values in volts are converted to µV
- All participants need the same channels and trial times
Out
- .csv: Participant, Condition, Value_uV, Latency_s (peak only), Trials, PeakAtEdge
- .mat: struct
resultswith the ERPs of every participant and the grand average, the settings, the measures and the statistics - Session, one-page PDF report and a draft methods text (see Sessions and reports)
Walkthrough on the demo data
Demo expectations
The demo data are made by core/demo/demoEEG.m, with known answers.
- Data (Try demo data): an oddball study, 8 participants, 32 channels at 250 Hz, trials from −200 to 800 ms, already cleaned (band-pass 0.1–30 Hz, average reference, ICA components 1 and 3 removed, 5 trials rejected, T7 interpolated: the Overview tab lists these steps). Conditions Standard (40 trials), Target (15) and Novel (15) before rejection.
- Simulated: P1 +2 µV at 60 ms (Oz), N1 −5 µV at 100 ms (Cz), P300 at 350 ms (Pz): Target 10 > Novel 6 > Standard 2 µV, 10 Hz alpha over O1 / Oz / O2 in random phase, noise. Participants differ by about ±10% in amplitude and ±10 ms in latency.
- ERPs at Pz (grand average): the three lines split after about 250 ms, Target highest, peaking near 350 ms (about 8 µV).
- Mean amplitude, 300–400 ms, Pz: about 7 µV Target, 4 µV Novel, 1.5 µV Standard in every participant. These are lower than the simulated peaks because the window also takes the flanks of the wave, and the average reference takes a little away from every channel.
- Compare conditions, parametric: repeated-measures ANOVA, p < 0.0001, every pair differs (Target − Standard about +6 µV). Nonparametric: Friedman χ²(2) = 16, p = 0.0003.
- N1: peak amplitude, negative, 50–150 ms at Cz: about −4.5 µV near 100 ms in every condition.
- Rodent (continuous, 4 skull screws at 1000 Hz, 60 s, 30 light flashes): cut from −100 to 400 ms gives 30 trials; at V1 a negative peak of about −40 µV at 50 ms and a positive one of about +25 µV at 100 ms, about 30% of that over M1.
Troubleshooting
| Problem or message | What to do |
|---|---|
| The plain .mat form opens | A plain .mat file does not say which variable is the EEG or how it is ordered. Choose the variable with the numbers, the sampling rate and the order of the numbers (for example trials × channels × samples). |
| "Unknown channel" | The names must match the file's channel names (any case), separated by commas. The Overview tab and the butterfly view show the names. |
| "other channels / other trial times than participant 1" | Every participant needs the same channels in the same order and the same trial times. Interpolate or remove channels and cut the trials the same way before loading them together. |
| Peaks flagged "on the window edge" | The window cuts through a slope instead of around a peak. Widen it, check the direction, or use the mean amplitude. |
| A condition is missing from the grand average | Only conditions present in every participant are averaged and compared. The Overview lists the trials per condition of each participant. |
| Statistics button greyed out | Load two or more participants, Show ERPs, then Measure. |