Error using Envelope Correlation [2022]

Dear All,

I tried to calculate NxN functional connectivity using Envelope Correlation [2022]. But the error message was returned as captured here. I also attached a capture file in that I used the parameters in this analysis. Please let me know to way to run this connectivity program correctly.

Thank you,


You spotted an implementation issue with the option "Split large files":
the number of samples used in each block was not always an integer, leading to the error you observed.

Investigating this error, I realized that there were other issues in the implementation of this splitting option:

  1. The last block considered might include only a few data samples padded with zeros
  2. The function crashes if each split block is shorter than 5 seconds

I posted modifications that fix the error you have, but not the two others I found:

This requires some attention from the authors of the method: @hossein27en @leahy @Sylvain @Raymundo.Cassani
Until this gets fixed, it would be better to avoid using this option if possible.
GitHub issue:

Please update Brainstorm, and try again.

An example data file for this to be tested: (211.9 KB)

Dear Francois,

Thank you for your reply. The bst_henv.m worked using the same parameter by modifying the program as you showed. But it took a lot of time to complete the connectivity analysis compared with an old version of the Amplitude Envelope Correlation program. Please let me know why this program needs more time than an older one.

Thank you!


The envelope correlation process was completely redesigned.
The old functions were removed in this commit: Connectivity: Deprecation of older AEC processes, replaced with HENV · brainstorm-tools/brainstorm3@33a5ffa · GitHub

If you used exactly the same process, then the computation time difference is probably to different options selected. You are processing 300s at once, which is extremely long...

Dear Francois,

Thank you.
I think the AEC analysis previously I used on the Brainstorm has finished faster than the current version.
Could you let me know why the latest Envelope Correlation version needs more time to complete the AEC analysis than the older versions?


Please post screen captures of the options you used in both cases, and copy here the computation time for both methods.
You can enable again the old processes by moving the files brainstorm3/toolbox/process/deprecated/process_aec*.m to folder brainstorm3/toolbox/process/functions.

Hi Francois,

Thank you for your reply.
I calculated Envelope Correlation from the same data from both the recent and old versions.

I indicate the computation time for both method as follow:

Older version: about 2min
Recent version: about 3 hours

The parameters I used are here.

Please check the attached files.

Thank you,


The results of connectivity matrices extracted from the old and current versions were completely same.


Indeed, with this combination of options, the computation of the new function is awfully slow.
I tried to optimize some of the computation in this commit: bst_henv: Significant optimization of function HMatCorr · brainstorm-tools/brainstorm3@f55319f · GitHub
Please update Brainstorm and try again.

However, I could not obtain strictly the same results between the old AEC and the new EC processes. There are slight differences in the expected results.

I computed EC using the latest version of Brainstorm and obtained the EC result at maybe 3 minutes. Thank you!
Could you let me know why it took a lot of time to calculate EC by the previous version if you don't mind?

The code was correct but not optimized.