I am having trouble using the Envelope Correlation N x N (2020) feature.
I am testing it on one participant, with 47 epochs (source localized), each epoch of 10 seconds long (512 Hz samples). Running Amplitude Envelope Correlation (N x N) works and provides no error, but to speed up the process, I would like to run the exact same analysis but with the parallel processing provided in the Envelope Correlation N x N (2020).
My understanding is that the "Estimation window length" should equal to the "Time Window" if I want to produce the same results as the Amplitude Envelope Correlation (N x N).
But when trying to do so, I am running into the following error:
** Error: [process_henv1n] Connectivity > Envelope Correlation NxN (2020)
** Line 23: cat
** Dimensions of arrays being concatenated are not consistent.
**
** Call stack:
** >process_henv1n.m at 23
** >bst_process.m>Run at 230
** >bst_process.m at 37
** >panel_process1.m>RunProcess at 124
** >panel_process1.m at 26
** >gui_brainstorm.m>CreateWindow/ProcessRun_Callback at 768
** >bst_call.m at 28
** >gui_brainstorm.m>@(h,ev)bst_call(@ProcessRun_Callback) at 292
**
**
My understanding is that the "Estimation window length" should equal to the "Time Window" if I want to produce the same results as the Amplitude Envelope Correlation (N x N).
This probably results in gigantic files created in memory, and maybe output files with an unnecessarily high frequency resolutions. Have you tried with shorter epochs?
I am running into the following error
I could not reproduce the error you reported with the options shown in your screen capture.
Could you please share an example dataset so that we can first reproduce this error?
Right-click on the subject > File > Duplicate subject
In the duplicated subject, keep only the files that are needed to reproduce the error:
In the anatomy: the MRI, the cortex surface you used for the source estimation
In the functional data: the channel file, two data files + the inversion kernel (or + the associated source maps if they are not links)
Make sure you can replicate the error with this minimalist setup
Right-click on the subject > File > Export
Upload the .zip file somewhere and post the download link here
I have tried shortening the epochs down to 2 seconds, and still run into the error.
I also shortened "Estimation Window Length" from 10000 down to 1000, in steps of 1000. Only when I reached 1000, did it work. However, since I'm trying to produce the exact same results as Amplitude Envelope Correlation (N x N), as in only interested in static AEC with Hilbert Transform, I followed this post by Hossein, which if I'm understanding the last part of it, "Estimation Window Length" should equal the entire "Time Window" for what I am trying to do. Or is "Estimation Window Length" not considered at all when choosing "Static" (this was my first thought)?
Please find the link below with the example dataset. The error was replicated with this as well (just the 2 data files).
I debugged the code and understood what the problem was: the Envelope correlation code is not capable of correctly handling unconstrained source maps.
I opened a PR to propose a fix for these changes:
We'll let you know when the PR is merged and you can download a fixed version of Brainstorm.
The top figure (theta band) is that calculated with Envelope Correlation N x N (2020), with the 'Estimation window length' set to the length of the full epoch (9998 ms; this is resting state continuous EEG where I split the data into ~10 sec epochs). The bottom is with the static Amplitude Envelope Correlation N x N process.
These are results obtained with the files you shared earlier?
Can you please post screen captures of the options that you are using in the two cases (including all the secondary option windows that can be set from the pipeline editor)?
I may have done something wrong with the definition of the time window that led to the differences originally reported.
On a related note, is there any reason why would want to define the "time window" and "overlap %" when using the static option? From my understanding the 2 parameters are for dynamic?
I double checked everything regarding the time window options, and now am getting the original differences I reported in the same dataset.
The dataset that showed the difference vs the one above (where they are the same) are different. Not sure if this could be an issue with the data? I will dig further.
I've compared the two methods again, and they are indeed not converging on this particular data. What is interesting is that when comparing the correlations values for each connection, either they do match, or they do match in magnitude, but are opposite in direction.
I've compared the two methods again, and they are indeed not converging on this particular data.
Can you share an example dataset?
The simplest could be that you extract the scouts time series (with the dedicated process) first. Make sure that you can reproduce the same differences with the scouts time series in input (select the scouts "matrix" files in the Process1, instead of the source maps). Then share only this matrix_...mat file so we can reproduce your observations on our end.
Thank you for the example file.
I could reproduce exactly the behavior you reported.
I noticed that the values are mostly the same, except for some differences:
The old function (AEC) return positive/negative values, while the new function (HENV) returns strictly positive values
A small number of values are very different (not only a sign difference), like the one selected in the screen captures below (same as yours, but with the colormap configured with the option "Absolute values")
Old function (AEC):
New function (HENV):
@hossein27en
You can download the example posted above as a readily available Brainstorm protocol from the link below. You can import it with the menu File > Load protocol > Load from zip file.
@pdhami Note that we've just updated the HENV processes. This corrects many bug fixes, but does not change the differences you observed.
Please update Brainstorm to get these fixes before doing any further tests.
I was able to finish my AEC calculations using the old process.
I'm assuming (due to providing both positive and negative correlations) that these results are 'correct' and okay to move forward with, and that the issue is strictly with the newer HENV process?
We tested further the comparison between the older AEC and the new HENV processes.
You can reproduce exactly the results obtained the new HENV results with the older processes AEC by editing bst_connectivity.m.
Eeplace line 504:
Amplitude envelope correlation is not a symmetric measure by its nature. Still, most people have used it as symmetric, and there is no clear explanation about the meaning of the connectivity from A->B Vs. B->A.
As a result, my code and the AEC make the matrix symmetric by adding its transpose and dividing over 2. However, I apply abs() before summation, but the AEC does not (so if there is a negative value, it might cancel the positive one). I do think the abs value is necessary. In MNE-python, they have abs as the default.