We are developping a home tool (using the App Designer) based on Brainstorm. The idea would be to create a standalone app. To do so, we tried to compile Brainstorm (bst_compiled.m) but we got an error (see error message below). It seems the file 'plugin.mat' is missing, and I can't find it in the brain2mesh-master folder.
Error using bst_compile (line 208)
COMPILE> MCC returned an error:
Error while determining required deployable files. Compilation terminated. Details:
Error using matlab.depfun.internal.MatFileInspector/determineType (line 32)
File, function or class "brain2mesh-master\plugin.mat"
may not exist. Neither WHICH nor EXIST could find an exact, case-sensitive match. Please check the spelling of
the name, and that any required directories are on the MATLAB path.
There is something wrong in the configuration of the path of the files provided to mcc.
It looks like your call results in trying to add "brain2mesh-master\plugin.mat" which indeed doesn't exist.
Put a breakpoint at line 194 to check that the plugin brain2mesh is correctly loaded.
It should add:
-a "C:\Users\franc\.brainstorm\plugins\brain2mesh\brain2mesh-master"
-a "C:\Users\franc\.brainstorm\plugins\brain2mesh\plugin.mat"
If you have issues compiling Brainstorm with the plugins, then compile it without.
Make sure you clean your Matlab path before running brainstorm compile: it should contain only the Matlab installation folders.
Thank you for your answer, there is no more problem with the loading of the plugin brain2mesh.
However, we now have an error (see error message below) when trying to copy a file. The problem is that the folder R2021b contains no file. Which file is it trying to copy and why does our R2021b folder is empty?
Error using copyfile
No matching files named 'D:\Brainstorm\brainstorm3\bin\R2021b\*.*' were found.
Error in bst_compile (line 264)
copyfile(fullfile(binDir, '*.*'), destDir);
This copy operation is completely optional, it is part of the creation of a .zip file with the new binary distribution. You could ignore this error, but the fact that the folder brainstorm3\bin\R2021b\ is empty is a sign that more silent errors occurred before in the script.
The folder brainstorm3\bin\R2021b\ is supposed to contain the compiled brainstorm distribution packaged as a .jar file. See the brainstorm3\bin\R2020a\ from the current distribution for execution.
If you don't have any file at the moment of the copy, it is because the creation of this .jar file failed:
In order to understand why this is not working: you need to debug the bst_compile.m script, and try to run the jar file creation from a CMD terminal manually or check the existence of each file.
The problem is due to another problem before, maybe the compilation with mcc failed?...
Once you manage to get the .jar file generated correct: Here are additional files that could be added to the brainstorm3\bin\R2021b\ folder, to make it easier to start the compiled Brainstorm version from the .jar file: R2021b.zip (2.5 KB)
We have been working on an app that uses Brainstorm. Up until recently, we were using the app in a Matlab environment (using Brainstorm nogui). Now, we want to have a compiled version of this app.
We compiled the app but had problems. First, we had to move the two .jar files (brainstorm.jar and riverLayout.jar) to a specific folder. We then had a problem when calling Brainstorm functions. For example, when calling the function bst_get('ProtocolInfo'), we got an error because the function 'panel_process1' was unrecognized.
We then tried to compile the app without starting Brainstorm (we removed the lines that were starting Brainstorm nogui). It did not work. When calling the function bst_get('ProtocolInfo'), we got an error because the variable 'GlobalData' was empty.
We are not sure how we can obtain a compiled app that uses Brainstorm.
Any advice would be greatly appreciated!
Thanks,
Corentin
Can you please confirm can you can compile a non-modified version of today's version of Brainstorm using brainstorm compile noplugs? Tutorials/Scripting - Brainstorm
If this work, but you can't compile your modifications, please:
Thanks for your help! We can now compile a modified version of Brainstorm correctly (although we will be using the version you distribute!).
We tried running our code as a script using the compiled version of Brainstorm (and MATLAB Runtime). Our script takes a json file as an input. The json file contains a list of processes with the parameters. This list of processes is then stored in the property of a custom MATLAB class that we have developped.
Although we can run simple script, it seems like MATLAB Runtime does not support script that calls custom classes.
Although we can run simple script, it seems like MATLAB Runtime does not support script that calls custom classes.
I added a new paragraph to the documentation:
"In this configuration, the Matlab Runtime is not allowed to compile and execute .m scripts as a regular Matlab installation would. To work around this limitation, Brainstorm reads the script.m file and executes its contents with the Matlab eval function. Therefore this approach does not support the definition of functions or classes within the script.m. The compiled version of Brainstorm can only run code that can be executed from the Matlab Command Window. If you need more flexibility, you need to recompile a modified version of Brainstorm including your custom code (see below)."
Sorry for the late response!
We included our classes and functions in the compilation of Brainstorm.
It all works fine when we run a script with no parameters (or argument). We tried to run a MATLAB function file with an argument, but it does not work (see error message below). It seems like the parameter passed in the command window is not recognized. We use the syntax indicated in the tutorial : brainstorm3.bat 'script.m' 'parameters'.
Is it possible to run a function file that requires arguments ?
Thank you for your help,
Corentin
Here is the error messgae:
"WARNING: This file is a function, trying to convert to a script...
Error using panel_command>ExecuteScript
The number of argmuents in the function does not match the number of parameters passed in the command line.
It seems it's not available when compiling Brainstorm including all plugins. I get the following error: Preparing the folder spmtrip with bst_spmtrip.m is available only for Windows (for the moment).
I then tried compiling Brainstorm without plugins, but I get the following error: COMPILE> MCC returned an error: bin/bash: mcc: command not found
I don't understand this error since we have the MATLAB Compiler installed (MATLAB Compiler Version 8.2 (R2021a) and MATLAB Compiler SDK Version 6.10 (R2021a)).
Is it possible to compile Brainstorm in Linux or is it a problem with the MATLAB Compiler we have?
Thanks for the response, the compilation on Linux seems to work fine.
I still have one question: I tried using Brainstorm compiled on Linux but it did not work (see error message below). I tested with a script that used to work with Brainstorm compiled on Windows. I made sure the syntax was correct (brainstorm3.command MATLABROOT script.m parameters)
Thanks for your help,
Corentin
Error message:
Please wait...
If it hangs for more than a few minutes: try pressing ENTER.
Alternatively, download Brainstorm for a different version of the Matlab Runtime.
(See the installation instructions on the Brainstorm website)
Usage : brainstorm start : Start Brainstorm
brainstorm nogui : Start Brainstorm with hidden interface (for scripts)
brainstorm server : Start Brainstorm on a distant server (completely headless)
brainstorm <script> <args> : Start Brainstorm in server mode, execute the input script and quit
brainstorm ... local : Start Brainstorm with a local database (in .brainstorm folder)
brainstorm stop : Quit Brainstorm
brainstorm update : Download and install latest Brainstorm update (see bst_update)
brainstorm reset : Re-initialize Brainstorm database and preferences
brainstorm digitize : Digitize electrodes positions and head shape using a Polhemus system
brainstorm setpath : Add Brainstorm subdirectories to current path
brainstorm startjava : Add Brainstorm Java classes to dynamic classpath
brainstorm info : Open Brainstorm website
brainstorm forum : Open Brainstorm forum
brainstorm license : Display license
brainstorm tutorial name : Run the validation script attached to a tutorial (ctf, neuromag, raw, resting, yokogawa)
brainstorm tutorial all : Run all the validation scripts
brainstorm packagebin : Create separate zip files for all the currently available binary distributions
res = brainstorm('status') : Return brainstorm status (1=running, 0=stopped)
BST> Compiled code returned without errors.
Passing arguments works in different ways in Windows and Linux, maybe there is something to fix...
Can you try compiling only Brainstorm first, not your script? (so that executing from the command line starts the Brainstorm interface)
Just to make sure the compilation does work in your setup.
I tried compiling only Brainstorm and I get the same behavior. When I execute brainstorm3.command in the command line, the Brainstorm interface opens. So the compilation seems to work. Also, I get the same error message when trying to run a script with or without parameters.
The problem seemed to be the path to the script. The script I was trying to execute contained a capital letter and it apparently caused of the error.
For example, If I run a script named 'script_new.m', I have no error. If I simply modify the name to 'Script_new.m', I get the error I mentioned earlier. I have the same problem if the folder containing the script has a capital letter.
It is a weird problem and I don't understand why, but I'll be aware. If you know the reason, I'd be curious to understand!