-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ENH: Add channel names to plot_alignment (#13502) #13507
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
mohit-malpote
wants to merge
3
commits into
mne-tools:main
Choose a base branch
from
mohit-malpote:enh/plot-alignment-channel-names-13502
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.
+59
−1
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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 ``show_names`` parameter to :func:`mne.viz.plot_alignment` to display channel names in the 3D scene. |
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 | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||
| """Functions to make 3D plots with M/EEG data.""" | ||||||||
| z"""Functions to make 3D plots with M/EEG data.""" | ||||||||
|
|
||||||||
| # Authors: The MNE-Python contributors. | ||||||||
| # License: BSD-3-Clause | ||||||||
|
|
@@ -554,6 +554,7 @@ def plot_alignment( | |||||||
| sensor_colors=None, | ||||||||
| *, | ||||||||
| sensor_scales=None, | ||||||||
| show_names=False, | ||||||||
| verbose=None, | ||||||||
| ): | ||||||||
| """Plot head, sensor, and source space alignment in 3D. | ||||||||
|
|
@@ -621,6 +622,13 @@ def plot_alignment( | |||||||
| %(seeg)s | ||||||||
| %(fnirs)s | ||||||||
| .. versionadded:: 0.20 | ||||||||
|
|
||||||||
|
Member
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.
Suggested change
|
||||||||
| show_names : bool | ||||||||
| If True (default False), plot the name of each channel near its | ||||||||
| location in the 3D scene. | ||||||||
|
|
||||||||
| .. versionadded:: 1.x (The maintainer will finalize the version number) | ||||||||
|
|
||||||||
|
Comment on lines
+630
to
+631
Member
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.
Suggested change
|
||||||||
| show_axes : bool | ||||||||
| If True (default False), coordinate frame axis indicators will be | ||||||||
| shown: | ||||||||
|
|
@@ -941,6 +949,30 @@ def plot_alignment( | |||||||
| sensor_colors=sensor_colors, | ||||||||
| sensor_scales=sensor_scales, | ||||||||
| ) | ||||||||
|
|
||||||||
| if show_names is True and info is not None: | ||||||||
| for ch_type in ['mag', 'grad', 'eeg', 'ecog', 'seeg', 'dbs']: | ||||||||
| picks = pick_types(info, **{ch_type: True, 'ref_meg': ch_type == 'meg'}) | ||||||||
|
|
||||||||
| if len(picks) > 0: | ||||||||
| ch_pos = np.array([info['chs'][k]['loc'][:3] for k in picks]) | ||||||||
| ch_names = [info['ch_names'][k] for k in picks] | ||||||||
| ch_coord_frame = info['chs'][picks[0]]['coord_frame'] | ||||||||
| trans = to_cf_t[_frame_to_str[ch_coord_frame]] | ||||||||
|
|
||||||||
| ch_pos = apply_trans(trans, ch_pos) | ||||||||
|
|
||||||||
| scale = 0.003 | ||||||||
|
|
||||||||
| for pos, name in zip(ch_pos, ch_names): | ||||||||
| renderer.text3d( | ||||||||
| x=pos[0], | ||||||||
| y=pos[1], | ||||||||
| z=pos[2], | ||||||||
| text=name, | ||||||||
| scale=scale, | ||||||||
| color='gray' | ||||||||
| ) | ||||||||
|
|
||||||||
| if src is not None: | ||||||||
| atlas_ids, colors = read_freesurfer_lut() | ||||||||
|
|
||||||||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.