Spectrogram of EEG signal
조회 수: 16 (최근 30일)
이전 댓글 표시
Hello. I would like to plot spectrogram of a 700s of EEG signal with fs=256. Pls help me to have spectrogram with stft like below pic.Thanks
댓글 수: 0
답변 (1개)
Star Strider
2023년 7월 31일
One approach —
Fs = 256;
figure
spectrogram(EEGsignal, hann, [], [], [], Fs)
xlim([0 700]) % May Not Be Necessary If The EEG Is Only 700 s Long
Using the pspectrum function with tthe 'spectrogram' option is another option. Note that while the results of these functions may appear to be similar, they are not the same. The spectrogram function results are in dB/Hz, and tthe pspectrum results are in dB.
.
댓글 수: 4
Star Strider
2023년 8월 4일
The ‘M’ parameter here is the segment length of the signal segments the function uses to calculate the Fourier transform. Using 4.5 in the denominator produces a segment length of 39651 samples, and that would definitely obscure any detail. Setting it to a lower value (the denominator value of 500 produces a segment length of 356) will result in better resolution. The documentation example uses a denominator value of 4.5 because that signal length has only 1024 elements. Your signals each have 178432 elements.
I do not usually do coherence plots, and I have no recent experience with wavelets, although I was able to find the wcoherence function. The mscohere function (and similar functions) produce only 2D results, not anything similar to a spectrogram plot.
I added the pspectrum calls because I wanted to see what the power spectrum looked like iun two dimensions. That helps me understand the spectrogram results.
figure
imshow(imread('Spectrum.jpg'))
LD = load('EEG.mat')
EEGsignal1 = LD.w;
EEGsignal2 = LD.w;
Fs = 256;
L = numel(EEGsignal1);
tv = linspace(0, L-1, L)/Fs;
[p1,f1] = pspectrum(EEGsignal1,Fs);
[p2,f2] = pspectrum(EEGsignal1,Fs);
figure
subplot(2,1,1)
plot(f1,p1)
grid
subplot(2,1,2)
plot(f2,p2)
grid
M=floor(L/500)
M = 256;
g=hamming(M,'periodic');
L=floor(0.75*M);
Ndft=128;
figure
spectrogram(EEGsignal1,g,L,Ndft,Fs,'yaxis')
colormap(turbo)
spectrogram(EEGsignal2,g,L,Ndft,Fs,'yaxis')
colormap(turbo)
.
참고 항목
카테고리
Help Center 및 File Exchange에서 EEG/MEG/ECoG에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



