Skip to content

ENH: Implement TimeChange behaviour for evoked_topo and merge option in link#13968

Open
Gnefil wants to merge 7 commits into
mne-tools:mainfrom
Gnefil:evoked-topo-timechange
Open

ENH: Implement TimeChange behaviour for evoked_topo and merge option in link#13968
Gnefil wants to merge 7 commits into
mne-tools:mainfrom
Gnefil:evoked-topo-timechange

Conversation

@Gnefil

@Gnefil Gnefil commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Reference issue (if any)

Implements #13928.

What does this implement/fix?

It enables plot_evoked_topo figures to interact with other figures sharing TimeChange event.

The strategy is to implement on_time_change function, link subfigures with the main figure, and mark the current time (set as a figure attribute) with a vertical line. Clicks on the subfigures publish TimeChange events, main figure subscribes to external events, and publish/subscribe transmit events/callbacks through the link function.

Additional information

ui_events.link() function now has a merge parameter that allows mutually linking the link-groups that figs belong to separately.

@Gnefil Gnefil marked this pull request as ready for review June 21, 2026 14:52
Copilot AI review requested due to automatic review settings June 21, 2026 14:52
@Gnefil Gnefil requested a review from wmvanvliet as a code owner June 21, 2026 14:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds TimeChange-based UI event interoperability to mne.viz.plot_evoked_topo (enabling time synchronization with other interactive figures) and extends mne.viz.ui_events.link() with a merge option to merge existing link-groups.

Changes:

  • Add TimeChange publishing/subscribing to the magnified (single-channel) topo time series and track current time on the main plot_evoked_topo figure.
  • Extend mne.viz.ui_events.link() with merge= to unify existing link-groups.
  • Add/adjust tests, a tutorial snippet, and a changelog entry covering the new behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tutorials/evoked/20_visualize_evoked.py Adds an example linking an interactive topomap and plot_evoked_topo for synchronized time selection.
mne/viz/ui_events.py Adds merge parameter to link() to merge figures’ existing link-groups.
mne/viz/topo.py Implements TimeChange interactions for the magnified topo time series and subscribes the main topo figure to time-change events.
mne/viz/tests/test_ui_events.py Adds a test covering merge=True link-group behavior.
mne/viz/tests/test_topo.py Adds tests for time-change propagation/select-line behavior in plot_evoked_topo.
doc/changes/dev/13968.newfeature.rst Adds a changelog entry describing the new TimeChange behavior and merge parameter.

Comment thread mne/viz/topo.py
Comment on lines 427 to +429
# allow custom function to override parameters
show_func(ax, ch_idx)
plt_show(fig=fig)
show_func(ax, ch_idx, orig_fig=fig)
plt_show(fig=subfig)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a good point.

Comment thread mne/viz/topo.py
Comment on lines +647 to +651
def _on_click(event):
if event.inaxes == ax:
publish(ax.figure, TimeChange(time=event.xdata))
_update_selectline(event.xdata)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, we can probably use a with disable_ui_events() to get around this.

Comment thread mne/viz/topo.py
face_brightness = np.dot(facecol, [299, 587, 114])
ax._cursorcolor = "white" if face_brightness < 150 else "black"

# setattr(orig_fig, "_current_time", None)
Comment thread mne/viz/ui_events.py
Comment thread doc/changes/dev/13968.newfeature.rst
Comment on lines +265 to +267
# Topo and topomap figures have dynamic interactivity when plot for single
# :class:`~mne.Evoked` instance and allow time selection, which could be
# synchronized through link.
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.

3 participants