EEG Band Extraction

77 Views Asked by At

I performed band extraction on my EEG dataset and got the following results:

Power Spectral Density for Alpha band:

Power Spectral Density for Alpha band

PSD for Beta Band:

PSD for Beta Band

PSD for Delta Band:

PSD for Delta Band

The plot shows Frequency(Hz) on X-axis and Power/Frequency(dB/Hz) on Y-axis. The values on Y-axis are negative. What does that indicate? How can I plot for a particular channel P3 with respect to time(sec)?

Code:

import numpy as np

freq_bands = {
    'delta': (0.5, 4),
    'theta': (4, 8),
    'alpha': (8, 13),
    'beta': (13, 30),
    'gamma': (30, 40)  
}

band_data = {}

# Iterate through each frequency band and extract the corresponding data
for band_name, (low_freq, high_freq) in freq_bands.items():
    # Apply bandpass filter
    raw_band = raw.copy().filter(l_freq=low_freq, h_freq=high_freq, fir_design='firwin')

    # Append the band data to the dictionary
    band_data[band_name] = raw_band

    delta_data = band_data['delta']
    theta_data = band_data['theta']
    alpha_data = band_data['alpha']
    beta_data = band_data['beta']
    gamma_data = band_data['gamma']

Code to plot the extracted bands:

import matplotlib.pyplot as plt

# Plot the PSD for each frequency band
for band_name, band_raw in band_data.items():
    fig, ax = plt.subplots()
    band_raw.plot_psd(fmin=freq_bands[band_name][0], fmax=freq_bands[band_name][1], ax=ax,   show=False)
    ax.set_title(f'Power Spectral Density - {band_name.capitalize()} Band')
    ax.set_xlabel('Frequency (Hz)')
    ax.set_ylabel('Power/Frequency (dB/Hz)')
    plt.show()
0

There are 0 best solutions below