plotting issue: "drawn head shapes" from mne.viz.plot_topomap not in alignment with color maps

Hello everyone,

I’m having difficulties trying to create a spectral density plot with a topomap. I’m using the configuration sphere=(0.00, 0.02, 0.03, 0.11) to position the channels in their appropriate locations. However, the colors of the spectral density are not displaying correctly in the topomap region, shifting out of place.

I would like to know if anyone has encountered a similar issue or if you could provide suggestions on how to correct this misalignment between the channels and colors in the plot.

Thanks in advance for your help!

freq_bands = {'Delta': (1, 4),
              'Theta': (4, 8),
              'Alpha': (8, 13),
              'Beta': (13, 30),
              'Gamma': (30, 50),
              'Super Gamma': (70, 90)}
extrapolations = ["local"]
fig, axes = plt.subplots(2, 3, figsize=(15, 10))
axes = axes.flatten()
all_band_data = [x]

for i, (banda, (baixa, alta)) in enumerate(freq_bands.items()):
    raw_banda = raw.copy().filter(l_freq=baixa, h_freq=alta, method='iir', verbose=False)
    dados_banda = raw_banda.get_data()[:, 0]

    all_band_data.append(dados_banda)

    im, _ = mne.viz.plot_topomap(dados_banda, raw_banda.info, axes=axes[i], sphere=(0.00, 0.02, 0.03, 0.11),cmap="Spectral_r", names=channels, contours=5, show=False)
    axes[i].set_title(f'Banda {banda}')
vmin = float('inf')
vmax = float('-inf')
for freq in range(len(dados_banda)):
    vmin = min(vmin, np.min(dados_banda[freq]))
    vmax = max(vmax, np.max(dados_banda[freq]))

norma = plt.Normalize(vmin=vmin, vmax=vmax)
cbar_ax = fig.add_axes([0.92, 0.15, 0.02, 0.7])
cbar = plt.colorbar(im, cax=cbar_ax,
                    norm=norma)
cbar.ax.set_title("uV²", fontsize=12)


plt.suptitle('frequences, fontsize=16)
plt.tight_layout(rect=[0, 0, 0.9, 0.95])
plt.show()

@leticiaainoan I don’t have an answer for your problem, but a piece of advice how you may be able to get more replies in the future:

I changed the title of your question to: plotting issue: “drawn head shapes” from mne.viz.plot_topomap not in alignment with color maps

before, it was simply: mne.viz.plot_topomap

given that this forum is run by volunteers with limited time, you have to try and make your questions as clear and concise as possible: Make it easy for someone to reply to you :slightly_smiling_face:

Having that said, sorry I cannot be of further help, and good luck!

1 Like