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