- MNE version: e.g.1.3.0
- operating system:Windows 10
Hello, I would like to compute Power Spectral Density of variable sized epochs (from stimulus onset to response onset for e.g.), for this, I am using the following code:
epochs = read_epochs(thisCleanFile, preload=True)
for i_ep in range(len(epochs)):
tmax = np.asarray(epochs[i_ep].metadata['response_time'])[0]
epochs_cut = epochs[i_ep].copy().crop(tmin=0, tmax = tmax)
epochs_cut._data = 1e6*epochs_cut.get_data()
psd_this_epoch= epochs_cut.compute_psd(method = 'welch', fmin = 2,
fmax = 30, tmin = 0, tmax=tmax, n_per_seg = 125)
power_dB = 10*np.log10(psd_this_epoch.get_data()) #Convert in dB.
power_thisSub[i_ep] = power_dB
power_stacked = np.stack(np.squeeze(power_thisSub))
evoked_power = np.nanmean(power_stacked, axis=0)
Now ideally, I would like to store power_stacked and evoked_power in the EpochsSpectrum and Spectrum objects respectively, but direct class instantiation is not supported. In that case, what would be the clean way to store these objects? (I want to do it so that I can have interactive PSD plots with topography and so on).
Thank you in advance.