How to edit y-axis scale in pop_spectopo function to log power spectral density 10*log10(uV^2/Hz)
10 views (last 30 days)
Show older comments
I am trying to plot the average power spectrum for a group of participants. MatLab automatically uses a numeric scale for the yaxis, this can be changed to 'log' in the figure editor page but I want the y-axis to use the following scale: log power spectral density 10*log10(uV^2/Hz).
I am plotting an average power spectrum for one channel for a group of subjects.
This is my current code:
dataDir_1 = '/Users/juliannemcleod/Documents/Data1';
ch = 20; % ch is the number of channel you need
i = 1; %% i is the subject number
ch = 20;
setFiles_1 = dir(fullfile(dataDir_1, '*.set'));
for i = 1:length(setFiles_1)
EEG1 = pop_loadset('filename', setFiles_1(i).name, 'filepath', setFiles_1(i).folder);
spectrum_1(i,:) = pop_spectopo(EEG1, 1, [], 'EEG' , 'percent', 100, 'freq', [0 100], 'freqrange', [0 100], 'electrodes', 'off', 'plot', 'off', 'plotchans', ch);
end
figure;
plot(mean(spectrum_1,1));
xlim([0 100]); % Assuming you want frequencies from 0-100 Hz
xlabel('Frequency (Hz)');
0 Comments
Accepted Answer
Star Strider
on 27 Sep 2023
This ‘10*log10(uV^2/Hz)’ is the same a dB/Hz. Thi is the same as the units of the ‘pxx’ outputs of the pwelch and periodogram functions. If your ‘pop_spectopo’ function uses one of those functions, no further conversion is necessary. Just set:
ylabel('PSD (dB\muV/Hz)')
or something similar.
.
2 Comments
Star Strider
on 27 Sep 2023
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
More Answers (0)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!