Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/changes/dev/13570.newfeature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add an optional ``show_channel_names`` parameter to
:meth:`mne.viz.plot_alignment` to overlay channel labels at sensor
locations in the 3D alignment view, by :newcontrib:`Aman Srivastava`.
1 change: 1 addition & 0 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
.. _Alex Rockhill: https://github.com/alexrockhill/
.. _Alexander Rudiuk: https://github.com/ARudiuk
.. _Alexandre Barachant: https://alexandre.barachant.org
.. _Aman Srivastava: https://github.com/aman-coder03
.. _Andrea Brovelli: https://brovelli.github.io/
.. _Andreas Hojlund: https://github.com/ahoejlund
.. _Andres Rodriguez: https://github.com/infinitejest/
Expand Down
1 change: 1 addition & 0 deletions examples/visualization/eeg_on_scalp.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
meg=[],
coord_frame="head",
subjects_dir=subjects_dir,
show_channel_names=True,
)

# Set viewing angle
Expand Down
23 changes: 23 additions & 0 deletions mne/viz/_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ def plot_alignment(
sensor_colors=None,
*,
sensor_scales=None,
show_channel_names=False,
verbose=None,
):
"""Plot head, sensor, and source space alignment in 3D.
Expand Down Expand Up @@ -648,6 +649,11 @@ def plot_alignment(
%(sensor_scales)s

.. versionadded:: 1.9
show_channel_names : bool
If True, overlay channel names at sensor locations.
Default is False.

.. versionadded:: 1.12
%(verbose)s

Returns
Expand Down Expand Up @@ -942,6 +948,23 @@ def plot_alignment(
sensor_scales=sensor_scales,
)

if show_channel_names and picks.size > 0:
chs = [info["chs"][pi] for pi in picks]

# channel positions are in head coordinates
pos = np.array([ch["loc"][:3] for ch in chs])

# transform to current coord frame
pos = apply_trans(to_cf_t["head"], pos)

for ch, xyz in zip(chs, pos):
renderer.text3d(
*xyz,
ch["ch_name"],
scale=0.005,
color=(1.0, 1.0, 1.0),
)

if src is not None:
atlas_ids, colors = read_freesurfer_lut()
for ss in src:
Expand Down