# Lagged coherence

Hi all,

I am interested in functional connectivity analysis by lagged coherence.
We can apply this method by choosing the following flows.
[connectivity] -> [coherence] -> [lagged coherence]

On the other hand, we can also choose lagged coherence with the following flows.
[connectivity] -> [envelope correlation] -> [lagged coherence]

So, could you let me know the difference between these two lagged coherence methods?

Best,

Hisato

The difference is in how coherence is estimated, this is a detailed description of the two methods:

A. Connectivity > Coherence [2021] > Lagged Coherence

This process obtains only one coherence spectrum estimate using all the windows

These 2 parameters control how coherence is computed:

1. Time window: This refers to the part of the signal that you want to analyze, often All file is often selected.

2. Window length for PSD estimation: Time window to compute the xy-CrossSpectrum, and the x- y-AutoSpectra (which are the same to their PSDs). These spectra are used to compute coherence. Overlap for PSD estimation: This parameter controls the number of windows that will be used to estimate the coherence spectra in the current segment.

Coherence (`C`) is computed as the ratio of the xy-CrossSpectrum, and the x- y-AutoSpectra

For example with these parameters:

• Time window: 0 -10,000 ms
• Lagged coherence
• Window length for PSD estimation: 2000 ms
• Overlap for PSD estimation: 50% (250 ms)

If the input is one file, and Output option is Save individual results... :

1. The first 10 s of signal are split in 9 windows of 2 s, with 1 s overlap. One xy-CrossSpectrum, and two AutoSpectra (one for x and one for y) are computed for each window.
2. Then, xy-CrossSpectrum, and two AutoSpectra are averaged across windows.
3. The Coherence spectrum is computed using the averaged CrossSpectrum and averaged AutoSpectra. Thus there is one Coherence spectra for the 10-s signal
4.Finally, lagged coherence is then computed from `C` as `LC = |imag(C)| / sqrt(1 - real(C)^2)`

If the input are multiple files, and Output option is Average cross-spectra..., one Coherence spectrum is obtained from the averaged (across all windows in all files) xy-CrossSpectrum and AutoSpectra

B. Connectivity > Envelop correlation [2022] > Lagged Coherence

Computing coherence through the "envelope correlation" process, is a bit different, as there is one coherence spectrum estimate for each window

These 3 parameters control how coherence is computed:

1. Time window: This refers to the part of the signal that you want to analyze, often All file is often selected.

2. Time resolution:

• Dynamic (one coherence estimate per window)
• Static (average coherence spectrum across windows)
3. Estimation window length: Time window to compute the xy-CrossSpectrum, and the x- y-AutoSpectra (from the TF representations). Sliding window overlap: This parameter controls the number of windows.

Coherence (`C`) is computed as the ratio of the xy-CrossSpectrum, and the x- y-AutoSpectra

For example with these parameters:

• Time window: 0 -10,000 ms
• Morlet wavelet: 1:1:40 Hz
• Lagged coherence
• Time resolution: Dynamic
• Estimation window length 2000 ms
• Sliding window overlap 50% (1000 ms)

If the input is one file, and Output option is Save individual results... :

1. A TF representation is obtained using the Morlet wavelet approach (40 frequencies)
2. The TF map is then split in nine windows of 2 seconds each, with 1 second overlap
3. For each window, CrossSpectrum and AutoSpectra are computed using all the time samples in the window (nTimeSamples = estimation_window_length * fs)
4. Then a Coherence spectrum is computed for each window, thus there are a total of nine Coherence spectra for the 10-s signal
5.Finally, lagged coherence is then computed from `C` as `LC = |imag(C)| / sqrt(1 - real(C)^2)`

Note: The Static time resolution option performs the average of the lagged coherence, and not the average of the CrossSpectrum and AutoSpectra (as it is done in Coherence [2021])

If the input are multiple files, and Output option is Average cross-spectra..., the previous steps are executed for each file, and the result is averaged across files.

Best,
Raymundo

Hi, Raymundo,

Thank you for getting back to me.

If I have 10000ms x 112 ROIs data, are the following parameters reasonable for calculating lagged coherence in method B?

Time window: 0 -10,000 ms
Morlet wavelet: 1:1:100 Hz
Lagged coherence
Time resolution: Static
Estimation window length 10,000 ms
Sliding window overlap 0%

Or do I have to input multiple time windows to calculate lagged coherence by method B?

Having the same value for the Time window and Estimation window length implies that lagged coherence is derived from only one window, thus the only one lagged coherence spectrum will computed.

With the above parameters, the estimations for CrossSpectrum and AutoSpectra are the mean CrossSpectrum and mean AutoSpectra across all the time samples in the 10-s window. From these estimations, (lagged) coherence is computed. This is the approach also used in the Coherence [2021] process. This is the common approach to compute coherence: https://www.frontiersin.org/articles/10.3389/fnsys.2015.00175/full

On the other hand, if multiple windows are defined in the Envelop correlation [2022] and Time resolved is `Static`, the resulting lagged coherence spectrum is the mean of lagged coherence spectra in each window.

The mean coherence is not the same that coherence obtained from mean CrossSpectrum and AutoSpectra.

Hi Raymundo,

is there a recommendation which approach (A or B) is better/more common used for resting state EEG data?

Best,
Christina

Hi Christina,

If one lagged coherence spectrum is wanted for the resting state data, using A (Connectivity > Coherence [2021] > Lagged coherence) is preferred. This is because the coherence computation comes from cross-spectrum and auto-spectra estimations obtained from all the available data.

Approach B ( Connectivity > Envelop correlation [2022] > Lagged Coherence) is used when there is a need for time-resolved coherence, i.e., the original signal is divided in segments, and a coherence spectrum is obtained for each signal segment.

Best,
Raymundo

Hi Raymundo,

I was running coherence calculation in the brainstorm toolbox using the 6 Feb 2024 version and using MatLab R2023b version. Process selection options in 1xN coherence got an error. Pipeline pop up like "please check the advanced option of process Coherence 1xN [2023] before running the pipeline".

What should I do with this or how can I fix it?

Any suggestion,
Sincerely

Click on the Edit... button on the Time-frequency decomposition section to validate the options that will be used for the selected TF method.

well, kindly appreciate for your response. However, I have processed the data but there is also the problem of the export file. Normally I can export file to *.xlsx but this time got as shown in the figure below.

The issue is that the data to export is 4D `[nSensors, nSenstors, nWindows, nFrequency]`. You need to collapse either the time of the frequency dimension. Check this post:

highly thank you for your help. I couldn't have done without this information.

appreciate it