File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Add an optional ``show_channel_names `` parameter to
2+ :meth: `mne.viz.plot_alignment ` to overlay channel labels at sensor
3+ locations in the 3D alignment view, by :newcontrib: `Aman Srivastava `.
Original file line number Diff line number Diff line change 1414.. _Alex Rockhill : https ://github . com /alexrockhill /
1515.. _Alexander Rudiuk : https ://github . com /ARudiuk
1616.. _Alexandre Barachant : https ://alexandre . barachant . org
17+ .. _Aman Srivastava : https ://github . com /aman -coder03
1718.. _Andrea Brovelli : https ://brovelli . github . io /
1819.. _Andreas Hojlund : https ://github . com /ahoejlund
1920.. _Andres Rodriguez : https ://github . com /infinitejest /
Original file line number Diff line number Diff line change 3535 meg = [],
3636 coord_frame = "head" ,
3737 subjects_dir = subjects_dir ,
38+ show_channel_names = True ,
3839)
3940
4041# Set viewing angle
Original file line number Diff line number Diff line change @@ -554,6 +554,7 @@ def plot_alignment(
554554 sensor_colors = None ,
555555 * ,
556556 sensor_scales = None ,
557+ show_channel_names = False ,
557558 verbose = None ,
558559):
559560 """Plot head, sensor, and source space alignment in 3D.
@@ -648,6 +649,11 @@ def plot_alignment(
648649 %(sensor_scales)s
649650
650651 .. versionadded:: 1.9
652+ show_channel_names : bool
653+ If True, overlay channel names at sensor locations.
654+ Default is False.
655+
656+ .. versionadded:: 1.12
651657 %(verbose)s
652658
653659 Returns
@@ -942,6 +948,23 @@ def plot_alignment(
942948 sensor_scales = sensor_scales ,
943949 )
944950
951+ if show_channel_names and picks .size > 0 :
952+ chs = [info ["chs" ][pi ] for pi in picks ]
953+
954+ # channel positions are in head coordinates
955+ pos = np .array ([ch ["loc" ][:3 ] for ch in chs ])
956+
957+ # transform to current coord frame
958+ pos = apply_trans (to_cf_t ["head" ], pos )
959+
960+ for ch , xyz in zip (chs , pos ):
961+ renderer .text3d (
962+ * xyz ,
963+ ch ["ch_name" ],
964+ scale = 0.005 ,
965+ color = (1.0 , 1.0 , 1.0 ),
966+ )
967+
945968 if src is not None :
946969 atlas_ids , colors = read_freesurfer_lut ()
947970 for ss in src :
You can’t perform that action at this time.
0 commit comments