Unfortunately, still having trouble.
Based on the epochs above, Iâm trying to plot a power/frequency graph using an average of a combination of specific(group) MEG channels and a combination of epochs at the same time but I canât find a way to combine the channels, just the epochs. Here is the code I have been using to do it:
kwargs = dict(fmin=2, fmax=40, n_jobs=1)
psds_welch_mean, freqs_mean = psd_welch(epochs[55:56], average=âmeanâ, **kwargs)
psds_welch_median, freqs_median = psd_welch(epochs[55:56], average=âmedianâ, **kwargs)
psds_welch_mean = 10 * np.log10(psds_welch_mean)
psds_welch_median = 10 * np.log10(psds_welch_median)
channel_indices = mne.pick_types(info, meg=âmagâ, eeg=True)
meg_channels = mne.pick_types(info, meg=True)[:10]
channel_types = [mne.io.pick.channel_type(info, ch) for ch in meg_channels]
ch_name = âMEG0121â
ch_idx = epochs.info[âch_namesâ].index(ch_name)
epo_idx = 0
_, ax = plt.subplots()
ax.plot(freqs_mean, psds_welch_mean[epo_idx, ch_idx, :], color=âkâ,
ls=â-â, label=âmean of segmentsâ)
ax.plot(freqs_median, psds_welch_median[epo_idx, ch_idx, :], color=âkâ,
ls=âââ, label=âmedian of segmentsâ)
ax.set(title=âWelch PSD ({}, Epoch {})â.format(ch_name, epo_idx),
xlabel=âFrequency (Hz)â, ylabel=âPower Spectral Density (dB)â)
ax.legend(loc=âupper rightâ)
plt.show()
=====================================
Using the code above, I can plot an average of the epochs I defined but canât find a way to insert more channels into it. This is the code I used to try to insert more channels, but when I plot it, I just get a blank graph.
ch_name = âMEG0121â
ch_idx = epochs.info[âch_namesâ].index(ch_name)
epo_idx = 0
b = np.hstack([psds_welch_mean[epo_idx, 14, :], psds_welch_mean[epo_idx, 17, :]])
c = np.hstack([psds_welch_median[epo_idx, 14, :], psds_welch_median[epo_idx, 17, :]])
_, ax = plt.subplots()
ax.plot(freqs_mean, b, color=âkâ,
ls=â-â, label=âmean of segmentsâ)
ax.plot(freqs_median, c, color=âkâ,
ls=âââ, label=âmedian of segmentsâ)
ax.set(title=âWelch PSD ({}, Epoch {})â.format(ch_name, epo_idx),
xlabel=âFrequency (Hz)â, ylabel=âPower Spectral Density (dB)â)
ax.legend(loc=âupper rightâ)
plt.show()
14 and 17 are MEG channel indices.
I would like to plot a graph like this one for exemple:

Does anyone knows how I can combine those channels + epochs and get a mean?
@alexrockhill