ENH: Let vertexSelect event to carry the estimated source id - #14126
Open
Gnefil wants to merge 7 commits into
Open
ENH: Let vertexSelect event to carry the estimated source id#14126Gnefil wants to merge 7 commits into
Gnefil wants to merge 7 commits into
Conversation
7 tasks
Member
|
@wmvanvliet probably most relevant to you, being an event-related thing? |
wmvanvliet
reviewed
Aug 4, 2026
| # shift = np.array(grid.GetOrigin()) + spacing / 2. | ||
| # ijk = np.round((pos - shift) / spacing).astype(int) | ||
| # vertex_id = np.ravel_multi_index(ijk, shape, order='F') | ||
| source_id = idx |
Contributor
There was a problem hiding this comment.
why rename idx -> source_id here and not starting from line 1446?
Contributor
Author
There was a problem hiding this comment.
My intention here is to unify the variable name, is it worth it?
Co-authored-by: Marijn van Vliet <w.m.vanvliet@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR enhances MNE-Python’s 3D Brain visualization UI event system by extending the VertexSelect event to include a source_id, enabling downstream callbacks to interact with other source-estimate-aware plots without re-computing vertex→source mappings.
Changes:
- Extend
mne.viz.ui_events.VertexSelectwith a newsource_idfield. - Populate
source_idwhen publishingvertex_selectevents fromBrain(initial selection and picking). - Add a Towncrier changelog fragment documenting the new feature.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
mne/viz/ui_events.py |
Adds the source_id field to VertexSelect and documents it. |
mne/viz/_brain/_brain.py |
Includes source_id in published VertexSelect events and maps mesh vertex selections to source indices. |
doc/changes/dev/14126.newfeature.rst |
Changelog entry announcing the new source_id parameter. |
Suppressed comments (2)
mne/viz/ui_events.py:189
source_idis optional (defaulting toNone), but the type annotation is currentlyint = None, which is inconsistent and can break static type checking. Annotate it asint | Noneto match how other optional UI event fields are typed in this module.
hemi: str
vertex_id: int
source_id: int = None
mne/viz/ui_events.py:184
- The
Attributessection should match the actual type/semantics ofsource_id(it can beNoneand is an index into the source estimate for the given hemisphere).
vertex_id : int
The vertex number (in the high resolution mesh) that was selected.
source_id : int
The index number of the closest source point to the vertex.
Only set if the publishing figure contains a source estimate.
| row = smooth_mat[vertex_id] | ||
| source_id = smooth_mat[vertex_id].argmax() if row.nnz else None | ||
|
|
||
| publish(self, VertexSelect(hemi=hemi, vertex_id=vertex_id, source_id=source_id)) |
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)
Solves #14094.
What does this implement/fix?
Adds source id to the vertexSelect event. Carrying the source point when publishing the vertex select event makes interaction possible with other plots not aware of the source space.
Additional information