Skip to content

Add hover to add_annotation#13931

Merged
drammock merged 4 commits into
mne-tools:mainfrom
larsoner:annot
Jun 1, 2026
Merged

Add hover to add_annotation#13931
drammock merged 4 commits into
mne-tools:mainfrom
larsoner:annot

Conversation

@larsoner
Copy link
Copy Markdown
Member

Implemented something I've wanted for a while, hover support for printing label names:

import mne
brain = mne.viz.Brain('fsaverage', surf="inflated")
brain.add_annotation('HCPMMP1_combined', hover=True)
Screencast.From.2026-05-28.14-22-14.mp4

Along the way:

  • Removed our custom _read_annot code, we should use nibabel for this
  • Removed support for passing (labels, ctab) as annot in add_annotation. I strongly suspect it wasn't really used in practice, and wasn't tested, so I think it's safe enough.

@larsoner larsoner changed the title ENH: Add hover to add_annotation Add hover to add_annotation May 28, 2026
Comment thread mne/viz/_brain/_brain.py
Comment on lines +2939 to +2940
hover : bool
If True, show annotation labels on hover.
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.

do we (someday) want to provide other info on hover, besides the label name? e.g, value of the plotted STC at the hovered vertex, or MNI coords, or...

If so, we should consider whether setting up this param as a boolean is the most forward-looking choice.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm... probably not for add_annotation (here). Something like Brain itself, or add_data might want per-vertex hover support, which we would add with a different kwarg elsewhere I think

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.

ah right of course.

@drammock drammock merged commit bc4a887 into mne-tools:main Jun 1, 2026
31 checks passed
@drammock drammock deleted the annot branch June 1, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants