High everyone, I used time-resolved coherence for a recent paper I wrote. They asked me for the exact equation. I'm not that sure, but does time-resolved coherence compute the coherence separately for each time window using the formula Coherence function (C): Gxy/sqrt(Gxx*Gyy)? Therefore the result is a simple concatenation in time of the results of the coherence in each sliding time window?
If this was the case, my signal length is 480 sec, I used a window of 6 seconds, and 50% overlap. In this case I should obtain as result 160 coherence matrices, but I obtain 158. Why do I miss 2 time samples, does the function delete the first and the last time window?
Thanks
the result is a simple concatenation in time of the results of the coherence in each sliding time window?
Yes. The process Time-resolved coherence NxN [2021] calls the same function as the coherence process in a loop, for each 6s-window.
https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/process/functions/process_cohere1n_time_2021.m#L143
does time-resolved coherence compute the coherence separately for each time window using the formula Coherence function (C): Gxy/sqrt(Gxx*Gyy)?
For this article, I guess you used the older version of the coherence implementation:
We redesigned completely the way the coherence was computed in July 2021:
The general formula remains the same, as you can see in the header of the two functions. However, the way the windowing is handled for the evaluation of the cross-spectra is done changed significantly, making it difficult to compare directly the results obtained with the old and the new version.
If this was the case, my signal length is 480 sec, I used a window of 6 seconds, and 50% overlap. In this case I should obtain as result 160 coherence matrices, but I obtain 158.
Actually none of these numbers is correct...
With an overlap of 50%, you should obtain N + (N-1) = 2*N-1 windows, i.e. one extra window between each pair of windows. Here, N=480/6=80, and the final number of time points should be 159.
There was however a bug in the Brainstorm code that led to skip the last window...
This is fixed here: Bugfix: Missing last block in time-resolved coherence · brainstorm-tools/brainstorm3@44b407c · GitHub
@hossein27en @Raymundo.Cassani Am I missing something here?
@Raymundo.Cassani brought up another issue: there was one sample too many included in each sliding window... I fixed this by replacing the time slicing in this process with the one used in bst_psd.m, which does not suffer from these errors:
https://github.com/brainstorm-tools/brainstorm3/commit/3f20be8ff8516c24873552c45bb7b7fce8247b12