- MNE version: e.g. 0.24.0
- operating system: Windows 10
Hello everyone,
I want to integrate all subjects in one graph (as the following picture) to plot psd_topomap (rest EEG), each groups contains 21 participants.But I don’t know how to do, anyone can help me?
Hello,
Most plotting functions have an axes
argument to specify on which subplot you want to plot.
Thus, you can first create the subplots, and then pass them individually to the plotting functions:
f, ax = plt.subplots(3, 7)
for k, participant in enumerate(participants):
plotting_function(participant, axes=ax[k])
Mathieu
Dear mscheltienne,
Thank you for your kind help. in fact, i want plot one graph with grand average all subjects, that is, i average all subjects first and then calculate their averaged PSD and plot, finally, i want to a topomap with averaged across subjects. could you please tell me any idea about this problem? i really need your help.
Hi @Left_handed_pola_bea , check out mne.viz.plot_topomap:
import numpy as np
import mne
fpath = mne.datasets.sample.data_path() / "MEG" / "sample" / "sample_audvis_raw.fif"
raw = mne.io.read_raw(fpath, preload=True)
raw.pick("eeg").interpolate_bads()
psd = raw.compute_psd(fmin=8, fmax=12)
psd_2 = psd.copy() # pretend we have data from a second subject
psd_avg = np.mean([psd.get_data(), psd_2.get_data()], axis=0).mean(1)
mne.viz.plot_topomap(psd_avg, raw.info)
thank you very much for your kind help! your code really dealled with this tough problem.
Hello, when I plot the topomap use mne.viz.plot_topomap, there is a problem that the figure didin’t have the colorbar, so I tried to add this, but it seems didn’t work, do you have any better method to show the colorbar with the figure?
fig, ax = plt.subplots(figsize = (5,5))
im, cn = mne.viz.plot_topomap(all_sub_average, raw.info, ch_type = ‘eeg’,size = 5, cmap = ‘RdBu_r’,vlim = (1E-14,5E-12), axes = ax)
ax.set_title(‘Delta’)
cax = fig.colorbar(im, ax = ax)
cax.set_label(r’μV2/HZ’)
Hi,
It would be more helpful to provide a figure in order to explain what doesn’t work.
Assuming you see the topomap but not the colorbar, you probably need to create a figure with 2 axes, then plot the topomap on the first and the colorbar on the second with something like:
cax = axes[1]
plt.colorbar(cax=cax)