ENH: Implement TimeChange behaviour for evoked_topo and merge option in link#13968
Open
Gnefil wants to merge 7 commits into
Open
ENH: Implement TimeChange behaviour for evoked_topo and merge option in link#13968Gnefil wants to merge 7 commits into
Gnefil wants to merge 7 commits into
Conversation
…update time in subfigures synchronously
3 tasks
There was a problem hiding this comment.
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
TimeChangepublishing/subscribing to the magnified (single-channel) topo time series and track current time on the mainplot_evoked_topofigure. - Extend
mne.viz.ui_events.link()withmerge=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 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) |
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) | ||
|
|
Contributor
There was a problem hiding this comment.
Yeah, we can probably use a with disable_ui_events() to get around this.
| face_brightness = np.dot(facecol, [299, 587, 114]) | ||
| ax._cursorcolor = "white" if face_brightness < 150 else "black" | ||
|
|
||
| # setattr(orig_fig, "_current_time", None) |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference issue (if any)
Implements #13928.
What does this implement/fix?
It enables
plot_evoked_topofigures to interact with other figures sharingTimeChangeevent.The strategy is to implement
on_time_changefunction, link subfigures with the main figure, and mark the current time (set as a figure attribute) with a vertical line. Clicks on the subfigures publishTimeChangeevents, main figure subscribes to external events, and publish/subscribe transmit events/callbacks through thelinkfunction.Additional information
ui_events.link()function now has amergeparameter that allows mutually linking the link-groups that figs belong to separately.