The predominance of gamma waves in EEG analysis.

Hi!

  • MNE version: 1.7.0
  • operating system: Windows 10

I am trying to analyze the data from the EEG, namely, to determine which brainwave prevails in each epoch. I use FFT for this.

raw = mne.io.read_raw_edf('0000_1_002603844.edf', preload=True)
#Network filtering
raw.notch_filter(freqs=50, notch_widths=1)
# Low-frequency data filtering
raw.filter(l_freq=0.5, h_freq=None)

raw.set_eeg_reference(ref_channels='average', projection=True)

events = mne.make_fixed_length_events(raw, duration=1.0)

epochs = mne.Epochs(raw, events, tmin=0, tmax=1, baseline=None, preload=True)

Here I add all the received maximum wave powers to the list, which I then output:

for i in range(len(epochs)):
    epoch_data = epochs[i].get_data(copy=True)[0]  

    # FFT
    fft_values = np.fft.fft(epoch_data)
    freqs = np.fft.fftfreq(epoch_data.shape[-1], d=1 / raw.info['sfreq'])
    
    psd = np.abs(fft_values) ** 2

    
    waves = {'delta': (0.5, 4),
             'theta': (4, 8),
             'alpha': (8, 12),
             'beta': (12, 30),
             'gamma': (30, 50)}

    
    max_power_band = None
    max_power = 0
    for band, (low, high) in waves.items():
        band_ix = (freqs >= low) & (freqs < high)
        power = np.mean(psd[:, band_ix], axis=1)
        if np.any(power > max_power):
            max_power = power
            max_power_band = band

And it works, but the problem is that there are too many gamma waves! And I think there’s some kind of filtering problem, but I can’t figure out what’s the matter.

Look at this:
[‘delta’, ‘theta’, ‘beta’, ‘gamma’, ‘delta’, ‘gamma’, ‘gamma’, ‘delta’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘delta’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘gamma’, ‘delta’]

My raw.info:

<RawEDF | 0000_1_002603844.edf, 129 x 15360 (30.0 s), ~15.2 MB, data loaded>
<Info | 9 non-empty values
 bads: []
 ch_names: AF3h, AF4h, AF5h, AF6h, AF7, AF8, AFF1h, AFF2h, AFF3h, AFF4h, ...
 chs: 129 EEG
 custom_ref_applied: False
 highpass: 0.5 Hz
 lowpass: 256.0 Hz
 meas_date: 2024-04-27 11:30:24 UTC
 nchan: 129
 projs: Average EEG reference: off
 sfreq: 512.0 Hz
 subject_info: 3 items (dict)
>

Might be a silly question (and apologies if it is), but what happens when you set h_freq to e.g 30? Also have you tried plotting the PSD as a sanity check?

I feel like without filtering it makes sense for gamma waves to at least account for a considerable part of the signal. Also, probably not the issue here, but in a dataset I collected semi-recently we actually had a very wide line noise peak due to a combination of bad line noise and bad drift. Maybe there could be a bit of that in your data(?)

2 Likes

You have different methods to compute a spectrum:

  • FFT
  • Welch, which basically computes FFT on segments (rolling window) and then average the segments together. It provides a better estimate with a resolution depending on the window length, and is usually fast to compute. This is the default method for Raw objects.
  • multitaper, which estimates the spectral density for orthogonal tapers and averages them. It provides a better estimate but is more computationally expensive. This is the default method for Epochs objects.

In you case, multitaper would make more sense, thus I would use MNE’s build-in methods:

spectrum = epochs.compute_psd()
spectrum.plot()
# retrieve the spectrum array
data = spectrum.get_data()

Second, your dataset likely does not contain only brain signal. Artifacts will likely contaminate your signal heavily, thus I would first inspect the raw recording and remove bad segments with annotations starting with BAD_ in their name. I might also run an ICA to remove blinks and other large artifact. All those points to say that without properly inspecting your data first and applying a couple of cleaning methods, the results are not specific to brain signals but to any kind of signals measured by your EEG system (environment noise, neck muscles, eye movements, …)

Mathieu

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.