custom function to epochspectrum

Dear all,

I have an EpochsSpectrum object created from epochs.compute_psd(). I would like to apply a custom baseline period, so I have created the following

def dB_baseline_correction(target_psd, baseline_psd):

    if len(target_psd.shape) == 3:
        mean_rest_power = baseline_psd.average().get_data()[np.newaxis, :, :]

    elif len(target_psd.shape) == 2:
        mean_rest_power = baseline_psd.average().get_data()

    return 10 * np.log10(target_psd.get_data() / mean_rest_power)

However, when I apply this, I lose the EpohcSpectrum structure and all the functionality. Is there a way to apply directly to the epochspectrum, so I can retain the easy event averaging after?

There isn’t a direct way to manipulate the data in an EpochsSpectrum object.
The recommended approach would be to package your manipulated data into an EpochsSpectrumArray object (which has the same functionality) and continue your analysis from there.