power analysis across subjects

Hello everyone! I’m new to MNE and I meet some difficulties in power analysis across subjects.

My aim is to get the average PSD of a time period across all subjects. For each subject, I applied tfr_morlet to the Epochs object and set " average=True " so it returned the AverageTFR object
containing the average of all TFRs across epochs. To get the average across all subjects, I know I can use the attribute to_data_frame to get the underlying data and manipulate the matrix across all subjects to get the average. But I wonder if there is a better way to do that.

Thanks very much! :smiling_face_with_three_hearts:

Here is the code snippet:

from mne.time_frequency import tfr_morlet
freqs = np.logspace(*np.log10([2, 35]), num=15)
n_cycles = np.linspace(2,6,num=15)
power_induced = tfr_morlet(
epochs_rhy_maintain,
freqs=freqs,
n_cycles=n_cycles,
use_fft=True,
return_itc=False,
average=True #AverageTFR` containing the average of all TFRs across epochs.

)

1 Like

It seems that I can make all averageTFRs into a list and use np.mean to get the average. Is that right?

Hello hokottt,

you can use https://mne.tools/dev/generated/mne.grand_average.html

this functions takes care of bad channels etc., if you don’t care about this function I guess taking the mean over participants should give you the same result.

Best,

Carina

Thank you!