mne-python
mne-python copied to clipboard
plotting cov from mne.make_ad_hoc_cov leads to error
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
We should fix plot_cov to deal with diagonal noise covariances (which includes those returned by make_ad_hoc_cov)