Lagged Coherence: What if window too short?

Hello Brainstorm community/developers,

I am running a functional connectivity analysis using Lagged Coherence (process_cohere1n) on TMS-EEG data. To avoid the initial TMS artifact, I need to restrict my coherence calculation to a very short post-stimulus window (e.g., 30 to 150 ms). I am specifically interested in the alpha band (8–12 Hz).

My epochs in the database are much longer (e.g., -500 to +1000 ms), but I am using the 'timewindow', [0.03, 0.15] parameter in the pipeline.

I have a specific question about the order of operations under the hood to understand how edge artifacts are being handled:

1. Cropping vs. Math: When using 'tfmeasure', 'hilbert', does the process calculate the analytic signal (Hilbert) on the entire uncut epoch currently loaded in the database, and then extract the phase values for the 30–150 ms window to compute coherence? Or does it physically crop the data to the 120 ms timewindow before applying the Hilbert transform?

2. Padding: If the data is cropped to 120 ms before the transform, applying an 8–12 Hz filter to a 120 ms window will inherently cause severe edge artifacts (since it is less than one full alpha cycle). Does Brainstorm automatically apply mirror padding (edge reflection) to short time windows in this specific coherence function to mitigate this?

I want to ensure my alpha-band phase estimates are mathematically reliable within this short window, or if I should compute the time-frequency decomposition on the whole file first and then run the coherence on the resulting TF files.

Thank you in advance for the clarification!

It is the second option. Data is cropped to the requested time window before obtaining the analygic signal.

That is correct.

Indeed, mirror padding (plus windowing to make it smooth) is a way to handle the filter transient. However, the results are misleading for those first and last nTabs/2 samples.

You may be interested in this other recent Forum post: