# Frequency resolution between coherence functions

Hi Brainstorm,

We are scripting corticocortical connectivity (CCC, computed as lagged Coh) and corticomuscular coherence (CMC, also lagged Coh). How do we determine what the frequency resolution for each computation is?

Thank you,

The frequency resolution depends on the sampling frequency (`fs`) and the number of samples used in the FFT (`nFFT`) , as

`freq_resolution = fs / nFFT`

• `fs` comes from the recordings, and
• `nFFT` is the smallest power of two that is greater than or equal to the number of samples in the analysis window.

Using the data from the corticomuscular coherence tutorial (link below) as example:

Coherence is computed using 1-s trials with a sampling frequency of 1200 Hz. As such, there are 1200 samples per trial, and the next power of 2 for this is 2024, thus, the frequency resolution is `1200 Hz / 2048 samples =` `0.5859 Hz`

https://neuroimage.usc.edu/brainstorm/Tutorials/CorticomuscularCoherence

Thanks Raymundo.
Could there possibly be a difference in frequency resolution between CCC coh and CMC coh using the same computation?
All our data (EEG, EMG) eventually has the same sampling frequency (1000Hz). Since this is held constant, it seems like the `nFFT` is the only option for being different between the two metrics.

One of our scripts calls the `process_cohere1n` function (CCC) and the other calls the `process_cohere2` function (CMC) from Brainstorm; could this be where a difference if frequency resolution is found? For both scripts, the Morlet settings seem to be identical, so i'm confused as to where the difference could be. Any help would be appreciated.

Thank you!

Which are the time-frequency decomposition method and its Options that are being used for both processes?

Can it be that the time window is different?

@Raymundo.Cassani, here's our script (I deleted part of the scripts for brevity in this post) denoting the time freq decomposition method and respective options for CCC:

``````sFiles = bst_process('CallProcess', 'process_cohere1n', sFiles, [], ...
...
'cohmeasure',    'lcohere2019', ...
'tfmeasure',     'morlet', ...  % Morlet wavelets
'tfedit',        struct(...
'Comment',         'Complex,1-60Hz', ...
'TimeBands',       [], ...
'Freqs',           [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], ...
'MorletFc',        1, ...
'MorletFwhmTc',    3, ...
'ClusterFuncTime', 'none', ...
'Measure',         'none', ...
'Output',          'all', ...
'RemoveEvoked',    0, ...
'SaveKernel',      0), ...
'timeres',       'none', ...  % Full (requires epochs)
'avgwinlength',  1, ...
'avgwinoverlap', 50, ...
'outputmode',    'input');  % separately for each file
``````

and for CMC:

``````sFiles = bst_process('CallProcess', 'process_cohere2', sFiles, sFiles2, ...
...
'dest_sensors', char(emg_channels(iEMG)), ...
'removeevoked',  0, ...
'cohmeasure',    'lcohere2019', ...
'tfmeasure',     'morlet', ...
'tfedit',        struct(...
'Comment',         'Complex,1-60Hz', ...
'TimeBands',       [], ...
'Freqs',           [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], ...
'MorletFc',        1, ...
'MorletFwhmTc',    3, ...
'ClusterFuncTime', 'none', ...
'Measure',         'none', ...
'Output',          'all', ...
'RemoveEvoked',    0, ...
'SaveKernel',      0), ...
'timeres',       'none', ...  % None
'avgwinlength',  1, ...
'avgwinoverlap', 50, ...
'outputmode',    'input');  % separately for each file
``````

It does look good.

1. Is the input `sFiles` the same for both processes?
2. Does `sFiles2` and `sFiles` have the same sampling frequency, and same time window?
3. What is the difference that you are finding?
4. Do you have the same behaviour in the GUI?

Hey Raymundo,

Sorry for the delay. With our data, we have `fs` = 1000Hz and 2s analysis windows, thus `nFFT` = 2048, meaning that `freq_resolution` for us using the above formula is 1000Hz / 2048 = about 0.4883Hz. Just curious: is this the frequency resolution, or the max possible frequency resolution?
I'm asking because in the code I showed above, I told Brainstorm to analyze frequencies of 8, 9, 10, 11, 12Hz...and so on..., making me think that our frequency resolution would be 1Hz instead of the 0.4883Hz above.
Could you please clarify what the difference is between the formula you provided compared to the frequencies I provide Brainstorm for analysis?

1. As far as I am aware, `sFiles` is identical between the processes.
2. `sFiles` & `sFiles2` all have the same sampling rate and time window: 1000Hz & 2s windows, respectively.