Skip to content

ENH: make compute_covariance work with Evoked objects #14115

Description

@BabaSanfour

Describe the new feature or enhancement

In mne-denoise.DSS.linear, we need cov matrices for baseline and biased sensor covariance matrices from Evoked objects (mne-tools/mne-denoise#39). Now DSS falls back to numpy, but we want to make use of mne-python functions. One option could be an adapter we host in mne-denoise (mne-tools/mne-denoise#42). A cleaner implementation would be to work through mne.compute_covariance. @larsoner was already positive for this change (mne-tools/mne-denoise#42 (comment)).

Describe your proposed implementation

The change is minimal. We 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. I already have an implementation in my fork but I want to get confirmation for API before opening the PR. I also removed duplicate _unpack_epochs code and changed the function to _unpack_covariance_input.

Describe possible alternatives

  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 context

No response

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