Skip to content

plotting cov from mne.make_ad_hoc_cov leads to error #13142

@sappelhoff

Description

@sappelhoff

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

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