mne-tools / mne-tools/mne-python
plotting cov from mne.make_ad_hoc_cov leads to error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.5k
- Forks
- 1.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example with mne.cov.make_ad_hoc_cov(info, std={"eeg": 1}) and cov.plot(info), then compare it with the directly constructed mne.Covariance example that plots successfully. Trace the make_ad_hoc_cov and Covariance.plot entry points; done means the recommended covariance object plots without the IndexError and the existing behavior remains covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100