-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
ENH: Let vertexSelect event to carry the estimated source id #14126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Gnefil
wants to merge
8
commits into
mne-tools:main
Choose a base branch
from
Gnefil:vertexselect-source-index
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+53
−6
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
44111b4
ENH: Add extra source id parameter to vertex select
Gnefil 1ee2216
ENH: Simplify argmax selection with non-zero guard
Gnefil 8b84360
Apply suggestions from code review
Gnefil 9624128
[autofix.ci] apply automated fixes
autofix-ci[bot] 6212a64
ENH: Clean extra line
Gnefil 1b10afb
DOC: Add changelog
Gnefil 1563bc1
ENH: Add None option for source_id parameter
Gnefil 15f459a
ENH: Add test for the new functionality
Gnefil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add ``source_id`` as an optional parameter in :class:`mne.viz.ui_events.VertexSelect`, by `Lifeng Qiu Lin`_. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1182,8 +1182,10 @@ def _configure_vertex_time_course(self): | |
| ind = np.unravel_index( | ||
| np.argmax(np.abs(use_data), axis=None), use_data.shape | ||
| ) | ||
| vertex_id = vertices[ind[0]] | ||
| publish(self, VertexSelect(hemi=hemi, vertex_id=vertex_id)) | ||
| publish( | ||
| self, | ||
| VertexSelect(hemi=hemi, vertex_id=vertices[ind[0]], source_id=ind[0]), | ||
| ) | ||
|
|
||
| def _configure_picking(self): | ||
| # get data for each hemi | ||
|
|
@@ -1457,6 +1459,7 @@ def _on_pick(self, vtk_picker, event): | |
| # 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why rename
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My intention here is to unify the variable name, is it worth it? |
||
| else: | ||
| vtk_cell = mesh.GetCell(cell_id) | ||
| cell = [ | ||
|
|
@@ -1466,7 +1469,12 @@ def _on_pick(self, vtk_picker, event): | |
| vert_pos = mesh.points[cell] | ||
| vertex_id = cell[np.argmin(np.linalg.norm(vert_pos - pos, axis=1))] | ||
|
|
||
| publish(self, VertexSelect(hemi=hemi, vertex_id=vertex_id)) | ||
| # retrieve the nearest source_id from the smooth_mat | ||
| smooth_mat = self.act_data_smooth[hemi][1] | ||
| 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)) | ||
|
|
||
|
|
||
| def _on_time_change(self, event): | ||
| """Respond to a time change UI event.""" | ||
|
|
@@ -4050,9 +4058,11 @@ def _update_current_time_idx(self, time_idx): | |
| mesh = self.layered_meshes[hemi] | ||
| mesh.smooth_mat = hemi_data.get("smooth_mat") | ||
| key_rng = [ | ||
| -key_data["fmax"] | ||
| if key_data["center"] is not None | ||
| else key_data["fmin"], | ||
| ( | ||
| -key_data["fmax"] | ||
| if key_data["center"] is not None | ||
| else key_data["fmin"] | ||
| ), | ||
| key_data["fmax"], | ||
| ] | ||
| if data_key in mesh._overlays: | ||
|
|
||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.