My goal is to calculate the relative power and absolute power of EEG signals.
At the beginning, I used the 'mne.time_frequency import psd_array_welch' function to calculate the PSD of EEG. Then I used the 'simps' method to calculate the total power and the power of each frequency band, Relative power is defined as the power integral of a certain frequency band / total power.
1.The first question is: this calculation will cause the delta band to occupy most of the energy, but if using logarithmic values(10 log(psd)), negative values will appear, and I don’t know how to deal with these negative values in the process of calculation integration. So I directly performed integral calculation on the original PSD.
2.The second question is: When I want to use the IRASA method to obtain the periodic and aperiodic spectral components, in order to remove the pink noise, the periodic spectral components ( psd_osc ) that we are more concerned about also appear negative values. I also don’t know how to deal with these negative values. So, how can I calculate the power integral of the frequency band based on the IRASA method after removing the pink noise?
I would be very grateful for any related advice from you.
# welch method
psds, psds_freqs = psd_array_welch(data, sfreq=fs, fmin=fmin, fmax=fmax,n_fft=n_fft, n_per_seg=n_per_seg, verbose=0)
pn = len(self.interest_channel)
integ_powers = np.zeros((pn,5))
ratio_powers = np.zeros((pn,5))
delta=[0.2,4]
theta=[4,8]
alpha=[8,13]
beta=[13,30]
gamma=[30,40]
total_powers = simps(psds, psds_freqs, axis=1)
for band, (low, high) in enumerate([delta,theta,beta,alpha,gamma]):
mask = (psds_freqs >= low) & (psds_freqs