Imaginary Coherency Output - Time Average

Dear Brainstorm community,

I have preprocessed TMS-EEG data that I have run a 1 x N sensor imaginary coherence analysis with in FieldTrip, and would like to replicate in Brainstorm. I have multiple trials, each being an epoch length of 2 seconds (-1 s before TMS pulse and 1 s after TMS pulse).

From my understanding, for time-frequency analysis there can be no NaNs, so I first used the ft_interpolatenan function to replace the NaN values in the data due to removal of the TMS artifact before importing my .set files into Brainstorm.

Working with a single datafile, I now try to run the imaginary coherency 1 x N process, but when visualizing the results, I am confused as to a few parameters.

  1. my time is being listed as [-1.0, 143] s and it states 'Time average' below it. Does this mean the coherence values being displayed are averaged between these two times? When trying to use the arrows to change the time, i can only go to these two values, nothing else. Why is that? Is this related to the calculation of imaginary coherency and my data parameters? How can I get greater time resolution so I can look at how the topoplot changes over time?

  2. I was hoping to have a sort of coherency map for each electrode, showing the evolution of the coherency for each frequency over time to compare with my results from FieldTrip. How can I get such a map if possible?

I am ultimately hoping to use BrainStorm for source localization of my FieldTrip coherency findings, so thought I would first see if the sensor level findings are similar. Any help would be greatly appreciated.

Best,
Paul

1 Like

my time is being listed as [-1.0, 143] s and it states 'Time average' below it. Does this mean the coherence values being displayed are averaged between these two times? When trying to use the arrows to change the time, i can only go to these two values, nothing else. Why is that?

It indicates that in the options of the process "Coherence 1xN", you selected the option "Concatenate input files before processing". This created a long file with all your epochs concatenated. Then the coherence was estimated over this long time window. In output, you get only one value, and the time bounds are kept just to indicate how long was the segment of data in input.
After concatenation, the cross-spectra of the signals are estimated by blocks, similarly to what is done for the PSD (https://neuroimage.usc.edu/brainstorm/Tutorials/ArtifactsFilter#Evaluation_of_the_noise_level). I guess this is not what you expected to obtain...

How can I get greater time resolution so I can look at how the topoplot changes over time?

You can use the process "Time-resolved coherence". This would estimate the coherence by short blocks in your epochs. But 2s seconds is very short to split it in many smaller time windows. Just like it is explained for the PSD, you need many windows of at least 500ms-1s to estimate a proper spectrum.

For more information on how the coherence is estimated in Brainstorm, please refer directly to the comments in the code: https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/connectivity/bst_cohn.m
We are still waiting for new tutorials and test datasets to explain properly all these things.

I was hoping to have a sort of coherency map for each electrode, showing the evolution of the coherency for each frequency over time to compare with my results from FieldTrip. How can I get such a map if possible?

I'm not sure what you did in FieldTrip, but it might not translate to this process "Coherence 1xN" you used in Brainstorm. This will not give you any fine temporal evolution. Maybe something like "coherence before TMS pulse" vs "coherence after TMS pulse", but not more refined than this.
Can you post screen captures of what you obtained with FieldTrip? together with the names of the functions and main options you used?

If you are expecting to compare "coherence before" vs. "coherence after", maybe you could run the process Coherence 1xN twice (once for the 1st second, once for the 2nd second), using the option "Save individual results", and then run a non-parametric test to compare across trials what the differences are before and after the TMS pulse?

@Sylvain @hossein27en Any suggestion?

Hi Francois,

thank you very much for your reply.

Please find below an example of a coherency (averaged across all electrodes) time by frequency representation I was hoping to produce something similar to in Brainstorm.

In regards to code, with dataSPfreq_coh being my preprocessed data for a single subject:

    % interpolating NaN values due to removal of TMS pulse
    cfg                 = []; 
    cfg.prewindow       = 0.995; 
    cfg.postwindow      = 0.990; 
    cfg.method          = 'linear';
    dataSPfreq_coh          = ft_interpolatenan(cfg, dataSPfreq_coh); 
    
    % freq_coherency analysis
    cfg                 = []; 
    cfg.output          = 'powandcsd';
    cfg.method          = 'mtmconvol';
    cfg.foi             = 2:1:40;
    cfg.t_ftimwin       =  2 ./ cfg.foi; %length of the sliding time window in seconds
    cfg.tapsmofrq       = 0.4 *cfg.foi; % smoothing increases with increase in freq_coh
    cfg.toi             = -1:0.01:1;
    dataSPfreq_coh = ft_freqanalysis(cfg, dataSPfreq_coh)

    % Imaginary coherency analysis
    cfg  = [] ;
    cfg.method = 'coh';
    cfg.complex = 'absimag';
    mycoh = ft_connectivityanalysis(cfg, dataSPfreq_coh);

Then with the output structure, I just averaged across the channel domain (something like 1770 pairs) to create a matrix of coherency values by time by frequency, which is what the plot is above.

Best,
Paul

@Sylvain @hossein27en?

Hi Paul,

I am not sure I understand your problem. Would you please discuss it shortly?

Thanks
Hossein

@hossein27en I think the question is quite well explicited.
Paul would like to compute with Brainstorm the same results he obtained with FieldTrip.

Is it possible?
If yes: how?
If no: why?

So, If I understood correctly, you want to plot the average of connectivity spectrum (Frequency by time) among all pairs of a N x N matrix?

Paul, first of all, you need to use a measure which produces that 4-D structure (channels x channels x time x frequency band). Right now, you can use time-resolved coherence. You can specify the time window and frequency resolution. Make sure to select overlap as large as possible so you would have a better temporal resolution.

When you computed the connectivity matrix, you can export it to Matlab. The output variable will be a structure. There is a field inside the structure named as TF with the following dimensions:
(N^2+N)/2 x time points x frequency bins
It is lower-triangle of the original connectivity matrix. Average on the first dimension (Exclude the diagonal elements). Finally, use "imagesc" to display the connectivity spectrum.

Hossein