Difference between revisions of "AnyWave:WriteMatlabScripted"

From WikiMEG
Jump to: navigation, search
(AnyWave-Matlab functions)
(AnyWave-Matlab functions)
Line 21: Line 21:
 
=AnyWave-Matlab functions=
 
=AnyWave-Matlab functions=
 
The table below shows a summary of all matlab functions available when writing a Matlab Scripted plug-in:<br/>
 
The table below shows a summary of all matlab functions available when writing a Matlab Scripted plug-in:<br/>
Function parameters contained between <> are optional.<br/>
+
Function parameters placed between <> are optional.<br/>
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 38: Line 38:
 
| '''AwSendMessage'''(message) || Send a message to AnyWave. The message will be added to the plug-in's log.
 
| '''AwSendMessage'''(message) || Send a message to AnyWave. The message will be added to the plug-in's log.
 
|}
 
|}
 +
 +
==AwGetInputChannels()==
 +
AnyWave uses channels to represent signals on screen but also as its internal data set.<br/>
 +
When a plug-in is launched by AnyWave, a set of input and/or output parameters is defined.<br/>
 +
<br/>
 +
AwGetInputChannels() will request the list of input channels for the plug-in. No parameters are required.<br/>
 +
AnyWave will send back a structure array containing Matlab structures which match structure defined by the '''AwChannel()''' function.<br/>
 +
AwChannel() is provided by AnyWave to easily create a Matlab structure which will be compatible with AnyWave's channels objects.<br/>

Revision as of 13:22, 17 April 2014

Introduction

This section targets people who have a good knowledge and practice of Matlab language.
The purpose is to explain how to write a Matlab function that will be available to AnyWave.
The function will be executed by MATLAB after a connection to AnyWave has been established.
We will cover the AnyWave-Matlab API (Application Programming Interface) and develop examples through tutorials.

Where to start?

The first thing to do is to create the basic structure for a plug-in.
A Matlab Scripted plug-in is very simple, it is a folder containing at least two files.

Let's begin by creating a folder somewhere on the computer, called MyPlugin.
This can be done in MATLAB: create a folder and create a new function called main in that folder.
The main function is MANDATORY. It will be the main function AnyWave will call to execute our plugin.

Matlab1.png

As shown in the image above, a MyPlugin folder has been created and a main function was added.

We are now ready to write our first Matlab plug-in but before doing that we need to cover all the MATLAB functions provided by AnyWave.
Indeed, to get or put data from/to AnyWave, special functions are provided.
We can call that set of functions the AnyWave-MATLAB API.

AnyWave-Matlab functions

The table below shows a summary of all matlab functions available when writing a Matlab Scripted plug-in:
Function parameters placed between <> are optional.

Function Short description
AwGetInputChannels() Get current input channels set by AnyWave for the plug-in.
AwGetData(start, duration, <filtering>, <filteringOptions>) Get the data of the current input channels.
AwGetWorkingDir() Get the full path to a temporary directory created by AnyWave for the plug-in.
AwGetFilePath() Get the full path of the current open data file in AnyWave.
AwAddMarker(value, position, duration, <targeted channels>) Add a marker in AnyWave.
AwSendMessage(message) Send a message to AnyWave. The message will be added to the plug-in's log.

AwGetInputChannels()

AnyWave uses channels to represent signals on screen but also as its internal data set.
When a plug-in is launched by AnyWave, a set of input and/or output parameters is defined.

AwGetInputChannels() will request the list of input channels for the plug-in. No parameters are required.
AnyWave will send back a structure array containing Matlab structures which match structure defined by the AwChannel() function.
AwChannel() is provided by AnyWave to easily create a Matlab structure which will be compatible with AnyWave's channels objects.