question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

viz.plot_sensors('3d') doesn't handle mouse clicks to reveal sensor names correctly

See original GitHub issue

MWE:

from pathlib import Path
import matplotlib
import mne

matplotlib.use('Qt5Agg')

sample_dir = Path(mne.datasets.sample.data_path())
sample_fname = sample_dir / 'MEG' / 'sample' / 'sample_audvis_raw.fif'

raw = mne.io.read_raw_fif(sample_fname, preload=False)
raw.plot_sensors('3d')

Clicking on the frontal sensors reveals names of channels someplace else.

https://user-images.githubusercontent.com/2046265/115535014-a6acc000-a298-11eb-881d-bacf661ee57d.mov

When show_names=True is passed, the channels are labeled correctly, though, leading me to believe that the odd behavior described above is related to click -> channel mapping

Screen Shot 2021-04-21 at 11 55 09

For completeness, here’s a 2D sensor plot: Screen Shot 2021-04-21 at 11 54 48

macOS with Qt5 backend.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
drammockcommented, Apr 21, 2021

I played around a bit and have concluded that the event.ind returned by the matplotlib pick event is not deterministic and not stable before/after a click-drag rotation of the axes. Try it out: click on a point that you like, keep your eye on it while you rotate the axes, then click on that point again.

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
plt.ion()


def onpick(event):
    ind = event.ind
    print(f'index: {ind}')


x = np.tile(np.linspace(0, 1, 5), 3*7)
y = np.repeat(np.linspace(0, 1, 7), 3*5)
z = np.tile(np.linspace(0, 1, 3), 5*7)
c = np.linspace(0, 1, 3*5*7)
s = np.full(3*5*7, 100)

fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))
ax.scatter(x, y, z, s=s, c=c, picker=True)
fig.canvas.mpl_connect('pick_event', onpick)
0reactions
larsonercommented, Apr 23, 2021

I’m going to push to 0.24 since it seems like it might take a while to figure out the right solution here

Read more comments on GitHub >

github_iconTop Results From Across the Web

mne.viz.plot_sensors — MNE 1.2.2 documentation
Whether to plot the sensors as 3d, topomap or as an interactive sensor ... If an array, only the channel names in the...
Read more >
mne-python/utils.py at main - GitHub
For this will return a colormap that will display correctly for data ... Whether to plot the sensors as 3d, topomap or as...
Read more >
rviz/UserGuide - ROS Wiki
When rviz starts for the first time, you will see an empty ... Control-click to pick the object under the mouse and look...
Read more >
Augmented reality - Wikipedia
Augmented reality (AR) is an interactive experience that combines the real world and computer-generated content. The content can span multiple sensory ...
Read more >
Spatial Data Visualization with QGIS (Full Course Material)
Once you let go of you your mouse button, the map from the main canvas will be loaded in the region. If you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found