42 views (last 30 days)
Show older comments
Satya Gopal on 12 Nov 2019
-
-
Link
Direct link to this question
https://www.mathworks.com/matlabcentral/answers/490627-output-of-mscohere-function
Commented: Satya Gopal on 13 Nov 2019
Accepted Answer: Daniel M
Open in MATLAB Online
Hi all,
I have a doubt with regards to mscohere function output in matlab. I have 64 channel EEG data to extract coherence data for. Which means I would need a 64x64 matrix output for a particular frequency band say 8 to 13 Hz. I went through the documentation of mscohere function sveral times. One thing that I saw was that mscohere Cxy part can either be a vector, matrix or 3-D array. When I use the following code to calculate coherence between just two channels, channel 20 and channel 50, I get a 501×1 single column vector:
ch1 = 20;
ch2 = 50;
window = 2*EEG.srate; % create 2 sec epochs
noverlap = 0; % overlap
nfft = window*2; % zero-padding factor 2 for smoothing
fs = EEG.srate;
[Cxy,F] = mscohere(EEG.data(ch1,:),EEG.data(ch2,:),window,noverlap,nfft,fs);
Cxy
Cxy =
501×1 single column vector
0.0003
0.0060
0.0042
0.0003
0.0047 % I copied the first few values only to show the output I am getting
Can someone explain this output to me? Are these coherence values between two channels at 501 different frequency points (I'm just guessing. Not sure!)? Also, how do I input the frequency band of my interest like 8-13 Hz and calculate coherence just for that? Are there more steps in calculating coherence in matlab? How do I get a single value (between 0 to 1) for channel 20 x channel 50 coherence for 8-13 Hz frequency band?
I hope my question makes sense. Please let me know if I need to explain anything further.
Thanks!
Satya
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
Sign in to answer this question.
Accepted Answer
Daniel M on 12 Nov 2019
Open in MATLAB Online
Yes, these are the coherence values between the two channels at the frequencies returned in F. You can manually set the frequencies that you wish, for example F = [8:0.5:13]. The help section indicates this.
% [Cxy,F] = MSCOHERE(X,Y,WINDOW,NOVERLAP,F,Fs) computes the coherence
% estimate at the physical frequencies contained in the vector F. F must
% be expressed in hertz and have at least two elements.
Then you can average the output to get the total coherence over that band.
4 Comments Show 2 older commentsHide 2 older comments
Show 2 older commentsHide 2 older comments
Daniel M on 12 Nov 2019
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/490627-output-of-mscohere-function#comment_766483
Here are two other well used functions that compute the coherence between EEG signals.
In the Fieldtrip toolbox: ft_connectivityanalysis and follow the case where cfg.method = 'coh'.
Here is the code
And here is a tutorial
In the spm12 toolbox: spm_eeg_ft_multitaper_coherence, found at https://github.com/neurodebian/spm12/blob/master/toolbox/MEEGtools/spm_eeg_ft_multitaper_coherence.m
Satya Gopal on 13 Nov 2019
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/490627-output-of-mscohere-function#comment_766653
Thank you for your answer, Daniel! I tried setting the frequencies manually with F and I am getting fewer values. I just have a small doubt. Why don't we use F=[8:13] but put F=[8:0.5:13]? Is it because we get a better frequency resolution or smoothening?
Yes, I will check the Fieldtrip option as well!
Daniel M on 13 Nov 2019
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/490627-output-of-mscohere-function#comment_766657
Because interesting things in EEG don't happen at the just the discrete frequencies, e.g. 8:13. They happen at any frequency. That's why we sample with a smaller step. You can choose a step size that works for you.
Satya Gopal on 13 Nov 2019
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/490627-output-of-mscohere-function#comment_766662
Thanks again, Daniel! That makes sense! I really appreciate your effort in explaining things.
Sign in to comment.
More Answers (0)
Sign in to answer this question.
See Also
Categories
SciencesNeuroscienceHuman Brain MappingEEG/MEG/ECoG
Find more on EEG/MEG/ECoG in Help Center and File Exchange
Tags
- coherence
- matlab
- mscohere
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Contact your local office