Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotting cov from mne.make_ad_hoc_cov leads to error #13142

Open
sappelhoff opened this issue Mar 4, 2025 · 1 comment
Open

plotting cov from mne.make_ad_hoc_cov leads to error #13142

sappelhoff opened this issue Mar 4, 2025 · 1 comment
Labels

Comments

@sappelhoff
Copy link
Member

sappelhoff commented Mar 4, 2025

I want to create an identity covariance matrix. Using the code (make_ad_hoc_cov) below seems to work, however plotting leads to:

IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

Going the non-recommended way of instantiating mne.Covariance directly works, however.

Am I on the wrong track to create an identity matrix this way, or is this a potential issue with the code in mne?

import mne
import numpy as np

n = 50
sfreq = 100
info = mne.create_info([f"ch{i}" for i in range(n)], sfreq, ch_types='eeg', verbose=None)

# recommended way?
cov = mne.cov.make_ad_hoc_cov(info, std={"eeg": 1})
cov.plot(info)  # error

# not recommended
cov2 = mne.Covariance(data=np.eye(n), names=info.ch_names, bads=info["bads"], projs=[], nfree=1)
cov2.plot(info)  # works
@larsoner
Copy link
Member

larsoner commented Mar 4, 2025

We should fix plot_cov to deal with diagonal noise covariances (which includes those returned by make_ad_hoc_cov)

@sappelhoff sappelhoff added the BUG label Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants