Skip to content
Merged
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
2 changes: 2 additions & 0 deletions doc/changes/latest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ Bugs

- Fix bug with :ref:`mne make_scalp_surfaces` where ``--overwrite`` was not functional (:gh:`8800` by `Yu-Han Luo`_)

- Fix bug with :func:`mne.viz.plot_topomap` when plotting gradiometers with a missing channel in a pair (:gh:`8817` by `Alex Gramfort`_)

API changes
~~~~~~~~~~~

Expand Down
13 changes: 13 additions & 0 deletions mne/viz/tests/test_topomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,19 @@ def test_plot_topomap_bads():
plt.close('all')


def test_plot_topomap_bads_grad():
"""Test plotting topomap with bad gradiometer channels (gh-8802)."""
import matplotlib.pyplot as plt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to nest these imports anymore due to pytest infrastructure, eventually we can move these to the top. But it can be another PR since this whole file suffers from our old conventions.

data = np.random.RandomState(0).randn(203)
info = read_info(evoked_fname)
info['bads'] = ['MEG 2242']
picks = pick_types(info, meg='grad')
info = pick_info(info, picks)
assert len(info['chs']) == 203
plot_topomap(data, info, res=8)
plt.close('all')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, no need to plt.close('all') at the end, it happens automatically via pytest now



def test_plot_topomap_nirs_overlap(fnirs_epochs):
"""Test plotting nirs topomap with overlapping channels (gh-7414)."""
fig = fnirs_epochs['A'].average(picks='hbo').plot_topomap()
Expand Down
2 changes: 1 addition & 1 deletion mne/viz/topomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ def _plot_topomap(data, pos, vmin=None, vmax=None, cmap=None, sensors=True,
# deal with grad pairs
picks = _pair_grad_sensors(pos, topomap_coords=False)
pos = _find_topomap_coords(pos, picks=picks[::2], sphere=sphere)
data, _ = _merge_ch_data(data, ch_type, [])
data, _ = _merge_ch_data(data[picks], ch_type, [])
data = data.reshape(-1)
else:
picks = list(range(data.shape[0]))
Expand Down