- Requirements
- Use the Plugin Creation Assistant
- What is a Plugin?
- Compiled plugin
- anywave() API function
- Make your plugin BIDS Pipeline compatible
- DEBUG PLUGINS directly in MATLAB
A MATLAB plugin is a folder located in the user home dir.
Documents\AnyWave\Plugins\MATLAB on Windows.
/home/username/AnyWave/Plugins/MATLAB on Linux.
/users/username/AnyWave/Plugins/MATLAB on MacOS.
Requirements
MATLAB.
AnyWave will detect the MATLAB installation when starting up.
However, if MATLAB was installed in a custom directory, it will be invisible to AnyWave.
To fix that, you must use a user.json file that must be located in the Settings folder.
See section Customise MATLAB.
If you want to distribute your plugin, the best tool is the MATLAB compiler which generate a standalone application.
The target compute must have the matching version of the MATLAB Runtime in order to run it.
AnyWave will detect runtimes installed on the computer if they have been installed in the default folder of your system.
Use user.json file to change path where runtimes are located in order for AnyWave to find them.
Use the Plugin Creation Assistant
What is a Plugin?
It's a folder placed on Plugins/MATLAB subfolders of AnyWave.
When AnyWave starts the first time it creates a folder named AnyWave in the user's home directory.
In the AnyWave folder you will find a Plugins\MATLAB folder.
Create a directory for you plugin in that location or use the Plugin Creation Assistant (see previous section).
desc.txt
A file called desct.txt must be put in your Plugin.
This file is a simple text file that must contain the following lines:
name = My Plugin
description = Do something on data
optional lines
To tune up the behavior of your plugin you may add some flags to tell AnyWave what you plugin can do:
flags=nodatarequired -> this line will inform anywave that your plugin can run even if no data file is open.
flags=canrunfromcommandline -> this flag indicates that your plugin can be run from the command line.
You can combine flags by separating them with a colon (:)
flags=nodatarequired:canrunfromcommandline
Put your plugin in a submenu, by adding the following line:
category=Process:MyCategory:My plugin
This line will create a sub menu called MyCategory in the Processes Menu of AnyWave and a link to launch the plugin.
main.m
A filed called main.m must also be put in your Plugin.
This file along with desc.txt file will make your folder an AnyWave MATLAB plugin.
This is a MATLAB function you can create within MATLAB.
function main(varargin)
args = anywave('init', varargin);
% args contains all the properties related to AnyWave current data file and the plugin context.
% my plugin code starts here
When using the Plugin Creation Assistant of AnyWave, the file is automatically created.
Command Line
You may want your plugin to be used when AnyWave is launched using the command line.
AnyWave can run processes/plugins when launched that way:
anywave --run MyPlugin --input_file <filepath> --plugin_option1 option --plugin_option2 option ...
Add a flag to desc.txt
Add or edit the following line in desc.txt:
Handle command line options
By default the plugin will have all parameters passed to anywave in the resulting args variable after the call to:
args = anywave('init', varargin);
disp(args.plugin_option1); % value for plugin_option1 from the command line.
disp(args.plugin_option2); % value for plugin_option2 from the command line.
However, this is possible only if we inform AnyWave about plugin_option1 and plugin_option2.
Otherwise, an error will occur when using the command line saying that plugin_option1 and plugin_option2 are unknown options.
Register specific options
To add support for specific command line option, add a file called args.json in the plugin folder.
This is a JSON file that must be like this:
{
"Parameters" : ["plugin_option1", "plugin_option2"]
}
Compiled plugin
Using the MATLAB Compiler, you can create a standalone version of your plugin.
AnyWave can call the standalone version of your plugin if you add the following line in desc.txt:
compiled plugin=nameofexefile
On Windows it will the name of the .exe file located in the folder.
On macOS and Linux it will be the bash script (.sh file)
It is also strongly recommended to specify the version of the Runtime needed to run the plugin.
add a new line to desc.txt file:
runtime=version
For example with recent releases of MATLAB:
runtime=R2024b
You have to install the matching runtime version on your system.
AnyWave should detect it when starting up and when the time comes to run the plugin, it will setup the context to run the plugin with the required Runtime version.