Skip to content

ENH: make compute_covariance work with Evoked objects - #14129

Merged
wmvanvliet merged 6 commits into
mne-tools:mainfrom
BabaSanfour:compute-cov-evoked
Aug 6, 2026
Merged

ENH: make compute_covariance work with Evoked objects#14129
wmvanvliet merged 6 commits into
mne-tools:mainfrom
BabaSanfour:compute-cov-evoked

Conversation

@BabaSanfour

@BabaSanfour BabaSanfour commented Aug 3, 2026

Copy link
Copy Markdown
Member

Reference issue (if any)

Closes #14115.

What does this implement/fix?

Accept Evoked through existing epochs argument and reject keep_sample_mean=False. With Evoked data we treat samples will be treated as observations and channels as variables: spatial covariance over time, not an estimate of trial-to-trial noise covariance

Possible alternatives/Improvements

  1. as an alternative we can wrap Evoked in Epoch object.
  2. for arguments we accept inst (for instance instead of epochs) but this will require 2-3 releases and some backward compatibility maintenance.

Additional information

With the help of claude Opus5; all lines added were read and double checked.

@BabaSanfour

Copy link
Copy Markdown
Member Author

@larsoner PR is ready; code works as intended, one improvement would be changing epochs to inst, this would require some deprecation cycles (?).

Comment thread mne/cov.py
Comment thread mne/cov.py Outdated
Comment thread mne/cov.py Outdated
@wmvanvliet

Copy link
Copy Markdown
Contributor

This is useful, also for the upcoming dipole fitting GUI :)

@BabaSanfour

Copy link
Copy Markdown
Member Author

Thanks @wmvanvliet , i was going to make it an inst .. but not sure how i should handle deprecation here. Should i just change it ?

@wmvanvliet

Copy link
Copy Markdown
Contributor

it's only not compatible if someone explicitly does mne.compute_covariance(epochs=epochs) which I don't think is many. We could add a named parameter epochs that will raise a deprecation warning when used but otherwise just maps to inst.

Comment thread mne/cov.py Outdated
Comment thread doc/changes/dev/14129.apichange.rst Outdated
@BabaSanfour
BabaSanfour requested a review from wmvanvliet August 4, 2026 20:21
@wmvanvliet

Copy link
Copy Markdown
Contributor

Thanks, @BabaSanfour!

@wmvanvliet
wmvanvliet merged commit f20829c into mne-tools:main Aug 6, 2026
28 checks passed
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.

ENH: make compute_covariance work with Evoked objects

3 participants