Creating channel groups manually


  • MNE-Python version: 0.22.0
  • operating system: windows 10

I have a set of hand picked channels for which I would like to plot their sensor positions with different colors.
I want to use the mne.viz.plot_sensors with its ch_groups, set to my hand picked groups as follows:

hist_bins = [["AF3","AF7","Fp1"],
montage = mne.channels.make_standard_montage("standard_1020")
info = mne.create_info(montage.ch_names,256,"eeg")
raw =,1)),info)

a = []
for group in hist_bins:    

groups = np.array(a)

The problem is unlike the docs say the groups variable contains the following elements:

How may I get this task done?

The function is behaving correctly. The docstring says:

Returns the indices of ``ch_names`` in ``include`` but not in ``exclude``.

Therefore you get indices 0 ... N for N channel names.

I believe you’ll want to do something like this instead:

groups = []
for ch_names in hist_bins:
    indices = [raw.ch_names.index(ch_name) for ch_name in ch_names]

mne.viz.plot_sensors(, ch_groups=groups, show_names=True)

Thanks, That was exactly what I wanted to get as a result.