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.
- 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!