Skip to content

Document that add_reference_channel should be used with set_eeg_reference for average reference #13618

@behinger

Description

@behinger

Proposed documentation enhancement

Hey!
We (mostly @jschepers) might have diagnosed an issue in MNE:

  • We often want to have a different reference e.g. average reference in EEG.
  • But also often, the reference channel is not included in the data-set (because it is flat / removed during recording etc.).

Then, when naively applying the average reference with set_eeg_reference, one can very easily get the wrong result, as the calculation in mne boils down to (we think, the projection-code makes tracing the actual calculation difficult to us):
sum(over_channels) / n_channels

  • "ignoring" the forgotten reference channel, and not
    sum(over_channels) / (n_channels+1) - including the "forgotten" reference channel.

The (for us) seemingly correct way to calculate average reference is to add_reference_channel before, then calculating the average reference (optional: drop the reference channel again for fullrank data).

We assumed, MNE does this by default, but we were wrong. We think this could be documented, that if the reference channel is not included in the data, one should add_reference_channel before calculating average reference.

We think for a user this is a super easy mistake to do, and indeed, in e.g. eeglab the "wrong" reference was calculated for many years as well (in 2017 the new function fullRankAveRef was added, see https://eeglab.ucsd.edu/wiki/Makoto%27s_preprocessing_pipeline "Why should we add zero-filled channel before average referencing? (10/31/2025 Updated"))

We are happy to provide some example code if necessary to understand. We can also propose some documentation in the tutorial + reference-function. One could also think to check if a reference channel is included in the data (we don't know how), and if not - either calculate sum(...)/(n+1). or add a channel prior to re-referencing, or throw a warning

We hope we didn't miss anything too obvious! Thanks a ton for the hard work.

Cheers, Bene & Judith

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions