Bug with EEG decoding

Dear François,
I tried to use decoding for EEG data : SVM plug is installed, Brainstorm is updated
This is an oddball task with two condition with 1345 trials (275 vs 1070).
Parameters are Sensor types : EEG, Low-pass = 30 Hz, Number of permutations = 100 and folds =5, Decoding = pairwise
The process does not execute fully with the error
Any idea to solve this ? Thanks a lot !

Can you please share a small example dataset?
Zip together some file that can allow us to reproduce exactly this error:

  • A few data files that if placed in FilesA/FilesB produce this error (try with a small number of files)
  • The channel file(s) associated with these data files



Ok fine.
Where I send you a link for get the data ?

Thank you for the example files.
I tested them on my computer and it works:

It looks like you work on MacOS, and I suspect that you haven't compiled the library. I made the instructions more explicit in the tutorial:

I added a test to make the error message more explicit than what you got:
process_decoding_svm: New error message when libsvm must be compiled · brainstorm-tools/brainstorm3@aab5862 · GitHub

Perfect, you were fully right ! After having compiled the library, I had a nice result decoding result.
Thanks a lot for your help and this very nice process.
Last question : is there a significant value for decoding accuracy ? 80 - 90 %? I guess this is user's "choice" ?

@pantazis ?

Hi Jungju,

To establish statistical significance in decoding results, you still need to do statistics because high classification values can still arise by chance. See for example https://www.sciencedirect.com/science/article/pii/S0165027015000114

I use permutation tests in my work, when having multiple subjects and each subject contributes one decoding time course.


Hi Francois,

I got exactly the same error as here while trying with the tutorial example dataset on Brainstorm. I have compiled the library but it's still not working. It might be due to the built-in function of MATLAB itself?

Thank you.

Hi @popotracy,

Did you already update your Matlab path to have the path to the compiled libsvm library in a higher position, so this is the one svmtrain that is called, rather than Matlab one?

Hi @Raymundo.Cassani

Thanks for your reply. I tested it by doing "exist svmtrain" and 'which svmtrain' in my command windows, MATLAB told me it is from my LIBSVM library and a MEX-file on my MATLAB search path, so I assume I am running the correct one, but I still get the same error.
Thank you again for your time.


Do you get any addition information in Matlab's command window?

With Brainstorm running, execute this command in Matlab and paste the response:

Hi Raymundo,

Sorry for the late reply. It gave me "mac64" from the command. Please see the other message from MATLAB while I ran the SVM decoding in Brainstorm. Thank you for your time!

Hi Tracy,

The mac64 indicates that you are running on macOS (of course) with an Intel processor.
I tested on the same setup, and I got the same error as you (hurray!), and now it's solved.

I'm using Matlab 2020b, with macOS 14.4.1 and Xcode 15.3

Please follow the steps below to determine if it is indeed the same problem, if it is, the solution will be after the steps:

In Brainstorm, start with a clean

  1. Uninstall the plugin libsvm
  2. Clear the Matlab command window with clc
  3. Install the plugin libsvm, the installation should perform the compiling of the library
  4. Check if there are any errors in the command window
  5. There should be 4 .mex files at /Users/USERNAME/.brainstorm/plugins/

  1. Start Brainstorm and load the libsvm plugin
  2. Open the file sll_devodesvm.m it is in brainstorm3/external/scilearnlab
  3. Between lines 34 and 44, comment everything. Except line 36, so all that block just reads:
    svmtrain([0 1],[0 1],'-s 0 -t 0 -q'); %this should not produce errors in libsvm is installed
  1. Try to do the decoding again.
  2. It should give you a long and detailed error message. Please pasted in here.

Solution. In my case the error indicated that Library not loaded: @rpath/libMatlabEngine and all the places where it tried to find it. So I created a symbolic link (need to be done as admin) to one of the expected places:

ln -s /Applications/MATLAB_R2020b.app/extern/bin/maci64/libMatlabEngine.dylib /Applications/MATLAB_R2020b.app/bin/maci64/libMatlabEngine.dylib

Which Matlab version are you using?