%% Magnitude-Squared Coherence
% Linear correlation between power espectrum in a frequency f .
% It is sensitive to both phase and amplitude.
% We take the average over the segments of the FFT.
% We take two signals of subject one and visualize its coherence.
% When computing coherence in alpha band, we will average
% the coherence points in the limits of such band (Here, they are red dots)
% and that mean value is called as the coherence for two signals in alpha band.
[coh, f] = mscohere(sig1(:,1), sig1(:,2), hanning(200), 25, 200, EEG.srate);
figure
plot(f,coh, '-')
hold
plot(f(f>=EEG.freqwin(3) & f<=EEG.freqwin(4)), coh(f>=EEG.freqwin(3) & f<=EEG.freqwin(4)), 'ro')
plot([EEG.freqwin(3) EEG.freqwin(3)], [min(coh) 1], '--k')
plot([EEG.freqwin(4) EEG.freqwin(4)], [min(coh) 1], '--k')
legend('Coherence', '\alpha Coherence')
xlabel('Frequency (Hz)')
ylabel('Coherence')
text(10,0.98, '\alpha', 'FontSize', 20)
set(gcf, 'units','normalized','outerposition',[0 0 1 1]) %EXPANDING FIGURE ON SCREEN
I've got this error:
Unable to resolve the name EEG.srate.
Error in subject_08_ch1_EC1Ac (line 345)
[coh, f] = mscohere(sig1(:,1), sig1(:,2), hanning(200), 25, 200, EEG.srate);
What should I do?
Thanks in advance for any help.

5 件のコメント

Walter Roberson
Walter Roberson 2022 年 10 月 2 日
This looks to me as if you extracted some code from the middle of other code that creates EEG with appropriate properties, and that you are expecting to be able to run the code without creating appropriate EEG first
Neda Deljavan
Neda Deljavan 2022 年 10 月 3 日
Yes. You are right.
So what should I do to plot this?
Walter Roberson
Walter Roberson 2022 年 10 月 3 日
Create a structure named EEG that has appropriate fields srate and freqwin
Neda Deljavan
Neda Deljavan 2022 年 10 月 10 日
how could I do it?
Walter Roberson
Walter Roberson 2022 年 10 月 10 日
EEG.srate = -123456.789;
EEG.freqwin = flintmax() ;
except that you would put in meaningful values for your purposes.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEEG/MEG/ECoG についてさらに検索

タグ

質問済み:

2022 年 10 月 2 日

コメント済み:

2022 年 10 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by