Skip to content

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.

@CarinaFo
Copy link
Contributor

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.

Hi Farzah,

Could you explain what went wrong during your attempt at running the documentation locally?

I had some issues on the weekend with building docs on a windows 11 server in python 3.11, so I might be able to help.

Please also let us know if the documentation is unclear or missing something.

Thank you for contributing,

Carina

@Farzah11
Copy link
Author

Hi Carina,

I built the docs locally on Windows 11 / Python 3.11 using make html and make linkcheck, and didn’t encounter a hard Sphinx error locally.

At the moment I’m not seeing a specific CI failure yet, as the CircleCI jobs appear to be blocked with block-unregistered-user, so the docs build doesn’t actually run or produce logs.

Once the checks are approved and run, I should be able to see any concrete errors and debug them properly.

Thanks for the offer to help.

@tsbinns
Copy link
Contributor

tsbinns commented Feb 23, 2026

@Farzah11 Please see this comment and make an account with CircleCI so that the jobs don't need to be manually triggered by us each time: #13664 (comment)

But there is an issue with the changed docstring, as shown by this test failure: https://github.com/mne-tools/mne-python/actions/runs/22285364149/job/64470384061?pr=13664

@Farzah11
Copy link
Author

Hi, I’ve created a CircleCI account as suggested.

The CI jobs are still blocked with block-unregistered-user, so I believe my GitHub account needs to be approved for CircleCI on the MNE-Python side.

@drammock Could you please approve my GitHub account for CI so the jobs can run automatically?

In parallel, I’m fixing the docstring-related test failure shown in the GitHub Actions log and will push an update shortly.

Thanks!

@tsbinns
Copy link
Contributor

tsbinns commented Feb 25, 2026

The CI jobs are still blocked with block-unregistered-user, so I believe my GitHub account needs to be approved for CircleCI on the MNE-Python side.

@Farzah11 You need to push a commit (even an empty one) to trigger another CI run.

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

5 participants