I'm looking for a way to obtain the gamma band's average frequency of a channel in an EEG signal from an edf file and I am unable to figure out how to do so. I checked various sources online and I found out in order to do that I need to obtain the PSD(Power Spectral Density) from the signal using the Welch's method but I was unable to find a way to do that using the mne library. All I have been able to accomplish so far has been attached below. I'd be thankful for any kind of help.
import mne
file = "H S1 EC.edf"
data = mne.io.read_raw_edf(file)
raw_data = data.get_data()
info = data.info
channels = data.ch_names
To get the power spectrum of your signal you can:
This gives you the spectral power for all frequencies, so to get average gamma power you would have to average a slice of the
psdsarray that corresponds to your frequency band of interest (the frequencies corresponding to power values inpsdscan be found infreqsarray).However, you seem to be interested not in the average gamma power, but gamma frequency, and this is much trickier. Gamma power is generally weak in EEG and the signal in this frequency range can be dominated by muscle artifacts (and possible microsaccade artifacts) - beacause of this I doubt you would be able identify a reliable gamma peak (one that is not an artifact). I would suggest you to take a look at the "Dissociating neuronal gamma-band activity from cranial and ocular muscle activity in EEG" 2013 paper by Joerg Hipp and Markus Siegel, they give some good advice on preprocessing and analysing the data to get good estimates of neuronal gamma power.