Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/dev/13582.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where plotting covariance matrices created by :func:`mne.cov.make_ad_hoc_cov` would raise an IndexError, by :newcontrib:`Arnav Kumar` (:gh:`13582`).
1 change: 1 addition & 0 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
.. _Antti Rantala: https://github.com/Odingod
.. _Apoorva Karekal: https://github.com/apoorva6262
.. _Archit Singhal: https://github.com/architsinghal-mriirs
.. _Arnav Kumar: https://github.com/Arnav1709
.. _Arne Pelzer: https://github.com/aplzr
.. _Ashley Drew: https://github.com/ashdrew
.. _Asish Panda: https://github.com/kaichogami
Expand Down
2 changes: 1 addition & 1 deletion mne/viz/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _index_info_cov(info, cov, exclude):
for key in _DATA_CH_TYPES_SPLIT
if len(idx_by_type[key]) > 0
]
C = cov.data[ch_idx][:, ch_idx]
C = cov._get_square()[ch_idx][:, ch_idx]
return info, C, ch_names, idx_names


Expand Down
15 changes: 15 additions & 0 deletions mne/viz/tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from mne import (
SourceEstimate,
create_info,
pick_events,
read_cov,
read_dipole,
Expand All @@ -19,6 +20,7 @@
read_source_spaces,
)
from mne.chpi import compute_chpi_snr
from mne.cov import make_ad_hoc_cov
from mne.datasets import testing
from mne.filter import create_filter
from mne.io import read_raw_fif
Expand Down Expand Up @@ -136,6 +138,19 @@ def test_plot_cov():
fig1, fig2 = cov.plot(raw.info)


def test_plot_cov_diagonal():
"""Test plotting of diagonal covariances (e.g., from make_ad_hoc_cov)."""
n_channels = 10
sfreq = 100
info = create_info(
[f"EEG{i:03d}" for i in range(n_channels)], sfreq, ch_types="eeg"
)
cov = make_ad_hoc_cov(info, std={"eeg": 1})
# This should not raise an IndexError
fig1, fig2 = cov.plot(info)
plt.close("all")


@testing.requires_testing_data
def test_plot_bem():
"""Test plotting of BEM contours."""
Expand Down
Loading