Coherence corticomuscular with mscohere
Show older comments
Hi
I'm trying to calculate cortico-muscular coherence (EEG, EMG) with 'mscohere' in various frequency bands, eg 8-13 Hz. I have blocks of 30 sec of a task interspaced with blocks of 30 sec of rest. I want to know how coherence changes as a function of time during the task, so across the 30 sec of the task, not rest. I plan to separate the 30 sec EMG and EEG signals into 30 1 sec bin and then use for each of 30 bins:
[cxy,fc] = mscohere(dataEMG, dataEEG, [], [], [8:0.1:13], 1000)
mean(cxy)
Is that correct to calculate coherence in the 8-13 Hz across the 30 sec?
Thanks
help mscohere
Answers (1)
Star Strider
on 27 Aug 2023
0 votes
The first output of mscohere is a vector, and is intended to show the magnitude-squared coherence of the two signals. It seems to me that calculating the mean of it destroys the information it provides. I would keep it (and others like it, since I assume this is part of a set of experiments) as vectors (along with any other necessary information), store them, and then process them. How you process them depends on the information you want from them.
6 Comments
Pat
on 28 Aug 2023
Star Strider
on 28 Aug 2023
My pleasure!
The fifth argument to mscohere is the size of the fft. A vector is not going to work for that, so in that sense, no. That has to be a scalar, preferably a power of 2 (512, 1024, 4096, etc.).
I suggest looking at several different EEG bands, to see what works best. (My neurophysiology studies were not the sort you’re doing, so I’m not certain what the best approach would be. You need to do a PubMed search on similar research, if you’ve not already done so.) Obviously, leads over the motor cortex are going to be most important if you’re studying them with respect to EMG.
I get the impression that you’ve not completely understood what mscohere does and the output it produces. The result is a vector of amplitudes of the magnitude-squared coherence estimate, with (if you request it, and I recommend that) a matching vector of frequencies. Taking the mean of the first output destroys all that information, making the mscohere call essentially pointless. That’s the reason I suggest storing the vectors in a cell array or some other convenient array to compare later.
Pat
on 29 Aug 2023
Star Strider
on 29 Aug 2023
For EEG and EMG analyses, the sampling frequency is usually at least 1 kHz, so 1 second is a fair amount of data. It would be relatively straightforward to create elliptic filters for the bands-of-interest using the bandpass function (use the 'ImpulseResponse','iir' name-value pair for best results) and getting both outputs from the first call to it. (After that, use the second output, that being the digital-filter object, with filtfilt to filter the other signals.)
Probably the most efficient way to segment the signals would be to use the buffer function to divide the signal into separate one-second intervals (the second argument to buffer would be the sampling frequency for 1 second segments) and use that as the input to filtfilt along with the digital-filter object. The filtered outputs would have the same dimensions as the inputs, so you would then present chosen columns of the filtered output matrices to mscohere and then store those results (both ‘cxy’ and ‘f’) for each result.
That is essentially how I would do it.
Pat
on 30 Aug 2023
Moved: Star Strider
on 30 Aug 2023
Star Strider
on 30 Aug 2023
O.K.
I would use buffer to create the appropriate matrices (ideally the same sizes) and then give one of them to mscohere as the EMG matrix (perhaps ‘x’) and the other as the EEG matrix (‘y’). If they are the same sizes, the result will be a matrix of the magnitude-squared coherence vectors at the times corresponding to the columns in the argument matrices, and as a function of frequency, so keep at least one frequency vector as well (since they should all share it).
A waterfall plot might be an appropriate way of presenting the results graphcially, with frequency on one axis and time on the other.
Categories
Find more on Measurements and Feature Extraction 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!