Problems running SPRiNT Protocol

Hi everyone,

we currently want to try the new SPRiNT toolbox. However when we run the protocols on our own as well as on sample data, we always get the same error (see attachted screenshot).

The first problem is we can't find the function getlpOptions anywhere in the scripts, so maybe we just didn't see it, so it would be nice if someone may point us in the right direction.

Another problem seems to be that the function can't handle structs. We have our EEG data in a .mat file as just a matrix of channels and the signal timeseries. To be able to load it into Brainstorm, we currently make a detour via EEGLAB and save our data as .set files, therefore we automatically have our data in the EEGLAB struct form. So maybe there is a simpler way of loading our data into brainstorm, so we could bypass the struct form after all.

As we are new to the brainstorm platform, any help will be much appreciated. Thank you! :slight_smile:

fmincon is a function from specialized Matlab toolboxes (primarily the Optimization Toolbox, but maybe some other toolboxes like the Curve Fitting Toolbox). If your installation and setup of Matlab is correct, all the depending sub-functions should be part of your Matlab installation.

However, I suspect that you may have other programs in your path that may shadow some basic Matlab functions (e.g. EEGLAB). Therefore I propose the following debugging procedure:

  • Edit the Matlab path, remove ALL the folders that are not directly part of the Matlab installation
  • Close Matlab
  • Restart Matlab, start Brainstorm by running brainstorm.m (do not add it to the path - you should always do it like this).
  • Try again running SPRiNT
  • If you get exactly the same error message (check the line numbers):
    • Re-install Matlab completely
    • If you still get the same error:
      • Type which fmincon to verify that the version that is executed is really the version for Matlab
      • Open a bug report on the Mathworks website (you need to create an account for that - this is free)
  • If you get a different error: Then please post the new error message here
  • You can also try running the compiled version of Brainstorm, this should include all the needed dependencies (See the sections "without Matlab" from the Installation page on the Brainstorm website)

Another problem seems to be that the function can't handle structs. We have our EEG data in a .mat file as just a matrix of channels and the signal timeseries.

"Struct" is not a data format. It can contain any set of variables, there is no way Brainstorm can guess what is what from your own variable naming. EEGLAB .set files are also Matlab .mat files (i.e. "struct").
To load a file from a .mat file, you need an additional convention to define where is the data in the structure.

You can import data matrices from a .mat file (file format EEG: Matlab matrix (.mat)). This would work if your structure contains only one variable, with an optional field "Time" that can be interpreted.

You could save your data directly as an EEGLAB .set structure, without having to actually use EEGLAB to do it (just save the variables the way you would with a Matlab matrix, with the -struct flag on the command line). And then load your manually edited .set file in Brainstorm.

You could also save the data as as Brainstorm "data" structure:
https://neuroimage.usc.edu/brainstorm/Tutorials/Epoching#On_the_hard_drive

As we are new to the brainstorm platform, any help will be much appreciated.

My main recommendation would be for you to start by following all the introduction tutorials (section Get Started) at least until #19, using the example dataset provided, before you try processing your own recordings. Reading the Scripting tutorial would definitely help, if you are planning on scripting or customizing your file import to the database.
https://neuroimage.usc.edu/brainstorm/Tutorials
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting

Hi Francois,

thank you very much for your help. We really appreciate it.

With your input we now don't need to go with eeglab anymore, so this is already a lot more convenient. Regarding the error message, we also made some progress. The fmincon function is from the Opimization Toolbox and it is the only one on the path. Also we went back to default on the Matlab path. We still get the same error message. When we run the other approach "fminsearch" the SPRiNT protocol however runs smoothly and finishes.

So do you think this is a Matlab related problem or a problem with brainstorm or our data? If it is with Matlab I could definitely open a Bug report, however I would like to hear your opinion on this first.

Thank you very much!

If there is a sub-function that is missing in a Matlab function and your Matlab path is clean from any interference with other toolboxes, then the problem comes from Matlab. But:

  • It may come from a problem in your installation => Try re-installing or upgrading Matlab
  • If this is a bug, then maybe it is already fixed in more recent versions of Matlab => What is your Matlab version?
  • If you are already using 2021b or 2022a AND re-installing doesn't solve the issue => Yes, post a bug report on the Mathworks website
    • Put a brekpoint at line 979 in bst_sprint.m, run the execution, when the debugger stops, save all the variables that are used on this line in a .mat file, include the .mat file and the line of code in your bug report

@Luc Any other suggestion?