Find the max PSD for EEG data

12 次查看(过去 30 天)
Tran
Tran 2022-12-11
回答: Amith 2024-8-19
Hi everyone, I'm newbie. I have file 'data.mat' here contain table 'data' ( EEG record at channel AF3 with fs= 128)
I want to find the max PSD for beta,alpha, and theta wave in this signal using pwelch.
Who can help me solve this? thank you very much

回答(1 个)

Amith
Amith 2024-8-19
Hi Tran,
To find the maximum PSD for beta, alpha, and theta waves in the signal, you can create a function similar to the one shown below:
Assumptions:
The data being analyzed is stored in a file named data.mat and contains a variable Data which holds the signal data.
  1. Parameter Definition:
  • A Hamming window of length 256 is defined.
  • The overlap between segments is set to 128.
  • The number of FFT points is set to 512.
  • The data is loaded from data.mat.
  • The sampling frequency is set to 128 Hz.
2. Power Spectral Density (PSD) Calculation:
  • The PSD of the signal is computed using the Welch method (pwelch function).
3. Frequency Bands:
  • Identifying the three frequency bands:
  • Theta band: 4 to 8 Hz
  • Alpha band: 8 to 12 Hz
  • Beta band: 12 to 30 Hz
4. Max PSD Calculation:
  • The maximum PSD value within each of these bands is found:
  • max_psd_theta for the Theta band
  • max_psd_alpha for the Alpha band
  • max_psd_beta for the Beta band
% Define parameters
window = hamming(256); % Window length
noverlap = 128; % Overlap between segments
nfft = 512; % Number of FFT points
data = load('data.mat');
fs = 128;
% Compute PSD using pwelch
[pxx, f] = pwelch(data.Data, window, noverlap, nfft, fs);
% Find max PSD in each band
theta_band = (f >= 4 & f < 8);
alpha_band = (f >= 8 & f < 12);
beta_band = (f >= 12 & f < 30);
max_psd_theta = max(pxx(theta_band));
max_psd_alpha = max(pxx(alpha_band));
max_psd_beta = max(pxx(beta_band));
% Display results
fprintf('Max PSD in Theta band: %f\n', max_psd_theta);
fprintf('Max PSD in Alpha band: %f\n', max_psd_alpha);
fprintf('Max PSD in Beta band: %f\n', max_psd_beta);
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by