Skip to content

Comments

DOC: clarify average EEG reference behavior and update tutorial note#13664

Open
Farzah11 wants to merge 4 commits intomne-tools:mainfrom
Farzah11:fix-eeg-reference-doc
Open

DOC: clarify average EEG reference behavior and update tutorial note#13664
Farzah11 wants to merge 4 commits intomne-tools:mainfrom
Farzah11:fix-eeg-reference-doc

Conversation

@Farzah11
Copy link

This PR clarifies the behavior of average EEG referencing when the original
reference electrode is not present in the data.

  • Adds an explicit note to the set_eeg_reference docstring explaining that
    the average is computed only over existing EEG channels.
  • Updates the preprocessing tutorial to explicitly mention using
    add_reference_channel when applying an average reference and the original
    reference is missing.

Closes #13618

channel (or was removed during acquisition or preprocessing), it is not
implicitly accounted for in the average.
For sensor-space analyses where this distinction matters, consider adding
a zero-filled reference channel using :func:`add_reference_channel` before
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will need to be a fully qualified path or else the cross-reference will fail, e.g. :func:`~mne.add_reference_channels`

Comment on lines 144 to 151
# Note:
# When computing an average reference, if the dataset does not include
# the original reference electrode, the average will be biased because
# the missing channel is ignored. To avoid this, first add a
# zero-valued reference channel using
# mne.add_reference_channels(). This ensures that
# all intended channels, including the original reference,
# contribute correctly to the average.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as written, this will get treated like code comments. To format it like a normal paragraph, it needs # %% as the first line of the block. You could also consider making it a true "note" admonition, using .. note:: as the first line and indenting the rest.

@Farzah11
Copy link
Author

Hi @drammock ,

I’ve pushed updates addressing the points you mentioned. I noticed that the build_docs and linkcheck checks are currently failing, Kindly review when convenient. Thank you:)

@tsbinns
Copy link
Contributor

tsbinns commented Feb 18, 2026

@Farzah11 Those checks aren't failing as such, they're just not being run because you don't have an account with CircleCI. If you sign up (and push another commit), they'll run.

@drammock
Copy link
Member

for now I've manually triggered a re-run.

@drammock
Copy link
Member

in the data. If the original reference electrode was not recorded as a
channel (or was removed during acquisition or preprocessing), it is not
implicitly accounted for in the average.
For sensor-space analyses where this distinction matters, consider adding

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not definite enough. Maybe:

This matters for sensor-space analyses: The resulting reference would not be a correct average reference, as the subtracted reference signal would be divided by n-channels and not n-channels + 1 reference channel. Further discussion can be found in Kim et. al 2013 https://doi.org/10.3389/frsip.2023.1064138. Consider adding a ...

@Farzah11
Copy link
Author

Thanks for the clarification and for manually re-running the checks.
I’ve just set up CircleCI on my fork and will next revise the wording per the feedback and build the docs locally to address the failures before pushing updates.

- Move average reference note to docs.py (set_eeg_reference_see_also_notes)
- Remove floating text from reference.py docstring
- Add note to tutorial about using add_reference_channels for correct avg ref
- Include Kim et al. (2023) paper reference
- Fix line lengths to comply with PEP 8 (<= 79 chars)
@Farzah11 Farzah11 force-pushed the fix-eeg-reference-doc branch from dec3ef8 to f44ea8f Compare February 22, 2026 20:32
@Farzah11 Farzah11 requested a review from larsoner as a code owner February 22, 2026 20:54
@Farzah11
Copy link
Author

Hi,

I’ve been investigating the build_docs and linkcheck checks and attempted to reproduce them locally.

From the CircleCI page, it appears the jobs are currently blocked with block-unregistered-user, so the documentation build has not actually executed yet.

Could a maintainer please approve or rerun the CircleCI workflow for this PR when convenient?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document that add_reference_channel should be used with set_eeg_reference for average reference

4 participants