Hi!
Does anyone have any suggestion for a trick to insert multiple masks in the topographic images? I would need to mark three different sets of sensors with distinct colors/shapes
Thank you!
Hi!
Does anyone have any suggestion for a trick to insert multiple masks in the topographic images? I would need to mark three different sets of sensors with distinct colors/shapes
Thank you!
The advantage of the plotting functions is that they mostly use standard matplotlib plotting functions, so you can go through and mess with properties after plotting completes. Here is some example code that I wrote recently that you can probably adapt to your use case, where sigs
is a list of indices of significant channels:
fig, ax = plt.subplots()
ch_groups = [sigs, np.setdiff1d(np.arange(info['nchan']), sigs)]
mne.viz.plot_sensors(
info, 'topomap', 'hbo', title='', axes=ax,
show_names=True, ch_groups=ch_groups)
ax.collections[0].set(lw=0) # the collection created by MNE via matplotlib
c = ax.collections[0].get_facecolor()
c[(c[:, :3] == (0, 0, 0.5)).all(-1)] = (0., 1., 0., 0.5) # first group got this color
c[(c[:, :3] == (0.5, 0, 0)).all(-1)] = (0., 0., 0., 0.1) # second group got this color
sig_names = [info['ch_names'][idx] for idx in sigs]
texts = list(ax.texts)
for text in list(texts): # iterate over texts created by MNE, keeping significant ones
try:
idx = sig_names.index(text.get_text())
except ValueError:
texts.pop(texts.index(text))
else:
text.set_text(f'{sigs[idx] // 2 + 1}')
text.set(fontsize='xx-small', zorder=5, ha='center')
ax.texts[:] = texts