What are the best parameters in this case?

조회 수: 2 (최근 30일)
N Saf
N Saf 2023년 6월 11일
댓글: Diwakar Diwakar 2023년 6월 11일
I am trying to extract PSD using welch method from 1 channel EEG data of 4s length that is sampled at 256Hz , my code is below. What are the best parameters to be used for the window length and overlap???
% Load EEG data (replace with your actual data)
load('eeg_data.mat'); % Assuming eeg_data.mat contains a variable named 'eeg_data'
% Parameters
window_length = 2; % Window length in seconds
window_overlap = 0.5; % Window overlap ratio (0 to 1)
sampling_rate = 256; % Sampling rate in Hz
% Compute window parameters
window_size = round(window_length * sampling_rate);
overlap_size = round(window_overlap * window_size);
step_size = window_size - overlap_size;
% Initialize variables for PSD
num_windows = floor((numel(eeg_data) - window_size) / step_size) + 1;
psd = zeros(num_windows, window_size/2 + 1);
freq = (0:window_size/2) * sampling_rate / window_size;
% Compute PSD using a moving window
for i = 1:num_windows
% Extract current window
window_start = (i-1) * step_size + 1;
window_end = window_start + window_size - 1;
window_data = eeg_data(window_start:window_end);
% Compute PSD using Welch's method
[psd(i,:), ~] = pwelch(window_data, [], [], [], sampling_rate);
end
% Plot the PSD
figure;
imagesc(1:num_windows, freq, 10*log10(psd'));
set(gca, 'YDir', 'normal');
xlabel('Window Index');
ylabel('Frequency (Hz)');
title('Power Spectral Density');
colorbar;
  댓글 수: 2
John D'Errico
John D'Errico 2023년 6월 11일
The "best" parameters? That is impossible to know for parameters like that. It would depend on the magnitude of any noise in the data, and how it compares to the signal. It probably depends on some other thigns that are not easily defined. Anyway if there were some easy way to know the "best" parameters, then that would have been built into the code already.
So what can you do? Try some different parameters. See what makes you happy on your data. Your eye is the best possible measure of goodness.
Diwakar Diwakar
Diwakar Diwakar 2023년 6월 11일
Iterate and experiment with different parameter values to find the settings that best suit your specific EEG data and analysis goals.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by