[Eeglablist] FFT spectrogram

Cedric Cannard ccannard at protonmail.com
Wed May 19 17:33:19 PDT 2021


Hi Alan,

A simple example to do this on continuous data for one subject, frequencies 1-100 Hz:

%Compute power spectral density (PSD) for each channel:
for iChan = 1:size(EEG.data,1)
    [psd(:,iChan), freqs] = pwelch(EEG.data(iChan,:), EEG.srate, EEG.srate/2, [], EEG.srate, 'psd');
end

%Convert to dB and get correct freqs
corr_freqs = freqs>=1 & freqs<=100;
psd = 10*log10(psd(corr_freqs,:))';


%Average over channels of interest (here F3 and F7 as an example):
f3 = find(contains({EEG.chanlocs.labels}, 'F3'));
f7 = find(contains({EEG.chanlocs.labels}, 'F7'));
psd_mean = squeeze(mean([psd(f3,:); psd(f7,:)],1));

(there are many ways and parameters you need to decide on and edit in the inputs of the function, check out EEGLAB's spectopo function)

Hope this helps,

Cedric



‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, May 19, 2021 8:45 AM, Alan Velander via eeglablist <eeglablist at sccn.ucsd.edu> wrote:

> Thank you for your replies. I think my bigger question is about how to
> average signals. If I want to look at the average signal for the left
> hemisphere (combining Fp1, F3, F7, C3, P3, T7, O1) and then plot a
> spectrogram of that signal over the entire EEG recording, how should I do
> this? Alan
>
> On Tue, May 18, 2021 at 12:18 PM Alan Velander alanvelander at gmail.com
> wrote:
>
> > Dear list members,
> > I am a new user of EEGLAB and MATLAB, and this is my first post. I am a
> > clinical neurologist who is researching quantitative EEG measures in
> > critical care patients. I have used packages like Persyst in the past, but
> > I am trying to learn more about how Persyst calculates different measures.
> > Currently, I am trying to reproduce an FFT Spectrogram of an averaged
> > signal from the Left Hemisphere and an averaged signal from the Right
> > Hemisphere.
> > I preprocessed the 256 Hz EEG file as recommended in the tutorial. The EEG
> > is now an array with 21 channels (19 EEG, 8 right, 8 left, 3 center, and 2
> > ECG).
> > I then created an average signal of each hemisphere and a spectrogram of
> > each average signal.
> > EEG.data(22,:)=(EEG.data(1,:)+EEG.data(3,:)+EEG.data(6,:)+EEG.data(8,:)+EEG.data(11,:)+EEG.data(13,:)+EEG.data(16,:)+EEG.data(18,:))/8;
> > EEG.chanlocs(22).labels=‘Av_L’ %All left sided channels.
> > EEG.data(23,:)=(EEG.data(2,:)+EEG.data(4,:)+EEG.data(7,:)+EEG.data(9,:)+EEG.data(12,:)+EEG.data(14,:)+EEG.data(17,:)+EEG.data(19,:))/8;EEG.chanlocs(23).labels=‘Av_R’
> > %All right sided channels
> > I used the spectrogram function to plot the power spectral densities of
> > Av_L and Av_R. I wanted a window of 30 s, used the default noverlap,
> > evaluated the entire interval of the EEG, sampled at 256 Hz, and changed
> > frequency to the y axis with limits on the c and y axes.
> > spectrogram(EEG.data(22,:),(30*256),[],313856,256,'yaxis'); caxis([0
> > 20]);ylim([0 20]); colormap jet
> > spectrogram(EEG.data(23,:),(30*256),[],313856,256,'yaxis'); caxis([0
> > 20]);ylim([0 20]); colormap jet
> > Am I on the right track? Is there some special feature or toolbox of
> > EEGLAB that would make this entire process easier? Is the average of each
> > channel from the right and left hemisphere just an average, or is there a
> > more complicated way to combine the data? Can the power scale be changed
> > from dB/Hz to uv^2/Hz or sqrt(uV)/Hz?
> > Again, I apologize if these are newbie questions, and I appreciate any
> > help you can provide.
> > Alan
> > --
> > Alan Velander, MD
> > 917 975 3832
> > alanvelander at gmail.com
>
> --
>
> Alan Velander, MD
> 917 975 3832
> alanvelander at gmail.com
>
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu





More information about the eeglablist mailing list