-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
FIX: Handle diagonal covariances in plot_cov #13582
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
base: main
Are you sure you want to change the base?
Changes from all commits
0c1e103
5de117e
9d9f2d2
e3b1a4b
4178d6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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`). | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |||||||||
|
|
||||||||||
| from mne import ( | ||||||||||
| SourceEstimate, | ||||||||||
| create_info, | ||||||||||
| pick_events, | ||||||||||
| read_cov, | ||||||||||
| read_dipole, | ||||||||||
|
|
@@ -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 | ||||||||||
|
|
@@ -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" | ||||||||||
| ) | ||||||||||
|
Comment on lines
+145
to
+147
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will do the same thing more compactly!
Suggested change
|
||||||||||
| cov = make_ad_hoc_cov(info, std={"eeg": 1}) | ||||||||||
| # This should not raise an IndexError | ||||||||||
| fig1, fig2 = cov.plot(info) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Outputs are unused so no need to assign
Suggested change
|
||||||||||
| plt.close("all") | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, we have a pytest fixture that does this part |
||||||||||
|
|
||||||||||
|
|
||||||||||
| @testing.requires_testing_data | ||||||||||
| def test_plot_bem(): | ||||||||||
| """Test plotting of BEM contours.""" | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.