Only this pageAll pages
Powered by GitBook
1 of 73

Cortex API

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Connecting to the Cortex API

On Windows and MacOS, the Cortex service is a background process that communicates with the EMOTIV headsets and the EMOTIV cloud. It is also a WebSocket server that uses the JSON-RPC protocol.

WebSocket

Communicate with the Cortex API using the WebSocket Secure protocol.

Create a WebSocket client and connect to localhost on the port 6868, using the wss protocol.

Any WebSocket client should work in any programming language. You can even use a web browser plugin or an online client.

Please note that Cortex only supports the WebSocket Secure (wss) protocol. It doesn't support the plain WebSocket (ws) protocol without encryption.

To try the Cortex API, open a secure WebSocket connection to wss://localhost:6868 and send the message {"id":1,"jsonrpc":"2.0","method":"getCortexInfo"}

Cortex security certificate

The Cortex web socket server uses a self-signed certificate. When you install Emotiv softwares, the installer has already installed the Emotiv Root CA file and ask the system to trust it, so most of the time, your application don't need to configure anything else. However, for some programming languagues or for remote connections to Pi, you must configure a custom Certificate Authorities (CA) to trust Cortex websocket connection.

For example, on Android, you must configure the application like this or if you use python, you can configure the application like this.

Here is the link to the Emotiv Root CA file.

Remote connections

Since 2.7.1 release, we support remote connections to Cortex running on Raspberry Pi device. It requires some steps:

  • Grant the permissions to a desktop machine before an app on that machine can connect to the Cortex web socket server on Raspberry Pi device, using cortexaccess tool.

  • Connect using the IP address:

    • Only applied if the IP address of your Raspberry Pi device is in the below range:

      • 10.[0-1].[0-2].[0-255]

      • 172.[16-17].[0-2].[0-255]

      • 192.168.[0-5].[0-255]

    • Create a WebSocket client and connect to<IP address of Raspberry Pi device>

      on the port 6868, using the wss protocol.

  • Connect using the DNS name:

    • Can be applied for any value of IP address of your Raspberry Pi device.

    • Add this line into the host file of the desktop machine:<IP address of Raspberry Pi device> emotiv-cortex.remote

    • Create a WebSocket client and connect to emotiv-cortex.remote on the port 6868, using the wss protocol.

Please note that websocket server on Raspberry Pi accepts only 1 remote connection at a time (not counting the remote connection from EMOTIVApp).

JSON-RPC

After you have successfully opened the WebSocket connection, communicate with Cortex using the JSON-RPC 2.0 protocol.

Call methods, with or without parameters, and Cortex sends back a result or an error.

Call an API method by sending a JSON object with these fields:

Name

Type

Required

Description

jsonrpc

string

yes

Must be "2.0"

method

string

yes

The name of the API method you want to call

params

object

no

The parameters of the method, if it has any

id

number or string

no

The id of this request. Cortex will include this id into the response message, so you can can match the response with the request

The response from Cortex is a JSON object with these fields:

Name

Type

Description

jsonrpc

string

Is always "2.0"

result

any

If the method is successful, contains the result of the method. The type depends on the method

error

object

If the method failed, contains an error code and an error message

id

number or string

The id you included in the request

Here is a simple fictional example:

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "area",
    "params": {
        "width": 6,
        "length": 7
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": 42
}

Please read the JSON-RPC 2.0 specification for details.

Next step

The rest of this documentation will show you what methods are available, what parameters they take, and how to use these methods.

But first, you should start with the overview of the API flow.

getCortexInfo

This method returns information about the Cortex service, like its version and build number.

Parameters

This method has no parameter.

Result

The result is an object with these fields:

Name

Type

Description

buildDate

string (date time)

The date and time the Cortex binary was built

buildNumber

string

The internal build number

version

string

The version of Cortex. It should have the format "2.y.z"

Example

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getCortexInfo"
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "buildDate":"2019-05-29T14:09:19",
        "buildNumber":"25cf08bd",
        "version":"2.0.0"
    }
}

getUserLogin

Get the current logged in user.

There is no login or logout API in Cortex. Instead, users are required to login through the EMOTIV Launcher.

Parameters

This method has no parameter.

Result

The result is an array of objects, each object describes a logged in user. If no user is logged in, then the result is an empty array.

Please note that currently, Cortex is a single user system. Only one user can login at a time, so the result contains at most one object.

The user object includes these fields:

Name

Type

Description

username

string

The EmotivID of the user

currentOSUId

string

The id of the current OS account

currentOSUsername

string

The user name for currentOSUId

loggedInOSUId

string

The id of the OS account used to login in EMOTIV Launcher

loggedInOSUsername

string

The user name for loggedInOSUId

lastLoginTime

string (ISO datetime)

When this user logged in for the last time.

This field was added in Cortex 2.3.0

If currentOSUId is equal to loggedInOSUId, then the user is already logged in and can work with Cortex. If currentOSUId is different from loggedInOSUId, then a user is logged into Cortex, but from a different OS account. So the user of the current OS account cannot work with Cortex, and must check EMOTIV Launcher.

Examples

No user is logged in

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getUserLogin"
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": []
}

A user is logged in from the current OS account

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getUserLogin"
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [{
        "currentOSUId":"501",
        "currentOSUsername":"jsnow",
        "lastLoginTime": "2019-11-28T12:09:17.300+07:00",
        "loggedInOSUId":"501",
        "loggedInOSUsername":"jsnow",
        "username":"jon.snow"
    }]
}

A user is logged in from another OS account

The application is connected to Cortex that belongs to the OS account 501/jsnow. But someone has already logged in to Cortex from OS account 502/astark with the EmotivID aria.stark. So, the application cannot work with Cortex.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getUserLogin"
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [{
        "currentOSUId":"501",
        "currentOSUsername":"jsnow",
        "lastLoginTime": "2019-11-28T12:09:17.300+07:00",
        "loggedInOSUId":"502",
        "loggedInOSUsername":"astark",
        "username":"aria.stark"
    }]
}

hasAccessRight

Check if your application has been granted access rights or not in EMOTIV Launcher.

Any application that connects to Cortex must request approval from the user through EMOTIV Launcher. See requestAccess for details.

Parameters

Name

Type

Required

Description

clientId

string

yes

The client id of your Cortex application

clientSecret

string

yes

The client secret of your Cortex application

Result

The result is an object containing a boolean value "accessGranted" and a message.

Name

Type

Description

accessGranted

boolean

True, if the user has already approved your application False, if the user declined your application, or didn't approve it yet

message

string

If accessGranted is false, then your application should call requestAccess If accessGranted is true, then no action is required

Examples

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "hasAccessRight",
    "params": {
        "clientId": "xxx",
        "clientSecret": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "accessGranted":true,
        "message":"The User has granted access right to this application."
    }
}

Authentication

After your application is successfully connected to the Cortex service, you must go through the authentication procedure.

First, you should call getUserLogin to check if the user has already logged in though EMOTIV Launcher. Then, you must call requestAccess to ask the user to approve your application.

Finally, call authorize to generate a Cortex token or you can reuse a token that you previously got from this method, if it is not expired.

Overview of API flow

There are a few steps to prepare before you can get the data streaming out from Cortex:

  1. First you have to login to the EMOTIV Launcher with your .

  2. Make sure that you are using the correct application ID, client ID and client secret that you generated from the Account dashboard on Emotiv website in your application ().

  3. Call the API from your app to Cortex, and accept via the EMOTIV Launcher.

  4. After access is granted, connect your EMOTIV brainwear headset via the USB dongle or Bluetooth.

  5. Call the API with "refresh" command to start the headset scanning.

  6. Call the API to list the available headsets.

  7. Call the API with "connect" command to connect to the desire headset.

  8. Call the API to get a Cortex token for subsequence requests.

  9. Call the API to open up a new session and be ready for BCI data streaming.

Getting Started

This documentation contains guidance for developing applications with EMOTIV Cortex - the core piece of technology at EMOTIV which brings the brain computer interface to consumer.

The intended audience is anyone with some programming skills who wants to develop a third party application that interacts with an EMOTIV headset.

The Cortex API is built on JSON and WebSockets, making it easy to access from a variety of programming languages and platforms.

System requirements and supported platforms

Learn more about .

Supported headsets

Currently, Cortex supports the following headsets:

USB dongle refers to the USB receiver that comes with EPOC+. If you need an additional receiver, you can purchase it from the EMOTIV.

Currently, it is not possible to use a MN8 headset with Cortex on Linux Ubuntu.

Prerequisites

Create an EmotivID

As with other EMOTIV services, you are required to have an EmotivID account. You can create an ID on .

License

With a valid EmotivID, you have access to the basic data streams, including:

  • Motion Data

  • Mental Commands

  • Facial Expressions

  • Performance Metrics (low-resolution, 0.1Hz)

  • Frequency Bands

  • Contact Quality

  • Battery Level

A paid subscription will be required for data streams such as:

  • EEG Data

  • Performance Metrics (high-resolution, 2Hz)

A Developer API license is required to access the Raw EEG API and the High-resolution Performance metrics API. Please complete the , and our customer support team will respond as soon as possible with assistance and licensing options.

Visit for more details. If you have questions about the licensing plans please contact the .

Create a Cortex App

Create the application ID and generate the corresponding client ID and client secret for your application in order to grant access to Cortex API.

  1. Login to www.emotiv.com.

  2. Go to My Account Dashboard ().

  3. Select Cortex Apps.

  4. Read the Developers EULA carefully and click Accept only if you agree to all the terms and conditions. You cannot develop an application that works with Cortex if you do not agree to all of the terms.

  5. Enter the name of your new application - an application ID will be generated automatically in the form of com.{your-username}.{application-name}. Note that the app ID string must contain only alphanumeric characters (A-Z, a-z, 0-9), hyphens (-), and periods (.).

  6. (If you have purchased a subscription to the EEG Data API) Decide whether your application requires access to the EEG Data stream. If so, understand that your application will only be available to you until you contact EMOTIV for a deployment license. If your application does not require EEG data then you are entitled to share it with up to 10,000 users before contacting EMOTIV for a deployment license.

  7. (If you have purchased a subscription to the EEG Data API and decided that your application would require access to the EEG Data stream), tick "My App requires EEG access". If you forget this, your application cannot subscribe to EEG stream data later.

  8. Click Register Application. A client ID and a client secret will be presented to you. Copy them to somewhere safe immediately as the client secret will ONLY BE SHOWN ONCE ON THIS SCREEN FOR SECURITY. If you lost it, you will have to generate a new application ID later.

  9. (If you have purchased a subscription to the EEG Data API and decided that your application would require access to the EEG Data stream), make sure you submit this form with necessary information. If you don't submit this form, your applications don't have permission to use the license later.

The Cortex Examples

To help you getting started with your application, EMOTIV provides basic examples in various programming languages. There are open source and hosted by Github at

If you have difficulty with the Cortex API, you can also on this Github repository.

Next Step

If you are upgrading your application from Cortex 1.x to Cortex 2.x, then please be aware that the Cortex API has significantly changed. Please read the for details.

If you are new to the Cortex API, then please start with .

controlDevice

This method is to connect or disconnect a headset. It can also refresh the list of available Bluetooth headsets returned by .

Please note that connecting and disconnecting a headset can take a few seconds.

Before you call on a headset, make sure that Cortex is connected to this headset. You can use to check the connection status of the headset.

This method is not available on iOS. On iOS the user must connect and disconnect the headset in EMOTIV App.

Parameters

Headset Scanning Flow

The app must call controlDevice with "refresh" command to start headset scanning. The timeout of scanning is around 20s. When the scanning finishes, Cortex will send a to the app. When received this warning, if the app still want to scan for headsets, simply call controlDevice with "refresh" command again.

Please note that headset scanning can affect to data stream quality if headset scanning is running at the same time with data stream subscription, so we recommend app developers to design the app so that we only run headset scanning when necessary.

EPOC Flex mapping

The mappings parameter is only to connect an EPOC Flex headset. Use this parameter to tell Cortex how you setup the EEG sensors of your EPOC Flex headset.

The keys for this object must be chosen from this list: "CMS", "DRL", "LA", "LB", "LC", "LD", "LE", "LF", "LG", "LH", "LJ", "LK", "LL", "LM", "LN", "LO", "LP", "LQ", "RA", "RB", "RC", "RD", "RE", "RF", "RG", "RH", "RJ", "RK", "RL", "RM", "RN", "RO", "RP", "RQ".

The keys "CMS" and "DRL" are required.

The values are sensor locations from the international 10-20 system: "Cz", "FCz", "Fz", "Afz", "Fpz", "Fp1", "AF3", "AF7", "F9", "F7", "F5", "F3", "F1", "FC1", "C1", "C3", "FC3", "FC5", "FT7", "FT9", "T7", "C5", "TP9", "TP7", "CP5", "CP3", "CP1", "P1", "P3", "P5", "P7", "P9", "PO9", "PO7", "PO3", "O1", "O9", "CPz", "Pz", "POz", "Oz", "Iz", "O10", "O2", "PO4", "PO8", "PO10", "P10", "P8", "P6", "P4", "P2", "CP2", "CP4", "CP6", "TP8", "TP10", "C6", "T8", "FT10", "FT8", "FC6", "FC4", "C4", "C2", "FC2", "F2", "F4", "F6", "F8", "F10", "AF8", "AF4", "Fp2".

Connection Type

You can use this parameter together with the command "connect", to force Cortex to use the specified connection type. For example, an EPOC+ headset can be connected by dongle or by Bluetooth. If both connections are available on your computer then you may want to set connectionType to "dongle" so you don't accidentally connect the headset with Bluetooth.

Result

The result is an object containing these fields:

When the command is "connect", then the result of this method just tells you that the connection is in progress. You must wait for a warning object with to know that the connection is successful. If the connection fails then you will receive a warning with .

Another way to check if the headset is connected or not is to call and then check the status of the headset.

Examples

Refresh the list of headsets

Use the refresh command to start searching for new Bluetooth headsets.

Then you will receive a when scanning is finished.

Connect an Insight headset

Then you will receive a warning with code 104 if the connection is successful:

Connect an Epoc Flex headset

Disconnect a headset

requestAccess

Request user approval for the current application through .

When your application calls this method for the first time, EMOTIV Launcher displays a message to approve your application. You can call this API many times, but EMOTIV Launcher will prompt the user only once. If the user has already approved your application, then this API does nothing.

Almost all the methods of the API require that your application was approved in EMOTIV Launcher. These methods will return an error if your application wasn't approved.

Any application that connects to Cortex must call this API to request approval from the user through .

Most of the methods of the API will fail if the user didn't approve your application.

Parameters

Result

The result is an object containing a boolean value "accessGranted" and a message.

If accessGranted is false, then your application should ask the user to check EMOTIV Launcher and approve your application. Then you should wait for a while and call this API again. If accessGranted is true, then no action is required.

Examples

Application was already approved

Application is not approved yet, or declined

Name

Type

Required

Description

command

string

yes

The command must be "connect", "disconnect" or "refresh".

headset

string

no

The id of the headset that you want to connect or disconnect. The headset id is returned by queryHeadsets.

If the command is "refresh", then you should omit this parameter.

mappings

object

no

The EEG sensor mapping of the EPOC Flex headset that you want to connect.

If the command is not "connect", or if the headset is not an EPOC Flex, then you should omit this parameter.

connectionType

string

no

If the command is "connect" or "disconnect" then this parameter can be "dongle", "bluetooth" or "usb cable", or you can omit it. If the command is "refresh" then you should omit this parameter.

This parameter was added in Cortex 2.2.1

Name

Type

Description

command

string

The command that you set in the request

message

string

A success message

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "controlDevice",
    "params": {
        "command": "refresh"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "command": "refresh",
        "message": "..."
    }
}
{
    "jsonrpc": "2.0",
    "warning": {
        "code": 142,
        "message": {
            "behavior": "Headset discovering complete."
        }
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "controlDevice",
    "params": {
        "command": "connect",
        "headset": "INSIGHT-12341234"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "command": "connect",
        "message": "Start connecting to headset INSIGHT-12341234"
    }
}
{
    "jsonrpc": "2.0",
    "warning": {
        "code": 104,
        "message": {
            "headsetId": "INSIGHT-12341234",
            "behavior": "The headset is connected"
        }
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "controlDevice",
    "params": {
        "command": "connect",
        "headset": "EPOCFLEX-12341234",
        "mappings": {
            "CMS": "F3",
            "DRL": "F5",
            "LA": "AF3",
            "LB": "AF7",
            "RA": "P8"
        }
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "command": "connect",
        "message": "..."
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "controlDevice",
    "params": {
        "command": "disconnect",
        "headset": "EPOCFLEX-12341234"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "command": "disconnect",
        "message": "..."
    }
}
queryHeadsets
createSession
queryHeadsets
warning with code 142
code 104
code 100, 101, 102 or 113
queryHeadsets
warning with code 142

Name

Type

Required

Description

clientId

string

yes

The client id of your Cortex application

clientSecret

string

yes

The client secret of your Cortex application

Name

Type

Description

accessGranted

boolean

True, if the user has already approved your application False, if the user declined your application, or didn't approve it yet

message

string

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "requestAccess",
    "params": {
        "clientId": "xxx",
        "clientSecret": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "accessGranted":true,
        "message":"The User has granted access right to this application."
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "requestAccess",
    "params": {
        "clientId": "xxx",
        "clientSecret": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "accessGranted":false,
        "message":"The User has not granted access right to this application. Please use Emotiv App to proceed."
    }
}
EMOTIV Launcher
EMOTIV Launcher

Model

Firmware

Connection

EPOC

All

USB dongle

EPOC+

All

USB dongle, BLE 4.0

EPOC X

All

USB dongle, BLE 4.0

Bluetooth® 5.0 will be available with upcoming software and firmware updates

EPOC Flex

All

USB dongle, BLE 4.0

Insight

All

USB dongle, BLE 4.0

Insight 2.0

All

BLE 4.0

MN8

All

BLE 4.0

Flex

All

nRF dongle with BLE 5

the system requirements and support platforms for Cortex
store
www.emotiv.com
SDK application form
https://www.emotiv.com/developer/
EMOTIV Customer Support
https://www.emotiv.com/my-account/
https://account.emotiv.com/cortex-sdk-application-form/
https://github.com/Emotiv/cortex-v2-example
open an issue
release notes
Connecting to the Cortex API
"My App requires EEG access" option (in step 7)

Headsets

After you finish the authentication process, your application should start headset scanning to search for EMOTIV headsets, using the method controlDevice with "refresh" command, then use the method queryHeadsets to get the discovered headsets.

If the headset is not connected to Cortex yet, then you must call controlDevice with "connect" command.

See also Headset object for details.

Sessions

A session is an object that makes the link between your application and an EMOTIV headset. When the user wants to work with a headset, your application should create a session first. Then you can:

  • subscribe to the data stream of the headset

  • create a record and add markers

  • use BCI

Your application can open only one session at a time with a given headset. But it can open multiple sessions with multiple headsets.

Session lifetime

A session is created by createSession and closed by updateSession.

A session is linked to an application. All the sessions of an application are automatically closed when the application is disconnected from the Cortex service. A session is also closed if the headset is disconnected.

A session is a temporary in-memory object, it is not persistent. After a session is closed, it is destroyed by Cortex. If you want to create a persistent object, please create a record inside your session. See Records for details.

Session activation

When you create a session, you can activate it or leave as is.

If the session is not activated, then it doesn't use the license of the user. You cannot subscribe to the EEG stream and you are limited to the low resolution performance metrics. You can neither create a record nor markers.

If the session is activated, then it uses the license of the user. Depending on the license scope of the license, you can subscribe to the EEG stream or high resolution performance metrics. If the license has a session quota, then this session will be debited from this quota.

Use querySessions and check the field status to know if a session was activated or not.

EmotivID
see here
requestAccess
controlDevice
queryHeadsets
controlDevice
authorize
createSession

syncWithHeadsetClock

This method lets you synchronize the monotonic clock of your application with the monotonic clock of Cortex. It is an important step if you want to inject markers with a high precision.

Cortex uses a different clock for each headset and it initializes this clock when the headset is connected by Bluetooth or USB dongle. This means that:

  • You must call “syncWithHeadsetClock” after the headset is connected, not before.

  • You must provide a headset id.

  • If the headset is disconnected and connected again, then you must call this method again.

The simplest solution is to call this method just before creating a record.

Use Case

Cortex sets the timestamps of each EEG sample using the monotonic clock of the computer. It is more reliable than using the system clock, because the system clock is subject to unpredictable variations, notably because of the NTP synchronization.

When you add a marker to a record, Cortex uses the parameter "time" of your request to associate the marker with the EEG sample that has the closest timestamp. So if you want to have accurate markers, you should set the time of your markers using the monotonic clock, not the system clock.

Most programing languages provide a function to get a monotonic time. But in general, the point of origin of this time is undefined. So you need to synchronize the monotonic clock of your application with the monotonic clock used by Cortex. This is the purpose of this Cortex API method.

Parameters

This method takes 3 parameters:

Name
Type
Required
Description

headset

string

yes

The headset id.

Use to list available headsets.

monotonicTime

number

yes

The monotonic time of your application. The unit is in seconds. The origin can be anything.

You should get this time right before you call this API.

systemTime

number

yes

The system time of your application. It must be the number of seconds that have elapsed since 00:00:00 Thursday, 1 January 1970 UTC.

You should get this time right before you call this API.

Result

The result is a JSON object with these fields:

Name
Type
Description

headset

string

The headset id.

adjustment

number

The difference between the monotonic clock of your application and the monotonic clock of the headset.

The unit is in seconds.

To synchronize your clock, you must add the “adjustment” to your monotonic times. If the “adjustment” is positive, then it means your clock is late compared to the Cortex clock. If the “adjustment” is negative, then your clock is ahead of the Cortex clock.

Example

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "syncWithHeadsetClock",
  "params": {
    "headset": "INSIGHT-587XX4BB",
    "monotonicTime": 321.445,
    "systemTime": 1629978090.302
  }
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "adjustment": 1629977768.86108,
    "headset": "INSIGHT-587XX4BB"
  }
}

getUserInformation

This method returns basic information about the current user.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by

Result

The result is an object containing basic information about the user.

Name

Type

Description

username

string

The EmotivID of the user

firstName

string

The first name of the user

lastName

string

The last name of the user

licenseAgreement

object

An object that contain information about the EULA agreement

Examples

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getUserInformation",
    "params": {
        "cortexToken": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "username": "jon.snow",
        "firstName": "Jon",
        "lastName": "Snow",
        "licenseAgreement": {
            "accepted": true,
            "licenseUrl": "https://..."
        }
    }
}

authorize

This method is to generate a Cortex access token. Most of the methods of the Cortex API require this token as a parameter.

Application can specify the license key and the amount of sessions to be debited from the license and use them locally.

The token is linked to your application. It cannot be used with another application. The token is also linked to the EmotivID of the current user. It cannot be used with another EmotivID. So if the user logs out in EMOTIV Launcher, and then logs in with another EmotivID, your application must call this API again to get a new token.

Your application can save the Cortex token and reuse it later, within 2 days. Note that it is the responsibility of the application to secure the token.

If the user has not accepted the EULA, then a warning message will be included in the response as well. The user must accept the EULA through EMOTIV Launcher.

Before you call this method, the user must approve your application in EMOTIV Launcher. See requestAccess for details.

The Cortex token must remain secret. Do NOT share it. It is your responsibility to keep it secure.

Parameters

Name

Type

Required

Description

clientId

string

yes

The client id of your Cortex application.

clientSecret

string

yes

The client secret of your Cortex application.

license

string

no

A license id. In most cases, you don't need to specify the license id. Cortex will find the appropriate license based on the client id.

debit

number

no

Number of sessions to debit from the license, so that it can be spent locally without having to authorize again. You need to debit the license only if you want to . The default value is zero.

Result

The result is an object containing a field cortexToken. It may also include a field warning, if the user didn't accept the EULA.

Name

Type

Description

cortexToken

string

The Cortex token of the user

warning

object

Contains a message and the URL to accept the EULA

Examples

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "authorize",
    "params": {
        "clientId": "xxx",
        "clientSecret": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "cortexToken":"xxx",
        "warning": {
            "code": 6,
            "message": "...",
            "licenseUrl": "https://..."
        }
    }
}

getLicenseInfo

This method returns information about the license currently used by your application.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by

Result

The result is an object containing a license object and the isOnline flag.

Name

Type

Description

license

object

An object containing all the information about the current license

isOnline

boolean

True, if Cortex was able to get the license information from the EMOTIV cloud

False, if Cortex got the license information for its local cache

Example

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getLicenseInfo",
    "params": {
        "cortexToken": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "isOnline":true,
        "license":{
            "applications":["com.emotiv.emotivpro"],
            "billingFrom":"2018-08-23T07:00:00.000+07:00",
            "billingTo":"2019-09-23T07:00:00.000+07:00",
            "deviceInfo":{
                "deviceLimit":15,
                "devicesPerSeat":3,
                "sessionLimit":{"day":null,"month":null,"year":null}
            },
            "expired":false,
            "extenderLimit":30,
            "hardLimitTime":"2019-07-01T06:59:59.999+07:00",
            "isCommercial":false,
            "licenseId":"xxx",
            "licenseName":"PRO license",
            "localQuota":0,
            "maxDebit":null,
            "scopes":["eeg","pm"],
            "seatCount":5,
            "sessionCount":0,
            "softLimitTime":"2019-06-24T06:59:59.999+07:00",
            "totalDebit":0,
            "totalRegisteredDevices":1,
            "validFrom":"2018-08-23T07:00:00.000+07:00",
            "validTo":"2019-09-24T06:59:59.999+07:00"
        }
    }
}

generateNewToken

This method uses a Cortex token to generate a new Cortex token. You can use this method to extend the expiration date of a token.

See authorize for details.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by

clientId

string

yes

The client id of your Cortex application

clientSecret

string

yes

The client secret of your Cortex application

Result

The result is an object containing a field cortexToken.

Name

Type

Description

cortexToken

string

The new Cortex token of the user

Example

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "generateNewToken",
    "params": {
        "cortexToken": "xxx",
        "clientId": "...",
        "clientSecret": "..."
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "cortexToken": "yyy"
    }
}

Session object

A session is the link between your application and a headset.

You must create a session before you call subscribe to receive data from a headset. See createSession.

Description

A session object includes these fields:

Name

Type

Description

id

string

The id of this session.

status

string

Can be "opened", "activated", or "closed".

owner

string

The EmotivID of the user.

license

string

The id of the license used by this session. Or an empty string if the session wasn't activated.

appId

string

The application id of your Cortex app.

started

string (ISO datetime)

When this session was created.

stopped

string (ISO datetime)

When this session was closed.

streams

array of strings

The data streams you subscribed to. See .

recordIds

array of strings

The ids of all the records created by this session. See .

recording

boolean

True if a record is currently in progress for this session. False otherwise.

headset

object

A . It contains information about the headset linked to this session.

Status

The status is linked to the license. If the session is activated, it will be debited from the quota of the user's license.

Status

Description

opened

The session was created with , but it doesn't use a license. You can activate or close this session with .

activated

The session was activated with a license. You can close this session with .

closed

This session is closed, you cannot use it anymore.

Examples

A session with an Epoc+ headset. It is not activated. We subscribed to the performance metrics and motion data.

{
    "id": "8bfc26de-754b-4c1f-9771-acfd1a7da02c",
    "status": "opened",
    "owner": "jon.snow",
    "license": "",
    "appId": "com.jon.snow.winterfell-app",
    "started": "2019-05-29T14:18:45.108+07:00",
    "stopped": "",
    "headset": {
        "status": "connected"
        "connectedBy": "dongle",
        "customName": "",
        "dongle": "6ff",
        "firmware": "625",
        "id": "EPOCPLUS-3B9AXXXX",
        "motionSensors": [
            "GYROX",
            "GYROY",
            "GYROZ",
            "ACCX",
            "ACCY",
            "ACCZ",
            "MAGX",
            "MAGY",
            "MAGZ"
        ],
        "sensors": [
            "AF3",
            "F7",
            "F3",
            "FC5",
            "T7",
            "P7",
            "O1",
            "O2",
            "P8",
            "T8",
            "FC6",
            "F4",
            "F8",
            "AF4"
        ],
        "settings": {
            "eegRate": 256,
            "eegRes": 16,
            "memsRate": 64,
            "memsRes": 16,
            "mode": "EPOCPLUS"
        }
    },
    "recordIds": [],
    "recording": false,
    "streams": ["met","mot"]
}

updateHeadset

This method lets you change the settings of an EPOC+ or EPOC X headset.

You can configure the EEG sample rate, EEG resolution, motion data sample rate, and motion data resolution. You can check the current settings of a headset using the method queryHeadsets.

This method is for EPOC+ and EPOC X headsets only. There are no configuration settings for other EMOTIV headsets.

Please note that updating the configuration of a headset can take a few seconds.

The user must connect the headset to the computer by using a USB cable before calling this method. You can't configure the headset through a wireless connection. You can use queryHeadsets to check how the headset is connected.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

headset

string

yes

A headset id returned by .

setting

object

yes

An object containing the setting to apply. See below.

The setting parameter must be an object with these fields:

Name

Type

Required

Description

mode

string

yes

Must be "EPOC" or "EPOCPLUS".

In "EPOC" mode, the EEG resolution is 14 bits.

In "EPOCPLUS" mode, the EEG and motion resolutions are 16 bits.

eegRate

number

yes

The EEG sample rate, in hertz. If the mode is "EPOC", then the EEG rate must be 128.

If the mode is "EPOCPLUS", then the EEG rate can be 128 or 256.

memsRate

number

yes

The motion sample rate, in hertz.

If the mode is "EPOC", then the motion rate must be 0.

If the mode is "EPOCPLUS", then the motion rate can be 0, 32, 64 or 128.

A motion rate of zero means that the motion sensors are disabled.

Result

The result is an object containing these fields:

Name

Type

Description

headsetId

string

The headset id you set in the parameters.

message

string

A success message.

In Cortex 2.3.0 and earlier, you just need to check the result of the method. If the method doesn't return any error, then it means that the update is successful.

However, since Cortex 2.4.0, the result of the method just tells you that the update is in progress. You must wait for a warning object with code 110 or 111 to know if the update is successful or not.

If your configuration is not compatible with a Bluetooth connection then you will receive a warning with code 112. Your configuration will work fine with a USB dongle. To use the headset with a Bluetooth connection, you must set the EEG rate to 128Hz and disable the motion sensors.

Examples

Set the EEG rate to 256 hertz (16 bits) and the motion rate to 64 hertz (16bits)

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "updateHeadset",
    "params": {
        "cortexToken": "xxx",
        "headsetId": "EPOCPLUS-3B9AXXXX",
        "setting": {
            "mode": "EPOCPLUS",
            "eegRate": 256,
            "memsRate": 64
        }
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "headsetId": "EPOCPLUS-3B9AXXXX",
        "message": "..."
    }
}

Set the EPOC+ headset in EPOC mode, EEG rate at 128 hertz (14 bits) and disable the motion sensors.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "updateHeadset",
    "params": {
        "cortexToken": "xxx",
        "headsetId": "EPOCPLUS-3B9AXXXX",
        "setting": {
            "mode": "EPOC",
            "eegRate": 128,
            "memsRate": 0
        }
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "headsetId": "EPOCPLUS-3B9AXXXX",
        "message": "..."
    }
}

updateHeadsetCustomInfo

This method lets you set the headband position of an EPOC X headset.

The headband position is important to interpret the motion data coming from the headset. The motion sensor is located in the headband. So Cortex uses the headband position to know the orientation of the motion sensor.

When you start a record Cortex saves the current headband position into the record. So you should set the position before starting the record.

This method was added in Cortex 2.4

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

headsetId

string

yes

A headset id returned by .

headbandPosition

string

yes

Must be "back" or "top".

Result

The result is an object containing these fields:

Name

Type

Description

headsetId

string

The headset id used in the request.

customName

string

The custom name of the headset.

headbandPosition

string

The position of the headband. Can be "back" or "top".

Examples

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "updateHeadsetCustomInfo",
  "params": {
    "cortexToken": "xxx",
    "headbandPosition": "top",
    "headsetId": "EPOCX-12345678"
  }
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "customName": "Epoc 1",
    "headbandPosition": "top",
    "headsetId": "EPOCX-12345678",
    "message": "Update headset customized information successfully."
  }
}

Headset object

Some methods of the API return one or more headset objects, for example queryHeadsets. A session object also includes a headset object.

Description

A headset object include these fields:

Name

Type

Description

id

string

The id of this headset.

status

string

Can be "discovered", "connecting", or "connected".

connectedBy

string

Can be "bluetooth", "dongle", "usb cable", or "extender".

dongle

string

The version of the dongle firmware.

firmware

string

The version of the headset firmware.

motionSensors

array of strings

The names of the motion sensors of this headset.

sensors

array of strings

The names of the EEG sensors of this headset. Use the international 10-20 system.

settings

object

An object containing the configuration of the EEG and motion data of this headset.

flexMappings

object

If the headset is an EPOC Flex, then this field is an object containing information about the mapping of the EEG channels.

headbandPosition

string

If the headset is an EPOC X, then this field tells you the position of the headband of this headset. Can be "back" or "top". If the headset is not an EPOC X, then this field is null. See for details.

This field was added in Cortex 2.4

customName

string

The custom name of the headset. The user can set it in EMOTIV App.

This field was added in Cortex 2.4

Status

When you want to work with a headset, it is important to check its status.

Status

Description

discovered

Cortex has detected the headset, but it is not connected. You cannot create a session for a discovered headset. You can call to connect the headset.

connecting

Cortex is trying to connect to this headset. This can take a few seconds.

connected

Cortex is connected to and receives data from this headset. You can call and start working with this headset.

You can call to disconnect the headset.

Settings

The settings object include these fields:

Name

Type

Description

mode

string

Can be "EPOC", "EPOCPLUS", or "EPOCFLEX"

eegRate

number

The EEG sample rate, in hertz.

eegRes

number

The EEG resolution, in bits.

memsRate

number

The motion data sample rate, in hertz.

memsRes

number

The motion data resolution, in bits.

For an Epoc+ headset, the mode can be "EPOC" or "EPOCPLUS", depending on its configuration. See updateHeadset for details. For an Insight or Epoc headset, the mode is always "EPOC". For an Epoc Flex headset, the mode is always "EPOCFLEX".

A motion rate of zero means that the motion sensors are disabled.

Flex Mapping

Currently, the flexMappings object contains a single field. It may include more fields in the future.

Name

Type

Description

mappings

object

Describe which EEG channel is mapped to which physical connector of EPOC Flex device. The keys are the names of the connectors, the values are the names of the EEG channels.

Example: { "CMS": "TP8", "DRL": "P6", "RM": "TP10", "RN": "P4", "RO": "P8" }

Examples

Insight

{
  "id": "INSIGHT-AAAA0000",
  "status": "connected",
  "connectedBy": "dongle",
  "customName": "",
  "dongle": "6ff",
  "firmware": "930",
  "motionSensors": [
    "Q0",
    "Q1",
    "Q2",
    "Q3",
    "ACCX",
    "ACCY",
    "ACCZ",
    "MAGX",
    "MAGY",
    "MAGZ"
  ],
  "sensors": [
    "AF3",
    "T7",
    "Pz",
    "T8",
    "AF4"
  ],
  "settings": {
    "eegRate": 128,
    "eegRes": 14,
    "memsRate": 64,
    "memsRes": 14,
    "mode": "INSIGHT"
  }
}

Epoc+

{
    "id": "EPOCPLUS-3B9AXXXX",
    "status": "connected",
    "connectedBy": "dongle",
    "customName": "",
    "dongle": "6ff",
    "firmware": "625",
    "motionSensors": [
        "GYROX",
        "GYROY",
        "GYROZ",
        "ACCX",
        "ACCY",
        "ACCZ",
        "MAGX",
        "MAGY",
        "MAGZ"
    ],
    "sensors": [
        "AF3",
        "F7",
        "F3",
        "FC5",
        "T7",
        "P7",
        "O1",
        "O2",
        "P8",
        "T8",
        "FC6",
        "F4",
        "F8",
        "AF4"
    ],
    "settings": {
        "eegRate": 256,
        "eegRes": 16,
        "memsRate": 64,
        "memsRes": 16,
        "mode": "EPOCPLUS"
    }
}

queryHeadsets

Shows details of any headsets connected to the device via USB dongle, USB cable, or Bluetooth. You can query a specific headset by its id, or you can specify a wildcard for partial matching.

Parameters

Name

Type

Required

Description

id

string

No

A headset id or a wildcard

includeFlexMappings

boolean

No

Set this parameter to true to include the mapping of each EPOC FLEX headset in the result .

For the parameter id, you can use these wildcards:

Wildcard

Filter

INSIGHT-*

All Insight headsets

EPOC-*

All Epoc headsets

EPOCPLUS-*

All Epoc Plus headsets

Result

The result is an array of headset objects, or an empty array if no headset matches the request.

Examples

Query all the headsets

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "queryHeadsets"
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "connectedBy": "dongle",
            "customName": "",
            "dongle": "6ff",
            "firmware": "625",
            "id": "EPOCPLUS-3B9AXXXX",
            "motionSensors": [
                "GYROX",
                "GYROY",
                "GYROZ",
                "ACCX",
                "ACCY",
                "ACCZ",
                "MAGX",
                "MAGY",
                "MAGZ"
            ],
            "sensors": [
                "AF3",
                "F7",
                "F3",
                "FC5",
                "T7",
                "P7",
                "O1",
                "O2",
                "P8",
                "T8",
                "FC6",
                "F4",
                "F8",
                "AF4"
            ],
            "settings": {
                "eegRate": 256,
                "eegRes": 16,
                "memsRate": 64,
                "memsRes": 16,
                "mode": "EPOCPLUS"
            },
            "status": "connected"
        }
    ]
}

If no headset matches your request, then the result is an empty array.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "queryHeadsets"
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": []
}

Query a headset by its id

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "queryHeadsets",
    "params": {
        "id": "EPOCPLUS-3B9AXXXX"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "connectedBy": "dongle",
            "customName": "",
            "dongle": "6ff",
            "firmware": "625",
            "id": "EPOCPLUS-3B9AXXXX",
            "motionSensors": [
                "GYROX",
                "GYROY",
                "GYROZ",
                "ACCX",
                "ACCY",
                "ACCZ",
                "MAGX",
                "MAGY",
                "MAGZ"
            ],
            "sensors": [
                "AF3",
                "F7",
                "F3",
                "FC5",
                "T7",
                "P7",
                "O1",
                "O2",
                "P8",
                "T8",
                "FC6",
                "F4",
                "F8",
                "AF4"
            ],
            "settings": {
                "eegRate": 256,
                "eegRes": 16,
                "memsRate": 64,
                "memsRes": 16,
                "mode": "EPOCPLUS"
            },
            "status": "connected"
        }
    ]
}

Query all the Insight headsets

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "queryHeadsets",
    "params": {
        "id": "INSIGHT-*"
    }
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": [
    {
      "id": "INSIGHT-AAAA0000",
      "status": "connected",
      "connectedBy": "dongle",
      "customName": "",
      "dongle": "6ff",
      "firmware": "930",
      "headbandPosition": null,
      "motionSensors": [
        "Q0",
        "Q1",
        "Q2",
        "Q3",
        "ACCX",
        "ACCY",
        "ACCZ",
        "MAGX",
        "MAGY",
        "MAGZ"
      ],
      "sensors": [
        "AF3",
        "T7",
        "Pz",
        "T8",
        "AF4"
      ],
      "settings": {
        "eegRate": 128,
        "eegRes": 14,
        "memsRate": 64,
        "memsRes": 14,
        "mode": "INSIGHT"
      }
    }
  ]
}

subscribe

This method is to subscribe to one or more data streams. You can call to cancel a subscription. After you successfully subscribe to a stream, Cortex will keep sending you .

See for details.

Parameters

The parameter streams must contain one or more values, chosen from this list: "eeg", "mot", "dev", "eq", "pow", "met", "com", "fac", "sys". See for details.

To subscribe to the "eeg" stream, you must have a paid license and the session.

Result

The result is an object that includes these fields:

In case of success, you get an object with these fields:

Please note that the field cols is especially important. This field tells you which values you will get in the data stream, and in which order. See for details.

In case of failure, you get an object with these fields:

Examples

Subscribe successfully to motion and performance metrics.

Subscribe successfully to performance metrics, but fail to subscribe to raw EEG.

querySessions

This method returns the list of the sessions created by the current application. You can create a session with .

New in 2.0: Sessions are now temporary in-memory objects. So this methods only returns the current sessions, not your past sessions. See for details.

Parameters

Result

The result is an array of .

Example

updateSession

This method is to activate or close a session. See for details.

Parameters

Result

The result is a representing the updated session.

Examples

Activate a session

Close a session

createSession

This method is to open a session with an EMOTIV headset.

To open a session with a headset, the status of the headset must be "connected". If the status is "discovered", then you must call to connect the headset. You cannot open a session with a headset connected by a USB cable. You can use to check the status and connection type of the headset.

You can use to activate or close a session.

See for details.

Make sure the headset has the status "connected" before you call this method. Use to check the status of the headset.

Parameters

If the status is "open", then the session won't be activated. You can activate the session later by calling .

Result

The result is a representing the created session.

Examples

Open a session.

Open a session and activate it.

unsubscribe

This method is to cancel a subscription that was previously created by the method.

Parameters

The parameter streams must contain one or more values, chosen from this list: "eeg", "mot", "dev", "pow", "met", "com", "fac", "sys". See for details.

Result

The result is an object that includes these fields:

In case of success, you get an object with these fields:

In case of failure, you get an object with these fields:

Examples

Unsubscribe successfully from the performance metrics and motion streams.

createRecord

This method is to create a new record.

You must create and activate a session before you call this method. See for details.

Parameters

Result

The result is an object containing two fields:

Examples

queryHeadset
authorize
activate a session
authorize
authorize
subscribe
createRecord
headset object
createSession
updateSession
updateSession
authorize
queryHeadsets
authorize
queryHeadsets
updateHeadsetCustomInfo
controlDevice
createSession
controlDevice
headset object

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

session

string

yes

A session id returned by createSession.

streams

array of strings

yes

The data streams you want to subscribe to.

Name

Type

Description

success

array of objects

For each stream you successfully subscribed to, this array contains an object that describe the data structure of this stream.

failure

array of objects

For each stream you failed to subscribed to, this array contains an object that describes the error.

Name

Type

Description

streamName

string

The name of the stream.

cols

array of strings

The labels of the columns that are part of this stream.

sid

string

The session id.

Name

Type

Description

streamName

string

The name of the stream.

code

number

The error code.

message

string

The error message.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "subscribe",
    "params": {
        "cortexToken": "xxx",
        "session": "f8cb7289-9a92-438b-8281-e5fdffe8166e",
        "streams": ["met","mot"]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "failure": [],
        "success": [
            {
                "cols": ["eng","exc","lex","str","rel","int","foc"],
                "sid": "f8cb7289-9a92-438b-8281-e5fdffe8166e",
                "streamName": "met"
            },
            {
                "cols": [
                    "COUNTER_MEMS",
                    "INTERPOLATED_MEMS",
                    "GYROX",
                    "GYROY",
                    "GYROZ",
                    "ACCX",
                    "ACCY",
                    "ACCZ",
                    "MAGX",
                    "MAGY",
                    "MAGZ"
                ],
                "sid": "f8cb7289-9a92-438b-8281-e5fdffe8166e",
                "streamName": "mot"
            }
        ]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "subscribe",
    "params": {
        "cortexToken": "xxx",
        "session": "49eb6cb0-9df6-414a-b3e8-cfa17198daa0",
        "streams": ["met","eeg"]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "failure": [
            {
                "code": -32016,
                "message": "The stream is unavailable or unsupported.",
                "streamName": "eeg"
            }
        ],
        "success": [
            {
                "cols": ["eng","exc","lex","str","rel","int","foc"],
                "sid": "49eb6cb0-9df6-414a-b3e8-cfa17198daa0",
                "streamName": "met"
            }
        ]
    }
}
unsubscribe
data sample objects
Data Subscription
Data Subscription
activate
Data sample object

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

status

string

yes

Must be "open" or "active".

headset

string

no

A headset id returned by queryHeadsets. If you omit this parameter, then Cortex will use the first connected headset.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "createSession",
    "params": {
        "cortexToken": "xxx",
        "headset": "EPOCPLUS-3B9AXXX",
        "status": "open"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "appId": "com.jon.snow.winterfell-app",
        "headset": {
            "connectedBy": "dongle",
            "customName": "",
            "dongle": "6ff",
            "firmware": "625",
            "id": "EPOCPLUS-3B9AXXXX",
            "motionSensors": [
                "GYROX",
                "GYROY",
                "GYROZ",
                "ACCX",
                "ACCY",
                "ACCZ",
                "MAGX",
                "MAGY",
                "MAGZ"
            ],
            "sensors": [
                "AF3",
                "F7",
                "F3",
                "FC5",
                "T7",
                "P7",
                "O1",
                "O2",
                "P8",
                "T8",
                "FC6",
                "F4",
                "F8",
                "AF4"
            ],
            "settings": {
                "eegRate": 256,
                "eegRes": 16,
                "memsRate": 64,
                "memsRes": 16,
                "mode": "EPOCPLUS"
            },
            "status": "connected"
        },
        "id": "8bfc26de-754b-4c1f-9771-acfd1a7da02c",
        "license": "",
        "owner": "jon.snow",
        "recordIds": [],
        "recording": false,
        "started": "2019-05-29T14:18:45.108+07:00",
        "status": "opened",
        "stopped": "",
        "streams": []
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "createSession",
    "params": {
        "cortexToken": "xxx",
        "headset": "EPOCPLUS-3B9AXXX",
        "status": "active"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
    }
}
controlDevice
queryHeadsets
updateSession
Sessions
queryHeadsets
updateSession
session object

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

session

string

yes

A session id returned by createSession.

streams

array of strings

yes

The data streams you want to unsubscribe to.

Name

Type

Description

success

array of objects

For each stream you successfully unsubscribed to, this array contains an object with the name of the stream.

failure

array of objects

For each stream you failed to unsubscribed to, this array contains an object that describes the error.

Name

Type

Description

streamName

string

The name of the stream.

Name

Type

Description

streamName

string

The name of the stream.

code

number

The error code.

message

string

The error message.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "unsubscribe",
    "params": {
        "cortexToken": "xxx",
        "session": "c6b52ab2-8828-412c-b1b9-9c48842dc0c2",
        "streams": ["met","mot"]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "failure":[],
        "success":[
            {"streamName":"met"},
            {"streamName":"mot"}
        ]
    }
}
subscribe
Data Subscription

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

session

string

yes

A session id returned by createSession.

title

string

yes

The title of the record. Must be 200 characters or less.

description

string

no

The description of the record.

subjectName

string

no

The name of a subject created by createSubject. The subject is the person wearing the headset during the record. If you omit this field, then Cortex assumes that the current user is using the headset.

tags

array of strings

no

A list of tags you can associate to this record. You can use queryRecords to search the records by tags.

experimentId

number (integer)

no

An experiment id you can associate to this record. If you omit this parameter then the experimentId of the record will be zero.

This parameter was added in Cortex 2.2.1

Name

Type

Description

record

object

A record object that represents the created record.

sessionId

string

The id of the session this record is linked to.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "createRecord",
    "params": {
        "cortexToken": "xxx",
        "session": "1067dc90-eb17-489b-9514-69cb79ac696c",
        "title": "Cortex Examples C++"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "record": {
            "uuid": "222eb845-bc44-4a01-bf28-07445a7c7e8a",
            "applicationId": "com.jon.snow.winterfell-app",
            "applicationVersion": "1.0",
            "description": "",
            "endDatetime": "",
            "experimentId": 0,
            "licenseId": "xxx",
            "licenseScope": ["pm","eeg"],
            "ownerId": "76c3468a-d9c0-428d-81b4-bdac5d63860e",
            "startDatetime": "2019-05-31T11:06:24.398560+07:00",
            "tags": [],
            "title": "Cortex Examples C++"
        },
        "sessionId": "1067dc90-eb17-489b-9514-69cb79ac696c"
    }
}
createSession

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

createSession
Sessions
session objects
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "querySessions",
    "params": {
        "cortexToken": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [{
        "id": "8bfc26de-754b-4c1f-9771-acfd1a7da02c",
        "owner": "jon.snow",
        "license": "",
        "appId": "com.jon.snow.winterfell-app",
        "started": "2019-01-29T14:18:45.108+07:00",
        "stopped": "",
        "status": "opened",
        "headset": {
            "connectedBy": "dongle",
            "customName": "",
            "dongle": "6ff",
            "firmware": "625",
            "id": "EPOCPLUS-3B9AXXXX",
            "motionSensors": [
                "GYROX",
                "GYROY",
                "GYROZ",
                "ACCX",
                "ACCY",
                "ACCZ",
                "MAGX",
                "MAGY",
                "MAGZ"
            ],
            "sensors": [
                "AF3",
                "F7",
                "F3",
                "FC5",
                "T7",
                "P7",
                "O1",
                "O2",
                "P8",
                "T8",
                "FC6",
                "F4",
                "F8",
                "AF4"
            ],
            "settings": {
                "eegRate": 256,
                "eegRes": 16,
                "memsRate": 64,
                "memsRes": 16,
                "mode": "EPOCPLUS"
            },
            "status": "connected"
        },
        "recordIds": [],
        "recording": false,
        "streams": ["met"]
    }]
}

Name

Type

Required

Description

cortexToken

string

yes

The token returned by authorize.

session

string

yes

A session id returned by createSession.

status

string

yes

Must be "active" or "close".

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "updateSession",
    "params": {
        "cortexToken": "xxx",
        "session": "38fef6d7-979b-420b-aa25-dd60ef5edc02",
        "status": "close"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "appId": "com.jon.snow.winterfell-app",
        "headset": {
            "connectedBy": "dongle",
            "customName": "",
            "dongle": "6ff",
            "firmware": "925",
            "id": "INSIGHT-5A68XXXX",
            "motionSensors": [
                "GYROX",
                "GYROY",
                "GYROZ",
                "ACCX",
                "ACCY",
                "ACCZ",
                "MAGX",
                "MAGY",
                "MAGZ"
            ],
            "sensors": [
                "AF3",
                "T7",
                "Pz",
                "T8",
                "AF4"
            ],
            "settings": {
                "eegRate": 128,
                "eegRes": 14,
                "memsRate": 128,
                "memsRes": 14,
                "mode": "UNKNOWN"
            },
            "status": "connected"
        },
        "id": "38fef6d7-979b-420b-aa25-dd60ef5edc02",
        "license": "xxx",
        "owner": "jon.snow",
        "recordIds": [
            "d8fe7658-71f1-4cd6-bb5d-f6775b03438f"
        ],
        "recording": false,
        "started": "2019-06-06T11:41:53.168+07:00",
        "status": "closed",
        "stopped": "2019-06-06T11:42:23.531+07:00",
        "streams": []
    }
}
Sessions
session object
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "updateSession",
    "params": {
        "cortexToken": "xxx",
        "session": "38fef6d7-979b-420b-aa25-dd60ef5edc02",
        "status": "active"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "id": "38fef6d7-979b-420b-aa25-dd60ef5edc02",
        "status":"activated",
        ...
    }
}

Records

After you opened a session with a headset, you can create a record. A record is a permanent object to store data from an EMOTIV headset. You can associate a subject to a record. You can add one or more markers to a record.

Unlike a session, a record is a permanent object. It is stored on the hard drive and then can be synchronized to the EMOTIV cloud. The opt-out configuration can let you decide if the records of a user are uploaded to the cloud or not.

Record lifetime

First, you must open a session with a headset. Then you call createRecord to start a new record. When the record is in progress, you can add markers to this record. You stop a record with updateRecord.

The record is linked to the session, so if you close the session, or if your application is disconnected from the Cortex service, then Cortex will automatically close the record.

After you stop the record you can export its data to a CSV or EDF file using exportRecord.

Data sample object

After you successfully subscribe to a data stream, Cortex will keep sending you data sample objects. See Data Subscription for details.

A data sample object contains these fields:

Name

Type

Description

<stream>

array

The name of this field is the name of the data stream, for example "eeg", "met", "com"...

This array contains the values of a data sample. The type and meaning of each value depend on the stream.

sid

string

The session id used to subscribe to this data stream.

time

number

The timestamp of this sample. It is the number of seconds that have elapsed since 00:00:00 Thursday, 1 January 1970 UTC.

To interpret the values in the <stream> array, you must check the field cols from the result of the subscribe method.

How to interpret the values

Suppose you want to get the mental command stream. You successfully subscribe to the stream "com", and you receive this response:

{
    "id":8,
    "jsonrpc":"2.0",
    "result":{
        "failure":[],
        "success":[{
            "cols":["act","pow"],
            "sid":"7f899d66-442b-4bf4-9752-ed06d57b72c3",
            "streamName":"com"
        }]
    }
}

The important part is the field cols:

["act","pow"]

So, the labels for the mental command samples are "act" (action) and "pow" (power), in this order. Then you will receive some mental command samples. They look like this:

{
    "com": ["push", 0.376],
    "sid": "7f899d66-442b-4bf4-9752-ed06d57b72c3",
    "time": 1559900743.3318
}

The values in the array com match the labels in the array cols. So "push" is the value for "act" , and 0.376 is the value for "pow".

Below is the description of the labels used in each data stream.

EEG

The stream "eeg" uses these labels:

Label

Type

Description

COUNTER

number

Increment by 1 for each sample, reset to zero every second.

INTERPOLATED

number

0 if this sample was received from the headset. 1 if this sample was interpolated by Cortex.

<EEG sensors>

number

For each EEG sensor, you get 1 value in microvolt.

RAW_CQ

number

Raw value of the contact quality.

MARKER_HARDWARE

number

1 if a hardware marker was received for this EEG sample.

0 otherwise.

MARKERS

array of objects

An array of . It includes the markers sent by all the applications working with this headset.

This label was added in Cortex 2.1

The maker objects include these fields:

Name

Type

Description

applicationId

string

The id of the application that created this marker.

recordId

string

The id of the record this marker belongs to.

markerId

string

The id of this marker.

value

string or number

The value of this marker, set by .

label

string

The label of this marker, set by .

port

string

The port of this marker, set by .

isStop

boolean

False if this is an instance marker.

True if this marks the end of an interval marker.

Example for an INSIGHT:

[
  "COUNTER",
  "INTERPOLATED",
  "AF3","T7","Pz","T8","AF4",
  "RAW_CQ",
  "MARKER_HARDWARE",
  "MARKERS"
]
{
  "eeg": [
    8,
    0,
    4202.051, 4235.385, 4146.667, 4210.769, 4108.718,
    0,
    0,
    []
  ],
  "sid": "8bbc58bd-0ab1-404e-b472-dac1322dbe5b",
  "time": 1590402103.9016
}

Example for an EPOC+ or EPOC X:

[
    "COUNTER",
    "INTERPOLATED",
    "AF3","F7","F3","FC5","T7","P7","O1","O2","P8","T8","FC6","F4","F8","AF4",
    "RAW_CQ",
    "MARKER_HARDWARE",
    "MARKERS"
]
{
    "eeg":[
        14,
        0,
        4161.41,4212.051,4135,4161.538,4195,4184.103,4182,
        0,
        0, 
        [{
            "applicationId": "com.emotiv.emotivpro",
            "isStop": false,
            "label": "Blink eye while relaxing",
            "markerId": "cc577d88-f404-482a-9629-3e08a0dbcc02",
            "port": "KeyStroke",
            "recordId": "f3c76112-9b7f-43ab-a906-5c15dc4dd55e",
            "value": 22
        }]
    ],
    "sid":"01e1e0f1-4416-436f-8f9d-5bf21e2e4784",
    "time":1559902873.8976
}

Motion

The stream "mot" uses these labels:

Label

Type

Description

COUNTER_MEMS

number

Increment by 1 for each sample, reset to zero every second.

INTERPOLATED_MEMS

number

0 if this sample was received from the headset. 1 if this sample was interpolated by Cortex.

ACCX, ACCY, ACCZ

number

X, Y, Z axis of the accelerometer.

MAGX, MAGY, MAGZ

number

X, Y, Z axis of the magnetometer.

Q0, Q1, Q2, Q3

number

Quaternions of the gyroscope (newer EMOTIV headsets)

GYROX, GYROY, GYROZ

number

X, Y, Z axis of the gyroscope (older EMOTIV headsets)

Depending on the headset, the labels for the gyroscope will be GYROX, GYROY, GYROZ or the quaternions. You will never get both these labels.

Example for a newer INSIGHT:

[
  "COUNTER_MEMS","INTERPOLATED_MEMS",
  "Q0","Q1","Q2","Q3",
  "ACCX","ACCY","ACCZ",
  "MAGX","MAGY","MAGZ"
]
{
  "mot": [
    48,
    0,
    0.735341, 0.255615, 0.627441, -0.015869,
    0.948257, -0.354986, -0.083497,
    -44.656766, -86.970985, 23.221568
  ],
  "sid": "da18712c-a292-46b7-a5a0-1bd64a3dc6f3",
  "time": 1590402244.8242
}

Example for an older INSIGHT:

[
    "COUNTER_MEMS","INTERPOLATED_MEMS",
    "GYROX","GYROY","GYROZ",
    "ACCX","ACCY","ACCZ",
    "MAGX","MAGY","MAGZ"
]
{
    "mot":[
        14,0,
        8206,8187,8181,
        4235,8668,8128,
        8294,8237,7938
    ],
    "sid":"462c4d75-113f-4664-a443-3aaa02c178d0",
    "time":1559902927.7428
}

Device information

The stream "dev" uses these labels:

Label

Type

Description

Battery

number

The battery level of the headset, from 0 to 4.

Signal

number

The strength of the wireless signal received from the headset, from 0 to 1.

<EEG sensors>

number

The contact quality of each EEG sensor, from 0 to 4.

There is an additional label "OVERALL" at the end of the array. The overall contact quality is a value from 0 to 100 that is calculated from the contact quality of all the EEG sensors. The label OVERALL was added in Cortex 2.4

BatteryPercent

number

The battery level of the headset, from 0 to 100. It has the same purpose as the label "Battery", but it is more precise.

This label was added in Cortex 2.7

Example with INSIGHT:

[
  "Battery",
  "Signal",
  ["AF3","T7","Pz","T8","AF4","OVERALL"],
  "BatteryPercent"
]
{
  "dev": [
    3,
    1,
    [4,1,1,2,4,25],
    74
  ],
  "sid": "edcb9287-f6d5-4c22-9b3f-783d72750f24",
  "time": 1590403053.5002
}

Example with EPOC+ or EPOC X:

[
    "Battery","Signal",
    ["AF3","F7","F3","FC5","T7","P7","O1","O2","P8","T8","FC6","F4","F8","AF4","OVERALL"],
    "BatteryPercent"
]
{
    "dev":[
        4,2,
        [2,0,1,0,1,0,0,4,0,1,0,1,0,1,24],
        98
    ],
    "sid":"d02af7d5-2bc0-46f4-8804-026a42ad7841",
    "time":1559903194.6721
}

EEG Quality

Please read this page to understand the difference between the contact quality and the EEG quality.

The stream "eq" uses these labels:

Label

Type

Description

batteryPercent

number

The battery level of the headset, from 0 to 100.

overall

number

A value from 0 to 100 that is calculated from the EEG quality of all the EEG sensors.

sampleRateQuality

number

A float value from 0 to 1 that evaluates the actual sample rate of the EEG data coming from the headset.

If the wireless connection between the headset and the computer is perfect (no data loss) then the sample rate quality is 1. If X percent of the EEG samples were lost over the last 2 seconds, then the SRQ is (100 - X) / 100.

If we lost more than 300 ms of data over the last 2 seconds, then the SRQ takes the special value -1.

<EEG sensors>

number

The EEG quality of each EEG sensor, from 0 to 4.

This stream was added in Cortex 2.7.0

Example with INSIGHT:

[
  "batteryPercent",
  "overall",
  "sampleRateQuality",
  "AF3","T7","Pz","T8","AF4"
]
{
  "eq": [
    78,
    25,
    1.0,
    4,1,1,2,4
  ],
  "sid": "edcb9287-f6d5-4c22-9b3f-783d72750f24",
  "time": 1590403053.5002
}

Band power

This stream gives you the power of the EEG data. The values are absolute, the unit is uV^2 / Hz. Each sample is calculated based on the last 2 seconds of EEG data.

The labels of the stream "pow" use the format "SENSOR/BAND", when SENSOR is the name of the EEG sensor and BAND is the name of the band power. Cortex provides these bands:

  • theta (4-8Hz)

  • alpha (8-12Hz)

  • betaL (low beta, 12-16Hz)

  • betaH (high beta, 16-25Hz)

  • gamma (25-45Hz)

So the low beta for AF3 has the label "AF3/betaL". The gamma for Pz has the label "Pz/gamma".

Example with INSIGHT:

[
    "AF3/theta","AF3/alpha","AF3/betaL","AF3/betaH","AF3/gamma",
    "T7/theta","T7/alpha","T7/betaL","T7/betaH","T7/gamma",
    "Pz/theta","Pz/alpha","Pz/betaL","Pz/betaH","Pz/gamma",
    "T8/theta","T8/alpha","T8/betaL","T8/betaH","T8/gamma",
    "AF4/theta","AF4/alpha","AF4/betaL","AF4/betaH","AF4/gamma"
]
{
  "pow": [
    1.246,0.706,0.566,1.065,0.602,
    10.293,4.374,11.638,351.767,40.273,
    50.159,4.585,0.467,1.481,3.764,
    9.861,3.139,2.094,3.342,4.452,
    75.652,1.972,2.932,2.555,7.005
  ],
  "sid": "ff0245d1-9531-424c-9f6d-9f736f465516",
  "time": 1590403491.0307
}

Example with EPOC+ or EPOC X:

[
    "AF3/theta","AF3/alpha","AF3/betaL","AF3/betaH","AF3/gamma",
    "F7/theta","F7/alpha","F7/betaL","F7/betaH","F7/gamma",
    "F3/theta","F3/alpha","F3/betaL","F3/betaH","F3/gamma",
    "FC5/theta","FC5/alpha","FC5/betaL","FC5/betaH","FC5/gamma",
    "T7/theta","T7/alpha","T7/betaL","T7/betaH","T7/gamma",
    "P7/theta","P7/alpha","P7/betaL","P7/betaH","P7/gamma",
    "O1/theta","O1/alpha","O1/betaL","O1/betaH","O1/gamma",
    "O2/theta","O2/alpha","O2/betaL","O2/betaH","O2/gamma",
    "P8/theta","P8/alpha","P8/betaL","P8/betaH","P8/gamma",
    "T8/theta","T8/alpha","T8/betaL","T8/betaH","T8/gamma",
    "FC6/theta","FC6/alpha","FC6/betaL","FC6/betaH","FC6/gamma",
    "F4/theta","F4/alpha","F4/betaL","F4/betaH","F4/gamma",
    "F8/theta","F8/alpha","F8/betaL","F8/betaH","F8/gamma",
    "AF4/theta","AF4/alpha","AF4/betaL","AF4/betaH","AF4/gamma"
]
{
    "pow":[
        0.225,0.213,0.537,0.19,0.34,
        0.511,0.808,1.706,0.839,0.416,
        ...
        0.92,0.469,1.657,1.443,0.912,
        2.675,0.824,0.951,0.303,0.881
    ],
    "sid":"f581b2bb-c043-4a00-8737-1e8e09a9a81b",
    "time":1559902987.133
}

Performance metric

The stream "met" uses these labels:

Label

Type

Description

eng

number

Engagement

exc

number

Excitement

lex

number

Long term excitement. It is calculated from the excitement values of the last minute.

str

number

Stress / Frustration

rel

number

Relaxation

int

number

Interest / Affinity

foc

number

Focus

eng.isActive

boolean

Active flag for engagement.

exc.isActive

boolean

Active flag for excitement.

str.isActive

boolean

Active flag for stress / frustration.

rel.isActive

boolean

Active flag for relaxation.

int.isActive

boolean

Active flag for interest / affinity.

foc.isActive

boolean

Active flag for focus.

Each performance metric is a decimal number between 0 and 1. Zero means "low power", 1 means "high power". So for example, a value of 0.1 for "eng" means that the user is not engaged, a value of 1.0 means the user is very engaged. If the detection cannot run because of a poor EEG signal quality then the value is null.

For each performance metrics, the flag isActive is true if the detection of this metrics is running properly. It is false if the detection cannot run. This can happen if the EEG signal from the headset is of poor quality. This flag was added in Cortex 2.2.1

[
    "eng.isActive","eng",
    "exc.isActive","exc","lex",
    "str.isActive","str",
    "rel.isActive","rel",
    "int.isActive","int",
    "foc.isActive","foc"
]
{
    "met":[false,null,false,null,null,false,null,true,0.266589,false,null,true,0.098421],
    "sid":"6a68b92a-cb1f-4062-bf1f-74424fbae065",
    "time":1559903137.1741
}

Mental command

The stream "com" uses these labels:

Label

Type

Description

act

string

A mental command action. Use the method to get the possible actions.

pow

number

The power of the action. It is a decimal number between 0 and 1, zero means "low power", 1 means "high power".

["act","pow"]
{
    "com":["pull",0.564],
    "sid":"79cc669b-af2e-465a-bdc2-0e9bd4aebe80",
    "time":1559903099.348
}

Facial expression

The stream "fac" uses these labels:

Label

Type

Description

eyeAct

string

The action of the eyes.

uAct

string

The upper face action.

uPow

number

Power of the upper face action. Zero means "low power", 1 means "high power".

lAct

string

The lower face action.

lPow

number

Power of the lower face action. Zero means "low power", 1 means "high power".

Use the method getDetectionInfo to get the possible actions.

["eyeAct","uAct","uPow","lAct","lPow"]
{
    "fac":["neutral","neutral",0,"clench",0.0576],
    "sid":"a4f69c56-9769-4a4d-950c-490eb5ebe372",
    "time":1559903035.2961
}

System events

The stream "sys" is used for the training of the mental command and facial expression. It uses these labels:

Label

Type

Description

event

string

The name of the detection. Can be "mentalCommand" or "facialExpression"

msg

string

Depends on the detection. Use the method to get the possible values, check the field events in the result.

For example, just after you start a training for the mental command detection, you receive a system event like this:

["event","msg"]
{
    "sid":"c7e7b527-2b2e-4ec6-8c74-cf16aae8540b",
    "sys":["mentalCommand","MC_Started"],
    "time":1559903035.2961
}

exportRecord

This method is to export one or more records to EDF or CSV files.

You can export the raw EEG data, the motion data, the performance metrics and the band powers. The available data streams depend on the license of the record. You can check the field licenceScope in the Record object to know which data streams are available.

By default, you can only export the records that were created by your application. If you want to export a record that was created by another application (e.g. Emotiv PRO or EMOTIV LABS) then you must provide the license id of this application in the parameter licenseIds.

In order to export a record created by EMOTIV LABS, the current Cortex user must be the owner of the LABS experiment.

You must stop the record before you can export it. If you want to export a record immediately after you stop it then you must wait for the warning 30 before you try to export.

The format of the exported files is described in EmotivPRO user manual.

This method was added in Cortex 2.1.1 to all desktop versions of Cortex. It was added to iOS and Android in Cortex 2.7.0

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

recordIds

array of strings

yes

An array of record ids. These are the ids of the records you want to export.

folder

string

yes

The path of a local folder. Cortex will write the exported files in that folder. You must create this folder before you call this method. Cortex will return an error if the folder doesn't exist.

On iOS, this parameter doesn't exist. Cortex exports the data to the "Documents" folder of the current application.

streamTypes

array of strings

yes

List of the data streams you want to export.

format

string

yes

The format of the exported files. Must be "EDF", "EDFPLUS", "BDFPLUS" or "CSV".

version

string

no

If the format is "EDF", then you must omit this parameter.

If the format is "CSV", then this parameter must be "V1" or "V2".

licenseIds

array of strings

no

The default value is an empty list, which means that you can only export the records created by your application. You can provide the license ID of other applications in order to export the records created by these applications.

This parameter was added in Cortex 2.6.3

includeDemographics

boolean

no

If true then the exported JSON file will include the demographic data of the user. It is only for the records created by .

The default value is false.

This parameter was added in Cortex 2.6.3

includeSurvey

boolean

no

If true then the exported JSON file will include the survey data of the record. It is only for the records created by .

The default value is false.

This parameter was added in Cortex 2.6.3 From Cortex 3.5.0, survey data will be exported in a separate CSV file (along with JSON file).

includeMarkerExtraInfos

boolean

no

If true then the markers of the records will be exported to a CSV file. This file is compatible with .

The default value is false.

This parameter was added in Cortex 2.6.3

includeDeprecatedPM

boolean

no

If true then deprecated performance metrics (i.e. Focus) will be exported.

The default value is false. This parameter was added in Cortex 3.5.6

Data streams

The parameter streamTypes must contain one or more values, chosen from this list: "EEG", "MOTION", "PM", "BP". If the format is "EDF" then only "EEG" and "MOTION" are available.

Stream

Description

EEG

Export the raw EEG data, the contact quality of each EEG sensor, and the markers. The license scope of the record must contain the scope "eeg".

MOTION

Export the motion data.

PM

Export the results of the performance metric detection.

If the license scope of the record contains the scope "pm" then Cortex will export the high resolution performance metrics, at 2 hertz. Otherwise Cortex will export the low resolution data, at 0.1 hertz.

MC

Export the results of the mental command detection.

FE

Export the results of the facial expression detection.

BP

Export the band powers of each EEG sensor.

Format and version

Depending on the parameters format and version Cortex will create different files.

Format EDF, no version

This format is identical to the one used in Cortex 1.x

  • 1 EDF file for the EEG and CQ data

  • 1 EDF file for the motion data

  • 1 JSON file for the markers

  • 1 CSV file for the markers if the parameter includeMarkerExtraInfos is true

Format EDFPLUS/BDFPLUS, no version (available since Cortex version 3.7.5)

  • 1 EDF+/BDF+ file for the EEG, CQ and Motion data

  • 1 JSON file for the markers

  • 1 CSV file for the markers if the parameter includeMarkerExtraInfos is true

Format CSV, version V1

This format is identical to the one used in Cortex 1.x

  • 1 CSV file for the EEG and CQ data

  • 1 CSV file for the band powers

  • 1 CSV file for the motion data

  • 1 CSV file for the performance metrics

  • 1 JSON file for the markers

  • 1 CSV file for the markers if the parameter includeMarkerExtraInfos is true

Format CSV, version V2

This format is the new format of Cortex 2.x

  • 1 CSV file for all the data streams (EEG, CQ, band powers, motion, PM)

  • 1 JSON file for the markers

  • 1 CSV file for the markers if the parameter includeMarkerExtraInfos is true

Result

The result is an object that includes these fields:

Name

Type

Description

success

array of objects

For each record you successfully exported, this array contains an object that includes the record id.

failure

array of objects

For each record that couldn't be exported, this array contains an object that describes the error.

In case of success, you get an object with these fields:

Name

Type

Description

recordId

string

The id of the record that was successfully exported.

In case of failure, you get an object with these fields:

Name

Type

Description

recordId

string

The id of the record that couldn't be exported.

code

number

The error code.

message

string

The error message.

Examples

EDF

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "exportRecord",
    "params": {
        "cortexToken": "xxx",
        "folder": "/tmp/edf",
        "format": "EDF",
        "recordIds": [
            "ec0ac33f-ad4e-48b1-bbc3-8502f5c49b62"
        ],
        "streamTypes": [
            "EEG",
            "MOTION"
        ]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "failure": [],
        "success": [
            {
                "recordId": "ec0ac33f-ad4e-48b1-bbc3-8502f5c49b62"
            }
        ]
    }
}

CSV V1

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "exportRecord",
    "params": {
        "cortexToken": "xxx",
        "folder": "/tmp/csv1",
        "format": "CSV",
        "recordIds": [
            "ec0ac33f-ad4e-48b1-bbc3-8502f5c49b62"
        ],
        "streamTypes": [
            "EEG",
            "MOTION",
            "PM",
            "BP"
        ],
        "version": "V1"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "failure": [],
        "success": [
            {
                "recordId": "ec0ac33f-ad4e-48b1-bbc3-8502f5c49b62"
            }
        ]
    }
}

CSV V2

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "exportRecord",
    "params": {
        "cortexToken": "xxx",
        "folder": "/tmp/csv2",
        "format": "CSV",
        "recordIds": [
            "ec0ac33f-ad4e-48b1-bbc3-8502f5c49b62"
        ],
        "streamTypes": [
            "EEG",
            "MOTION",
            "PM",
            "BP"
        ],
        "version": "V2"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "failure": [],
        "success": [
            {
                "recordId": "ec0ac33f-ad4e-48b1-bbc3-8502f5c49b62"
            }
        ]
    }
}

getRecordInfos

This method returns a list of records, selected by their id.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

recordIds

array of strings

yes

A list of records id.

Result

The result is an array of record objects, including the markers of each record.

Examples

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getRecordInfos",
    "params": {
        "cortexToken": "xxx",
        "recordIds": ["db01c15e-d916-4a7b-9f1d-16295fd1c643"]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [{
        "applicationId": "com.jon.snow.winterfell-app",
        "applicationVersion": "1.0",
        "description": "",
        "endDatetime": "2019-06-06T15:57:58.472229+07:00",
        "experimentId": 0,
        "licenseId": "xxx",
        "licenseScope": [
            "pm",
            "eeg"
        ],
        "markers": [
            {
                "endDatetime": "2019-06-06T15:57:33.523627+07:00",
                "extras": {},
                "label": "test1",
                "port": "Cortex Example",
                "startDatetime": "2019-06-06T15:57:33.523627+07:00",
                "type": "instance",
                "uuid": "3e8d3a26-f4bf-486c-8ece-6efb8b739a51",
                "value": 41
            },
            {
                "endDatetime": "2019-06-06T15:57:49.530743+07:00",
                "extras": {},
                "label": "test2",
                "port": "Cortex Example",
                "startDatetime": "2019-06-06T15:57:41.529661+07:00",
                "type": "interval",
                "uuid": "26fccfd8-e487-4623-910a-1ba8591fcdcf",
                "value": 42
            }
        ],
        "ownerId": "76c3468a-d9c0-428d-81b4-bdac5d63860e",
        "startDatetime": "2019-06-06T15:57:28.596410+07:00",
        "subject": {
            "subjectName": "Hodor"
        },
        "tags": [],
        "title": "Cortex Examples C++",
        "uuid": "db01c15e-d916-4a7b-9f1d-16295fd1c643"
    }]
}

Data Subscription

After you opened a session with a headset, you can subscribe to one or more data streams.

Each data steam gives you real time access to data from the headset (EEG, motion...) or data calculated by Cortex (band powers, mental command...)

After you successfully subscribe to a data stream, Cortex will keep sending you data sample objects.

A subscription is linked to a session. All the subscriptions of a session are automatically cancelled when the session is closed. You can call unsubscribe to cancel a subscription.

The available data streams depend on the license of the user, and the model and settings of the headset. For an EPOC Flex, it also depends on the EEG sensor mapping.

Data streams

Each data stream is identified by its name: "eeg", "mot", "dev", "eq", "pow", "met", "com", "fac", "sys".

Stream

Description

eeg

The raw EEG data from the headset.

mot

The motion data from the headset.

dev

The device data from the headset. It includes the battery level, the wireless signal strength, and the contact quality of each EEG sensor.

eq

The EEG quality of each EEG sensor.

Please read this to understand the difference between the contact quality and the EEG quality.

pow

The band power of each EEG sensor. It includes the alpha, low beta, high beta, gamma, and theta bands.

met

The results of the performance metrics detection.

com

The results of the mental commands detection. You must to get meaningful results.

fac

The results of the facial expressions detection.

sys

The system events. These events are related to the training of the mental commands and facial expressions. See for details.

Data streams availability

Depending on the license and the model of the headset, some streams may be available or not, and may send data samples objects at a different rate.

Stream

Supported headsets

Sample rate in hertz

eeg

All, but requires a license

128 or 256, depends on the headset and its settings.

The must contain the scope "eeg". You must activate the before you subscribe.

Please check the of your headset.

mot

All

Disabled, 32, 64, 128, depends on the headset and its settings.

6.4 hertz for MN8.

Please check the of your headset.

dev

All

2

eq

All

2

pow

All

8

met

All EPOC Flex requires a special EEG sensor mapping

2 if the license contains the scope "pm" and you activate the before you subscribe. 0.1 otherwise (1 sample every 10 seconds)

com

All EPOC Flex requires a special EEG sensor mapping

8

fac

All but MN8 EPOC Flex requires a special EEG sensor mapping

32

sys

All

No fixed rate, see for details.

Special EEG sensor mapping for EPOC Flex

By default, the streams "met", "com" and "fac" are not available for EPOC Flex. It is because Cortex doesn't implement the detections (performance metrics, mental command, facial expression) for EPOC Flex.

However, you can configure your EPOC Flex to simulate an EPOC X headset. In that case, Cortex runs the detections that are designed for EPOC X.

All you have to do is to use a sensor mapping that includes all the 14 EEG sensors of an EPOC X headset: AF3, F7, F3, FC5, T7, P7, O1, O2, P8, T8, FC6, F4, F8, AF4. In addition, you should use P3 and P4 as references CMS and DRL. Please see the EPOC X user manual for the complete EPOC X configuration.

Your mapping can also include sensors that are not present on an EPOC X. Cortex will not use these additional sensors to run the detections, but you can use them to collect more EEG data.

You must configure the EEG sensor mapping of your EPOC Flex when you call the method controlDevice.

This feature was added in Cortex 2.7.1

updateRecord

This method is to update a record. You can update its title, description and its tags.

Your application cannot update a record that was created by another application.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

record

string

yes

A record id returned by .

title

string

no

The new title of the record.

This parameter was added in Cortex 2.5.0

description

string

no

The new description of the record. Omit this parameter if you don't want to update the description.

tags

array of strings

no

The new tags of the record.Omit this parameter if you don't want to update the tags.

Result

The result is a record object.

Examples

Update the tags and the description.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "updateRecord",
    "params": {
        "cortexToken": "xxx",
        "record": "d8fe7658-71f1-4cd6-bb5d-f6775b03438f",
        "description": "My best record ever.",
        "tags": ["best", "snow", "direwolf"]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "applicationId": "com.jon.snow.winterfell-app",
        "applicationVersion": "1.0",
        "description": "My best record ever.",
        "endDatetime": "2019-06-06T11:42:23.436191+07:00",
        "experimentId": 0,
        "licenseId": "xxx",
        "licenseScope": ["pm","eeg"],
        "ownerId": "76c3468a-d9c0-428d-81b4-bdac5d63860e",
        "startDatetime": "2019-06-06T11:41:53.088632+07:00",
        "tags": ["best", "snow", "direwolf"],
        "title": "Cortex Examples C++",
        "uuid": "d8fe7658-71f1-4cd6-bb5d-f6775b03438f"
    }
}

Record object

Some methods of the API return one or more record objects, for example queryRecords.

Description

A record object includes these fields:

Name

Type

Description

uuid

string

The id of this record.

ownerId

string

The id of the user this record belongs to. It is a GUID, it is not the EmotivID of the user.

applicationId

string

The id of the application that created this record.

applicationVersion

string

The version of the application that created this record.

title

string

The title of this record.

description

string

The description of this record.

tags

array of strings

The tags associated to this record.

experimentId

number (integer)

The experiment id associated to this record.

startDatetime

string (ISO datetime)

When this record was created.

endDatetime

string (ISO datetime)

When this record was stopped.

licenseId

string

The id of the license used by this record.

licenseScope

array of strings

List of the data streams the license has access to.

The scope "eeg" gives access to the raw EEG data.

The scope "pm" gives access to the 2 hertz performance metrics.

subject

object

This object has a single field "subjectName". It is the subject name used to create this record. You can use to get more information about the subject. If the record was created without a subject name, then the field "subjectName" contains the EmotivID of the user.

localOnly

boolean

If true then this record will not be uploaded to the EMOTIV cloud.

If false then it will be uploaded.

headbandPosition

string

If the headset is an EPOC X, then this field tells you the position of the headband of this headset during this record. Can be "back" or "top". If the headset is not an EPOC X, then this field is null. See for details.

This field was added in Cortex 2.4

Depending on how you get the record, it may contains an additional field for the markers:

Name

Type

Description

markers

array of objects

A list of . The markers added to this record.

Examples

{
    "applicationId": "com.jon.snow.winterfell-app",
    "applicationVersion": "1.0",
    "description": "",
    "startDatetime": "2019-06-06T15:57:28.596410+07:00",
    "endDatetime": "2019-06-06T15:57:58.472229+07:00",
    "experimentId": 0,
    "licenseId": "xxx",
    "licenseScope": [
        "pm",
        "eeg"
    ],
    "localOnly": false,
    "markers": [
        {
            "endDatetime": "2019-06-06T15:57:33.523627+07:00",
            "extras": {},
            "label": "test1",
            "port": "Cortex Example",
            "startDatetime": "2019-06-06T15:57:33.523627+07:00",
            "type": "instance",
            "uuid": "3e8d3a26-f4bf-486c-8ece-6efb8b739a51",
            "value": 41
        },
        {
            "endDatetime": "2019-06-06T15:57:49.530743+07:00",
            "extras": {},
            "label": "test2",
            "port": "Cortex Example",
            "startDatetime": "2019-06-06T15:57:41.529661+07:00",
            "type": "interval",
            "uuid": "26fccfd8-e487-4623-910a-1ba8591fcdcf",
            "value": 42
        }
    ],
    "ownerId": "76c3468a-d9c0-428d-81b4-bdac5d63860e",
    "subject": {
        "subjectName": "Hodor"
    },
    "tags": ["snow", "cold", "winter"],
    "title": "Cortex Examples C++",
    "uuid": "db01c15e-d916-4a7b-9f1d-16295fd1c643"
}

Subjects

A subject represents a human being who is the subject of a , ie the person wearing the headset during the record. A subject is a permanent object. It is stored on the hard drive and then synchronized to the EMOTIV cloud.

To associate a subject to a record, you must create the subject first, by calling . Then you must specify the subject name when you call . A subject is identified by his/her name.

You can call to list the subjects already created for the current user.

injectMarker

This method is to create an "instance" marker to the current record of a session. Then you can call to turn this marker into an "interval" marker.

You must call before you call this method.

Parameters

Result

The result is an object containing these fields:

Examples

requestToDownloadRecordData

This method is to ask Cortex to download the EEG/motion/CQ/detections data of a record from the EMOTIV cloud.

Use case

Suppose that the user has installed Cortex on 2 computers, named computer A and computer B. On computer A, the user creates a record, and Cortex uploads this record to the EMOTIV cloud.

Then, on computer B, Cortex automatically downloads the metadata of this record, ie its name, description, start time, end time, etc... So this record is visible when you call methods like or .

But Cortex doesn't automatically download the actual data of the record, ie the EEG, motion, CQ, the results of the detections, etc... So you cannot this record. To download the actual data, you must call the method "requestToDownloadRecordData".

Parameters

Name
Type
Required
Description

Result

The result is an object with 2 fields:

Name
Type
Description

Each object in the success array include these fields:

Name
Type
Description

Each object in the failure array include these fields:

Name
Type
Description

Example

deleteRecord

This method is to delete one or more records.

The records will be deleted from the local computer, but also from the EMOTIV account of the user in the cloud, and from any computer where the user is logged in.

Your application cannot delete a record that was created by another application.

Deleting a record is irreversible. There is no way to recover a deleted record.

Parameters

Result

The result is an object that includes these fields:

In case of success, you get an object with these fields:

In case of failure, you get an object with these fields:

Examples

Deleting two records, including one that has an invalid id.

queryRecords

This method returns a list of records owned by the current user. By default, you only get the records created by your application. To query the records from another application, you must filter by the license id of this application.

Parameters

Depending on the query, this method may return a lot of records. To avoid performance issues, you should always set an offset and a limit.

query

The query object can contain one or more of these fields:

orderBy

The orderBy parameters is an array of objects, similar to the orderBy clause of a SQL request.

Each object must have a single attribute. The key of the attribute is the name of record's field you want to order by. The value of the attribute must be "ASC" or "DESC", to order is ascending or descending order.

For example, to order the records by their start date, in descending order, you must use the object {"startDatetime":"DESC"}. To sort the records by title, in alphabetical order, you must use {"title":"ASC"}.

You can order the records by these fields: title, description, startDatetime, modifiedDatetime, duration, subjectName, applicationId. The option to order by applicationId was added in Cortex 2.5.0

limit and offset

These parameters are to implement pagination. It useful if you want to display the records in a UI. You must order the results to use these parameters.

First you should call this method with an offset of zero, and a limit of X. In the response, check the value of count. If count is greater than the limit, then you should call this method again with an offset of X. And then with an offset of 2*X, 3*X... until you get all the records for your query.

Result

The result is an object that includes these fields:

Examples

Get the 10 most recent records created by EmotivPRO.

Get some records using a keyword.

Marker object

A marker object includes these fields:

Examples

An instance marker:

An interval marker:

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

records

array of strings

yes

An array of record ids.

Name

Type

Description

success

array of objects

For each record you successfully deleted, this array contains an object that includes the record id.

failure

array of objects

For each record that couldn't be deleted, this array contains an object that describes the error.

Name

Type

Description

recordId

string

The id of the record that was successfully deleted.

Name

Type

Description

recordId

string

The id of the record that couldn't be deleted.

code

number

The error code.

message

string

The error message.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "deleteRecord",
    "params": {
        "cortexToken": "xxx",
        "records": [
            "d8fe7658-71f1-4cd6-bb5d-f6775b03438f",
            "invalid-id"
        ]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "success": [
            {"recordId":"d8fe7658-71f1-4cd6-bb5d-f6775b03438f"}
        ],
        "failure": [
            {"recordId":"invalid-id","code":1234,"message":"..."}
        ]
    }
}

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

query

object

yes

An object to filter the records.

orderBy

array of objects

yes

Specify how to sort the records.

limit

number

no

The maximum number of records that this method should return. A limit of zero means no maximum.

offset

number

no

The number of record that this method should skip before returning the result. If the limit is zero, then Cortex will ignore this parameter.

includeMarkers

boolean

no

If true then the record objects in the result will include the markers linked to each record. The default value is false because a record may have a large number of markers.

This parameter was added in Cortex 2.1

includeSyncStatusInfo

boolean

no

If true then the record object in the result will include the field "syncStatus". This field tells you if the record was uploaded to the EMOTIV cloud or not.

The default value is false.

This parameter was added in Cortex 2.6.3

Name

Type

Description

licenseId

string

Set this parameter to filter the records by their license.

applicationId

string

If you set the licenseId, then you can set this parameter to further filter the records by application.

keyword

string

Set this parameter to filter the records by title, description, or subject name.

startDatetime

object

An object with fields "from" and "to" to filter the records by their start date time.

modifiedDatetime

object

An object with fields "from" and "to" to filter the records by their modification date time.

duration

object

An object with fields "from" and "to" to filter the records by their duration.

Name

Type

Description

records

array of objects

An array of record objects.

count

number

The total number of records that match the query.

limit

number

The limit you specified in the parameters.

offset

number

The offset you specified in the parameters.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "queryRecords",
    "params": {
        "cortexToken": "xxx",
        "limit": 10,
        "offset": 0,
        "orderBy": [
            { "startDatetime": "DESC" }
        ],
        "query": {
            "applicationId": "com.emotiv.emotivpro",
            "licenseId": "yyy"
        },
        "includeSyncStatusInfo": true
    }
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "count": 1,
    "limit": 10,
    "offset": 0,
    "records": [{
      "applicationId": "com.emotiv.emotivpro",
      "applicationVersion": "2.6.3",
      "demographics": {
        "uuid": "",
        "validated": false
      },
      "description": "A simple experiment with a drone",
      "endDatetime": "2021-01-06T16:32:50.572490+07:00",
      "experimentId": 0,
      "headbandPosition": null,
      "licenseId": "yyy",
      "licenseScope": ["pm", "eeg"],
      "localOnly": false,
      "ownerId": "ddeca960-9336-4a51-a2d2-9cb6e8fd5524",
      "startDatetime": "2021-01-06T16:32:13.431865+07:00",
      "subject": {
        "subjectName": "Ben Kenobi"
      },
      "syncStatus": {
        "status": "neverUploaded"
      },
      "tags": [],
      "title": "Experiment 42",
      "uuid": "1f2a8f85-7200-400a-a8f0-fd5c0b331852"
    }]
  }
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "queryRecords",
  "params": {
    "cortexToken": "xxx",
    "includeMarkers": true,
    "limit": 2,
    "offset": 0,
    "orderBy": [
      {
        "startDatetime": "DESC"
      }
    ],
    "query": {
      "keyword": "Cortex Example"
    }
  }
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "count": 9,
    "limit": 2,
    "offset": 0,
    "records": [
      {
        "applicationId": "com.xxx.cortex-examples",
        "applicationVersion": "1.0",
        "description": "",
        "endDatetime": "2020-03-09T15:59:34.794356+07:00",
        "experimentId": 0,
        "headbandPosition": null,
        "licenseId": "xxx",
        "licenseScope": [
          "pm",
          "eeg"
        ],
        "localOnly": false,
        "markers": [
          {
            "endDatetime": "2020-03-09T15:59:09.680802+07:00",
            "extras": {},
            "label": "test1",
            "port": "Cortex Example",
            "startDatetime": "2020-03-09T15:59:09.680802+07:00",
            "type": "instance",
            "uuid": "ba8ed3a9-3e0b-4a17-9227-96ae05fa1767",
            "value": 41
          },
          {
            "endDatetime": "2020-03-09T15:59:25.873059+07:00",
            "extras": {},
            "label": "test2",
            "port": "Cortex Example",
            "startDatetime": "2020-03-09T15:59:16.867054+07:00",
            "type": "interval",
            "uuid": "2cfe93cc-f242-49d6-8165-7b13147e7c10",
            "value": 42
          }
        ],
        "ownerId": "94f7c5ed-3d24-4c29-8243-96aa7db80d4a",
        "startDatetime": "2020-03-09T15:59:04.344671+07:00",
        "subject": {
          "subjectName": "Bob"
        },
        "tags": [],
        "title": "Cortex Examples C++",
        "uuid": "b26f35c3-42ee-4612-a9b9-09af04c2ba37"
      },
      {
        "applicationId": "com.xxx.cortex-examples",
        "applicationVersion": "1.0",
        "description": "",
        "endDatetime": "2020-03-09T15:58:37.792248+07:00",
        "experimentId": 0,
        "headbandPosition": null,
        "licenseId": "xxx",
        "licenseScope": [
          "pm",
          "eeg"
        ],
        "localOnly": false,
        "markers": [
          {
            "endDatetime": "2020-03-09T15:58:12.875515+07:00",
            "extras": {},
            "label": "test1",
            "port": "Cortex Example",
            "startDatetime": "2020-03-09T15:58:12.875515+07:00",
            "type": "instance",
            "uuid": "e22d46a0-480a-452a-a65e-d6b4448e3f7b",
            "value": 41
          },
          {
            "endDatetime": "2020-03-09T15:58:28.872019+07:00",
            "extras": {},
            "label": "test2",
            "port": "Cortex Example",
            "startDatetime": "2020-03-09T15:58:20.873850+07:00",
            "type": "interval",
            "uuid": "c8fd9191-43da-4e28-970d-bf9f24404c8a",
            "value": 42
          }
        ],
        "ownerId": "94f7c5ed-3d24-4c29-8243-96aa7db80d4a",
        "startDatetime": "2020-03-09T15:58:08.036369+07:00",
        "subject": {
          "subjectName": "Marie"
        },
        "tags": [],
        "title": "Cortex Examples C++",
        "uuid": "33d2c56a-4cdf-4e2b-a5bb-db127f838248"
      }
    ]
  }
}

Name

Type

Description

uuid

string

The id of the marker.

type

string

Can be "interval" or "instance".

value

string or number

The value you set in injectMarker.

label

string

The label of the marker.

port

string

The port of the marker, ie where the marker comes from. Examples: "Software", "Serial", etc...

startDatetime

string (ISO date time)

The timestamp you set in injectMarker.

endDatetime

string (ISO date time)

The timestamp you set in updateMarker.

If you didn't call this method, then endDatetime is equal to startDatetime.

extras

object

Can be any extra information you want to associate with this marker.

{
    "extras": {},
    "label": "test2",
    "port": "Cortex Example",
    "startDatetime": "2019-06-06T15:57:41.529661+07:00",
    "endDatetime":   "2019-06-06T15:57:41.529661+07:00",
    "type": "instance",
    "uuid": "26fccfd8-e487-4623-910a-1ba8591fcdcf",
    "value": 42
}
{
    "extras": {},
    "label": "test2",
    "port": "Cortex Example",
    "startDatetime": "2019-06-06T15:57:41.529661+07:00",
    "endDatetime":   "2019-06-06T15:57:49.530743+07:00",
    "type": "interval",
    "uuid": "26fccfd8-e487-4623-910a-1ba8591fcdcf",
    "value": 42
}
markers
injectMarker
injectMarker
injectMarker
getDetectionInfo
getDetectionInfo
authorize
EMOTIV LABS
EMOTIV LABS
EEGLAB
authorize
page
load a profile
BCI
license
session
documentation
documentation
session
BCI
authorize
createRecord
querySubjects
updateHeadsetCustomInfo
marker objects
record
createSubject
createRecord
querySubjects

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

session

string

yes

A session id returned by createSession.

The marker will be added to the current record of this session.

time

number

yes

The start timestamp of the marker. It is the number of milliseconds that have elapsed since 00:00:00 Thursday, 1 January 1970 UTC.

value

string or number

yes

The value of the marker. It can be a string or an integer.

If it is an integer then it must be positive or zero.

label

string

yes

The label of the marker.

port

string

no

The port of the marker, or where the marker comes from. Examples: "USB", "Serial", etc... The default value is "Software"

extras

object

no

Any extra information you want to associate with the marker.

Name

Type

Description

recordId

string

The id of the record this marker was added to.

sessionId

string

The id of the session associated to the record.

marker

object

A marker object that represents the marker that was created.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "injectMarker",
    "params": {
        "cortexToken": "xxx",
        "label": "test2",
        "port": "Cortex Example",
        "session": "4cbf7554-31bd-4659-ac58-400b823503f0",
        "time": 1559811461532,
        "value": 42
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "marker": {
            "endDatetime": "2019-06-06T15:57:41.529661+07:00",
            "extras": {},
            "label": "test2",
            "port": "Cortex Example",
            "startDatetime": "2019-06-06T15:57:41.529661+07:00",
            "type": "instance",
            "uuid": "26fccfd8-e487-4623-910a-1ba8591fcdcf",
            "value": 42
        },
        "recordId": "db01c15e-d916-4a7b-9f1d-16295fd1c643",
        "sessionId": "4cbf7554-31bd-4659-ac58-400b823503f0"
    }
}
updateMarker
createRecord

cortexToken

string

yes

A token returned by authorize.

recordIds

array of strings

yes

A list of record ids.

success

array of objects

List of the records that Cortex will start to download.

failure

array of objects

List of the records that Cortex will not download.

recordId

string

The id of a record that was added to the Cortex download queue.

Cortex will now start the download.

recordId

string

The id of a record that Cortex cannot download.

code

number

The error code for this record.

message

string

The error message for this record.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "requestToDownloadRecordData",
  "params": {
    "cortexToken": "xxx",
    "recordIds": [
        "33a9aa44-5a90-4881-8613-78493752b86d", 
        "3a4b7eb0-3b6c-4e16-a480-cbda8181f092"
      ]
  }
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "failure": [{
      "code": -32186,
      "message": "The record already exists.",
      "recordId": "33a9aa44-5a90-4881-8613-78493752b86d"
    }],
    "success": [{
      "recordId": "3a4b7eb0-3b6c-4e16-a480-cbda8181f092"
    }]
  }
}
queryRecord
getRecordInfos
export

Markers

A marker is to mark a point in time, or a period of time, inside a record.

Markers are always linked to a record, so you must start a record before you add a marker. You can't add nor update a marker after the record is stopped. You can associate some data to each marker, like a value and a label.

There are two types of markers:

  • An instance marker is to mark a point in time. You call injectMarker to create the marker at a specific timestamp.

  • An interval marker is to mark a period of time, with a beginning and an end. First you create an instance marker with injectMarker. This sets the beginning of the interval. Then you call updateMarker to set the end of the interval, turning the instance marker into an interval marker.

Readonly profile

If you upgrade from EmotivBCI before v3.6.5, you should notice that we change the format of training profiles so that the existing training profile (i.e. created before v3.6.5) will not be fully supported. We call them readonly profiles which can only run at a live mode and cannot run on training mode.

These readonly training profiles only support headsets with 14 EEG channels (i.e. EPOC X and Flex with EPOC X config mapping).

cortexaccess tool

This command line tool is available only for Raspberry Pi to manage permissions for remote connections via IP addresses of remote desktop machines.

This tool is installed on Raspberry Pi device along with Cortex installation. It is located at /usr/local/emotivapps/bin/cortexaccess.

List all granted IP addresses

List all IP addresses of remote desktop machines from which applications are allowed to create web socket connections to Cortex on Raspberry Pi device.

Command: cortexaccess ip list

If the IP address of your remote desktop isn't in the list, you should add it using accept command.

Add an IP address

Grant permissions a remote desktop machine (via its IP address) from which applications can create web socket connections to Cortex on Raspberry Pi device.

Command: cortexaccess ip accept <an-ip-address>

Remove an IP address

Remove permissions of remote desktop machines (via its IP address) so that applications on that machine cannot create web socket connections to Cortex on Raspberry Pi device anymore.

Command: cortexaccess ip deny <an-ip-address>

Clear all IP addresses

Remove permissions of current granted remote desktop machines so that applications on these machines cannot create web socket connections to Cortex on Raspberry Pi device anymore.

Command: cortexaccess ip clear

stopRecord

This method is to stop a record that was previously started by createRecord. This will set the end date time of the record to the current date time.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

session

string

yes

The session id you provided when you called .

A record is linked to a session. So to close a record, you need to provide the session id.

Result

The result is an object containing these fields:

Name

Type

Description

record

object

A .

sessionId

string

The session id linked to the record.

Example

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "stopRecord",
    "params": {
        "cortexToken": "xxx",
        "session": "38fef6d7-979b-420b-aa25-dd60ef5edc02"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "record": {
            "applicationId": "com.jon.snow.winterfell-app",
            "applicationVersion": "1.0",
            "description": "",
            "endDatetime": "2019-06-06T11:42:23.436191+07:00",
            "experimentId": 0,
            "licenseId": "xxx",
            "licenseScope": ["pm","eeg"],
            "ownerId": "76c3468a-d9c0-428d-81b4-bdac5d63860e",
            "startDatetime": "2019-06-06T11:41:53.088632+07:00",
            "tags": [],
            "title": "Cortex Examples C++",
            "uuid": "d8fe7658-71f1-4cd6-bb5d-f6775b03438f"
        },
        "sessionId": "38fef6d7-979b-420b-aa25-dd60ef5edc02"
    }
}

querySubjects

This method returns a list of subjects owned by the current user.

This method was added in Cortex 2.1

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

query

object

yes

An object to filter the subjects.

orderBy

array of objects

yes

Specify how to sort the subjects.

limit

number

no

The maximum number of subjects that this method should return. A limit of zero means no maximum.

offset

number

no

The number of subjects that this method should skip before returning the result. If the limit is zero, then Cortex will ignore this parameter.

Depending on the query, this method may return a lot of subjects. To avoid performance issues, you should always set an offset and a limit.

query

The query object can contain one or more of these fields:

Name

Type

Description

uuid

string

Set this parameter to get a subject by its id.

subjectName

string

Set this parameter to filter the subjects by name.

sex

string

Set this parameter to filter the subjects by their gender. Must be "M", "F" or "U".

countryCode

string

Set this parameters to filter the subjects by their country.

dateOfBirth

object

An object with fields "from" and "to" to filter the subjects by their date of birth.

keyword

object

An object with the fields as the keyword to search and values are the list of fields to search. The list of fields to search can contains "subjectName", "lastName", "email"

orderBy

The orderBy parameters is an array of objects, similar to the orderBy clause of a SQL request.

Each object must have a single attribute. The key of the attribute is the name of subject's field you want to order by. The value of the attribute must be "ASC" or "DESC", to order is ascending or descending order.

For example, to order the subjects by their names, in alphabetical order, you must use the object {"subjectName":"ASC"}.

You can order the subjects by these fields: subjectName, dateOfBirth.

limit and offset

These parameters are to implement pagination. It useful if you want to display the subjects in a UI. You must order the results to use these parameters.

First you should call this method with a offset of zero, and a limit of X. In the response, check the value of count. If count is greater than the limit, then you should call this method again with an offset of X. And then with an offset of 2*X, 3*X... until you get all the subjects for your query.

Result

The result is an object that includes these fields:

Name

Type

Description

subjects

array of objects

An array of .

count

number

The total number of subjects that match the query.

limit

number

The limit you specified in the parameters.

offset

number

The offset you specified in the parameters.

Examples

Find the 10 first female subjects born in 1979 or 1980.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "querySubjects",
    "params": {
        "cortexToken": "xxx",
        "query": {
            "dateOfBirth": {
                "from": "1979-01-01",
                "to": "1980-12-31"
            },
            "sex": "F",
            "keyword": {
                "yyy":["subjectName", "email"]
            }
        },
        "orderBy": [
            {"subjectName": "ASC"}
        ],
        "offset": 0,
        "limit": 10
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "count": 1,
        "limit": 10,
        "offset": 0,
        "subjects": [
            {
                "attributes": [
                    {
                        "name": "Handedness",
                        "value": "Left"
                    },
                    {
                        "name": "Education",
                        "value": "Master's degree"
                    }
                ],
                "city": "London",
                "countryCode": "GB",
                "countryName": "",
                "dateOfBirth": "1980-12-25",
                "experimentsCount": 0,
                "modifiedDatetime": "2019-07-01T11:23:11.644+07:00",
                "sex": "F",
                "state": "",
                "subjectName": "Alice Smith"
            }
        ]
    }
}

updateMarker

This method is to update a marker that was previously created by injectMarker.

This method set the end date time of a marker, turning an "instance" marker into an "interval" marker. You can also update the extras object.

The marker must belong to a record that is still in progress. You cannot update the marker if the record is already stopped.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

session

string

yes

A session id returned by .

markerId

string

yes

The id of the marker you want to update. This marker must belong to the current record of the session.

time

number

yes

The end timestamp of the marker. It is the number of milliseconds that have elapsed since 00:00:00 Thursday, 1 January 1970 UTC.

extras

object

no

Any extra information you want to associate with the marker.

Result

The result is an object containing these fields:

Name

Type

Description

recordId

string

The id of the record this marker belongs to.

sessionId

string

The id of the session associated to the record.

marker

object

A that represents the marker that was updated.

Examples

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "updateMarker",
    "params": {
        "cortexToken": "xxx",
        "session": "4cbf7554-31bd-4659-ac58-400b823503f0",
        "markerId": "26fccfd8-e487-4623-910a-1ba8591fcdcf",
        "time": 1559811469531
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "marker": {
            "endDatetime": "2019-06-06T15:57:49.530743+07:00",
            "extras": {},
            "label": "test2",
            "port": "Cortex Example",
            "startDatetime": "2019-06-06T15:57:41.529661+07:00",
            "type": "interval",
            "uuid": "26fccfd8-e487-4623-910a-1ba8591fcdcf",
            "value": 42
        },
        "recordId": "db01c15e-d916-4a7b-9f1d-16295fd1c643",
        "sessionId": "4cbf7554-31bd-4659-ac58-400b823503f0"
    }
}

updateSubject

This method is to update an existing subject.

This method was added in Cortex 2.1

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

subjectName

string

yes

The name of the subject.

dateOfBirth

string

no

The date of birth of the subject. The format must be "YYYY-MM-DD", e.g. "1980-12-25".

sex

string

no

Must be "M", "F" or "U". These letters stands for male, female and unknown respectively.

countryCode

string

no

The of the country the subject lives in.

state

string

no

The state the subject lives in.

city

string

no

The city the subject lives in.

attributes

array of objects

no

A list of demographic attribute objects. See .

A subject is identified by his/her name, so you must provide the name of the subject you want to update. Then you can set one or more of the not required fields to update their value.

Result

The result is a subject object representing the updated subject.

Examples

Update the date of birth of a subject.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "updateSubject",
    "params": {
        "cortexToken": "xxx",
        "subjectName": "Bob Smith",
        "dateOfBirth": "1978-11-21"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "attributes": [],
        "city": "",
        "countryCode": "",
        "countryName": "",
        "dateOfBirth": "1978-11-21",
        "experimentsCount": 0,
        "modifiedDatetime": "2019-07-01T11:49:50.332+07:00",
        "sex": "U",
        "state": "",
        "subjectName": "Bob Smith"
    }
}

configOptOut

This method is to configure the opt-out feature for the records. This feature lets you decide if the records created by your application on the local machine are uploaded to the EMOTIV cloud or not.

If the opt-out is on (ie the parameter newOptOut is true) then the records created on this machine will not be uploaded to the cloud. If the opt-out is off (ie the parameter newOptOut is false) then the records created on this machine will be uploaded to the cloud.

Please note that changing the opt-out configuration has no effect on the records previously created on the local computer. It only affects the records created after the change. Changing the opt-out configuration is not retroactive.

The opt-out configuration is linked to your application. Changing the configuration only affects the records created by your application. This has no effect on the records created by other applications.

The opt-out configuration is also linked to the EmotivID of the user. The opt-out can be turned on or off for each EmotivID. It is off by default.

You can check the field localOnly of a Record object to know if this record will stay on the local machine, or if it will be uploaded to the EMOTIV cloud.

Some licenses don't let you change the opt-out configuration and force the opt-out to be always on or always off. See the possible configurations below for details.

This method was added in Cortex 2.2.1

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

status

string

yes

Must be "get" or "set". Use "get" to read the current configuration of the opt-out feature. Use "set" to turn the opt-out on or off.

newOptOut

boolean

no

If the status is "set" then you must set this parameter to true or false, in order to turn the opt-out feature on or off. If the status is "get" then you should omit this parameter.

Result

The result is an object describing the current opt-out configuration. It includes these fields:

Name

Type

Description

optOutAvail

boolean

If false then the opt-out is always off. The value of this field depends on the current . Some license force you to upload the records to the cloud.

forceOptOut

boolean

If true (and optOutAvail is also true) then the opt-out is always on. The value of this field depends on the current . Some license don't let you upload the records to the cloud.

currOptOut

boolean

The current configuration of the opt-out.

If this value is true, then the records created by your application won't be uploaded to the cloud. If this value is false, then they will.

message

string

A text message.

Possible Configurations

Here is an overview of the possible configurations:

optOutAvail

forceOptOut

currOptOut

Description

true

false

Variable, false by default

By default, currOptOut is false and the records created by your application will be uploaded to the cloud. You can change the opt-out configuration for each EmotivID.

true

true

Always true

The records will never be uploaded to the cloud. You cannot change the configuration.

false

false

Always false

The records will always be uploaded to the cloud. You cannot change the configuration.

false

true

Always false

The records will always be uploaded to the cloud. You cannot change the configuration.

Examples

Get the current configuration

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "configOptOut",
    "params": {
        "cortexToken": "xxx",
        "status": "get"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "currOptOut": false,
        "forceOptOut": false,
        "message": "Get opt-out configuration successfully",
        "optOutAvail": true
    }
}

Change the configuration

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "configOptOut",
    "params": {
        "cortexToken": "xxx",
        "status": "set",
        "newOptOut": true
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "currOptOut": true,
        "forceOptOut": false,
        "message": "Update opt-out configuration successfully",
        "optOutAvail": true
    }
}

deleteSubjects

This method is to delete one or more subjects.

Deleting a subject is irreversible. There is no way to recover a deleted subject.

This method was added in Cortex 2.1

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

subjects

array of strings

yes

A list a subject names.

A subject is identified by his/her name, so you must provide the name of the subjects you want to delete.

Result

The result is an object that includes these fields:

Name

Type

Description

success

array of objects

For each subject you successfully deleted, this array contains an object with the name of deleted subject.

failure

array of objects

For each subject you failed to delete, this array contains an object that describes the error.

In case of success, you get an object with these fields:

Name

Type

Description

subjectName

string

The name of the deleted subject.

In case of failure, you get an object with these fields:

Name

Type

Description

subjectName

string

The name of the subject.

code

number

The error code.

message

string

The error message.

Examples

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "deleteSubjects",
    "params": {
        "cortexToken": "xxx",
        "subjects": ["Invalid Name", "Bob Smith"]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "failure": [
            {
                "code": -32124,
                "message": "The subject was not found.",
                "subjectName": "Invalid Name"
            }
        ],
        "success": [
            {
                "subjectName": "Bob Smith"
            }
        ]
    }
}

.

queryProfile

This method returns the list of all the training profiles of the user.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

Result

The result is an array of objects , or an empty array if the user has no profile. Each object includes these fields:

uuid

string

The unique ID of this profile.

name

string

The name of the profile.

readOnly

boolean

If a headset is created before v3.6.5, the profile will become read-only when upgrading to v3.6.5. See . This field is available since v3.6.5.

eegChannels

array

The list of EEG channels of a headset with which this profile can be loaded. For example, if eegChannels of a profile is ["AF3","T7","Pz","T8","AF4"], this profile can be loaded for Insight headset. This field is available since v3.6.5.

Example

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "queryProfile",
    "params": {
        "cortexToken": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "uuid":"xxx"
            "name":"Profile A",
            "readOnly":false,
            "eegChannels":["AF3","T7","Pz","T8","AF4"]
        },
        {
            "uuid":"yyy"
            "name":"Profile B",
            "readOnly":true,
            "eegChannels":["AF3","F7","F3","FC5","T7","P7","O1","O2","P8","T8","FC6","F4","F8","AF4"]
        }
    ]
}

BCI

You can use the Cortex API to develop a brain–computer interface (BCI), using facial expressions, mental commands, or both.

Before you start programming your own BCI, it is strongly recommended that you use EmotivBCI to get familiar with the main BCI features of Cortex. You should also check out the EmotivBCI Node-RED Toolbox.

To use the BCI features with an EPOC Flex headset, you must use a special EEG mapping. Please see Data Subscription for details.

To get the results of the facial expression detection and the mental command detection, you must subscribe to the data streams "fac" and "com" respectively.

To use the mental command detection, you must load a training profile that contains training data for at least one action. For the facial expression detection, the training is optional.

Profile

A profile is a persistent object that stores training data for the facial expression and mental command detections. A profile belongs to a user and is synchronized to the EMOTIV cloud.

You can use queryProfile to list the profiles of the current user. Use setupProfile to manage the profiles, and also to load or unload a profile for a headset. You can use training to add training data to a profile.

Before v3.6.5, a profile can be loaded for both Epoc/Flex and Insight. Since v3.6.5, a profile can only be loaded for Epoc/Flex or Insight since their EEG channels are different. If you upgrade from version before 3.6.5, the existing profiles will become readonly. See Readonly training profile.

Training workflow

The training works that same for the mental command detection and the facial expression detection. However, they don't use the same actions, events or controls. So you should call getDetectionInfo to know what actions, controls and events you can use for each detection.

Before you start a training, you must subscribe to the data stream "sys" to receive the training events from Cortex. Then you can follow these steps:

  1. Start the training by calling training with the action you want to train and the control "start".

  2. On the "sys" stream, you receive the event "started".

  3. After a few seconds, you receive one of these two events:

    1. Event "succeeded", the training is a success. Now you must accept it or reject it.

    2. Event "failed", the data collected during the training is of poor quality, you must start over from the beginning.

  4. Call training with the control "accept" to add the training to the profile. Or you can use the control "reject" to reject this training, and then you must start over from the beginning.

  5. Cortex sends the event "completed" to confirm that the training was successfully completed.

  6. You should save the profile to persist this training. If you unload the profile without saving, then the training is lost.

After step 2, but before step 3, you can send the control "reset" to cancel the training.

The following chart illustrates the flow of BCI training with corresponding request for each step:

Getting live actions

The following chart illustrates the streaming of Mental Commands data in live:

loadGuestProfile

This method loads an empty profile for a headset. You can use this method to quickly load a profile, without having to create a profile with setupProfile.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

headset

string

yes

A headset id returned by .

Result

The result is an object containing these fields:

Name

Type

Description

action

string

Is always "load".

name

string

Is always "Guest Profile".

message

string

A success message.

Examples

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "loadGuestProfile",
    "params": {
        "cortexToken": "xxx",
        "headset": "INSIGHT-12341234"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "action": "load",
        "name": "Guest Profile",
        "message": "..."
    }
}

createSubject

This method is to create a new subject. Then you can associate the subject to a record when you call createRecord.

This method was added in Cortex 2.1

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

subjectName

string

yes

The name of the subject. Must be 30 characters or less.

dateOfBirth

string

no

The date of birth of the subject. The format must be "YYYY-MM-DD", e.g. "1980-12-25".

sex

string

no

Must be "M", "F" or "U". These letters stands for male, female and unknown respectively.

countryCode

string

no

The of the country the subject lives in.

state

string

no

The state the subject lives in.

city

string

no

The city the subject lives in.

attributes

array of objects

no

A list of demographic attribute objects. See .

Result

The result is a subject object representing the new subject.

Examples

Create a subject with only his name.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "createSubject",
    "params": {
        "cortexToken": "xxx",
        "subjectName": "Bob Smith"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "attributes": [],
        "city": "",
        "countryCode": "",
        "countryName": "",
        "dateOfBirth": "",
        "experimentsCount": 0,
        "modifiedDatetime": "2019-07-01T11:41:25.270+07:00",
        "sex": "U",
        "state": "",
        "subjectName": "Bob Smith"
    }
}

Create a subject with more information.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "createSubject",
    "params": {
        "cortexToken": "xxx",
        "subjectName": "Alice Smith",
        "city": "London",
        "countryCode": "GB",
        "dateOfBirth": "1980-12-25",
        "sex": "F",
        "attributes": [
            {
                "name": "Handedness",
                "value": "Left"
            },
            {
                "name": "Education",
                "value": "Master's degree"
            }
        ]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "attributes": [
            {
                "name": "Handedness",
                "value": "Left"
            },
            {
                "name": "Education",
                "value": "Master's degree"
            }
        ],
        "city": "London",
        "countryCode": "GB",
        "countryName": "",
        "dateOfBirth": "1980-12-25",
        "experimentsCount": 0,
        "modifiedDatetime": "2019-07-01T11:23:11.644+07:00",
        "sex": "F",
        "state": "",
        "subjectName": "Alice Smith"
    }
}

setupProfile

This method is to manage the training profiles of the user.

You create, rename or delete a profile. You can load and unload a profile for a headset if the EEG channels of this headset is supported by this training profile. And you can save a profile after the user completed a training, or after you changed the attributes of the profile.

Before you load or unload a profile, you can call getCurrentProfile to know if a profile is currently loaded, and if it was loaded by your application.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

status

string

yes

Must be "create", "load", "unload", "save", "rename" or "delete".

profile

string

yes

The name of the profile.

headset

string

yes or no, depending on "status"

A headset id returned by .

newProfileName

string

no

If the status is "rename", then you must set this parameter, and it is the new name of the profile.

Depending on the status, this method has different effects, and uses different parameters.

Status create

Create a new profile. It can be an empty profile, or a copy of a loaded profile.

Name

Type

Required

Description

profile

string

yes

The name of the new profile. It must be unique for the user. Use to check if a name is already in use.

headset

string

yes

create a copy of the profile currently loaded for this headset.

Status load

Load an existing profile for a specific headset. If a profile is already loaded, then you must unload it first.

Name

Type

Required

Description

profile

string

yes

The name of the profile to load.

headset

string

yes

The id of the headset to load the profile to.

Status unload

Unload the profile of a specific headset. After the unload, this headset will use a default empty profile. You should set the parameter profile to an empty string. You cannot unload a profile that was loaded by another application.

Name

Type

Required

Description

headset

string

yes

The id of the headset to unload the profile.

profile

string

yes

Cortex will ignore this parameter. Should be an empty string.

Status save

Save the profile used by a headset. You can save it with a new name, so it creates a new profile. Or you can save it with the same name, ie the name you used to load it. You cannot save a profile that was loaded by another application.

Name

Type

Required

Description

headset

string

yes

The profile used by this headset will be saved.

profile

string

yes

The name of the profile.

If no profile with that name exists, then the method creates a new profile.

If it is the name of the profile that was previously loaded to this headset, then the method saves to this profile.

Status rename

Rename an existing profile.

Name

Type

Required

Description

profile

string

yes

The name of the profile you want to rename.

newProfileName

string

yes

The new name of the profile.

Status delete

Delete an existing profile. If this profile is loaded for a headset, then it is automatically unloaded. You cannot delete a profile that is currently loaded by another application.

Name

Type

Required

Description

profile

string

yes

The name of the profile you want to delete.

Result

The result is an object containing these fields:

Name

Type

Description

action

string

The status you used in the request.

name

string

The profile you used in the request.

message

string

A success message.

Examples

Create a new empty profile

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "setupProfile",
    "params": {
        "cortexToken": "xxx",
        "profile": "cortex-v2-example",
        "status": "create"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "action": "create",
        "message": "...",
        "name": "cortex-v2-example"
    }
}

Load a profile for a headset

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "setupProfile",
    "params": {
        "cortexToken": "xxx",
        "headset": "EPOCPLUS-12341234",
        "profile": "cortex-v2-example",
        "status": "load"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "action": "load",
        "message": "The profile is loaded successfully",
        "name": "cortex-v2-example"
    }
}

Save a profile

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "setupProfile",
    "params": {
        "cortexToken": "xxx",
        "headset": "EPOCPLUS-12341234",
        "profile": "cortex-v2-example",
        "status": "save"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "action": "save",
        "message": "The profile is saved successfully",
        "name": "cortex-v2-example"
    }
}

getCurrentProfile

This method returns the training profile that is currently loaded for a specific headset.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

headset

string

yes

A headset id returned by .

Result

The result is an object containing these fields:

Name

Type

Description

name

string

The name of the loaded profile, or null if no profile was loaded for this headset.

loadedByThisApp

boolean

true if the profile was loaded by your application, false if it was loaded by another application.

This field was added in Cortex 2.1

Examples

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getCurrentProfile",
    "params": {
        "cortexToken": "xxx",
        "headset": "EPOCPLUS-12341234"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "name": "my profile",
        "loadedByThisApp": true
    }
}

getDemographicAttributes

This method returns the list of valid names and values for the demographic attribute objects.

This method was added in Cortex 2.1

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

Result

The result is an array of objects. Each object contain these fields:

Name

Type

Description

name

string

The name of the demographic attribute.

value

array of strings

The list of all the possible values for this attribute.

Example

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getDemographicAttributes",
    "params": {
        "cortexToken": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
    {
        "name": "Education",
        "value": [
            "Below high school",
            "High school or equivalent",
            "Vocational/technical training",
            "Bachelor's degree",
            "Master's degree",
            "Doctoral degree",
            "Prof. degree (medical, law, etc. )"
        ]
    },
    {
        "name": "Handedness",
        "value": [
            "Left",
            "Right",
            "Ambidextrous",
            "Unspecified"
        ]
    },
    {
        "name": "Language ability",
        "value": [
            "Native Language Only",
            "Bilingual",
            "Multilingual"
        ]
    },
    {
        "name": "Musical skills",
        "value": [
            "None",
            "Single instrumentalist",
            "Multi-instrumentalist",
            "Vocalist",
            "Vocalist & instrumentalist"
        ]
    },
    {
        "name": "Profession",
        "value": [
            "Architecture",
            "Art and design",
            "Entertainment and media",
            "Sports",
            "Building and grounds cleaning",
            "Business and finance",
            "Community and social service",
            "Computer and mathematical",
            "Construction and extraction",
            "Engineering",
            "Education and training",
            "Farming, fishing, and forestry",
            "Food preparation and serving",
            "Healthcare practitioners",
            "Healthcare technicians",
            "Healthcare support",
            "Installation and maintenance",
            "Legal",
            "Physical and social science",
            "Management",
            "Office and administration",
            "Personal care and service",
            "Production and manufacturing",
            "Protective service",
            "Sales",
            "Transportation and logistics",
            "Homemaker",
            "Retired",
            "Student",
            "Unemployed"
        ]
    }
    ]
}

facialExpressionThreshold

This method can get or set the threshold of a facial expression action for a specific profile.

Actions with a low threshold are less likely to be detected. Actions with a high threshold will be detected more often.

Parameters

You must set one of these 2 parameters: profile or session. for details.

Result

If the status is "get", then the result is a number that is the current threshold of the action. If the status is "set", then the result is a string that is a success message.

Examples

Get

Set

Subject object

A subject represents a human being who is the subject of a (ie an experiment).

Description

A subject object includes these fields:

Demographic attribute object

The field attributes is a list of attributes. A demographic attribute is an object with 2 fields:

You must call to know what are the valid attribute names, and what are the possible values for each attribute.

For example, to tell that the subject is right handed, you can add the attribute { "name":"Handedness", "value":"Right"}

Example

getTrainingTime

This method returns the duration of a training. It is the approximate time needed by Cortex to decide if a training is a success or a failure. See for details.

Parameters

Result

The result is an object containing these fields:

The time should be 8 seconds, for both mental command and facial expression.

Examples

getDetectionInfo

This method returns useful information about the mental command training or the facial expression training.

Parameters

Result

The result is an object containing information about the detection you specified in the parameters.

Examples

Mental command

Facial expression

training

This method is to control the training of the mental command and facial expression detections. Before you start a training, you should to the "sys" data stream.

See for details.

Parameters

status

To get the available status for a detection, call , and check the field controls of the result object. Or you can check this list:

action

To get the available actions for a detection, call , and check the field actions of the result object.

However, note that for the facial expression detection, only these actions can be trained: "neutral", "surprise", "frown", "smile", "clench".

Result

The result is an object containing these fields:

Examples

Start a training

Start a mental command training for the action "push".

Accept a training

Accept a successful training for the action "push".

facialExpressionSignatureType

This method can get or set the signature used by the facial expression detection.

The "universal" signature contains some generic parameters. It doesn't need (nor accept) any training. It is the default signature. Cortex uses it automatically when the profile doesn't contain any training.

The "trained" signature uses the from the user. The profile must contain at least one training before you can switch to this signature.

Parameters

You must set one of these 2 parameters: profile or session. for details.

Result

The result is an object containing these fields:

Examples

Get

Set

mentalCommandActiveAction

This method is to get or set the active actions for the mental command detection.

If an action is inactive, then the mental command detection won't detect it anymore. Deactivate an action do not erase its trainings from the profile.

Check out and in our BCI app.

Parameters

You must set one of these 2 parameters: profile or session. for details.

Result

If the status is "get", then the result is an array of strings that is the list of active actions.

If the status is "set", then the result is an object with these fields:

Examples

Get

Set

Advanced BCI

In this section, you will find some advanced BCI features. Please read the section first.

The methods in this section are to read and modify the attributes of a training profile. Changing these attributes affects the way the facial expression and mental command detections work. It can make an action easier to detect, or it can completely disable an action.

You can use to change the attributes of a profile and see how it affects the detections.

Profile name or session id

Most of the methods takes 2 optional parameters, a profile name and a session id.

You must set one of these 2 parameters, and omit the second parameter.

If you set the profile, then Cortex will read the attributes of a profile from the hard drive. You can only read the attributes, you cannot change them. The profile is read only.

If you set the session, then Cortex will read the attributes of a profile currently loaded in-memory. You can also change these attributes. The profile is in read-write mode. After you edited the attributes, you should to persist your changes.

If Cortex tells you that profile is a required parameter, then please set this parameter to an empty string.

There is a bug in Cortex 2.0.0. The parameter profile is required, even if you set the parameter session. So, to read/write attributes from a session, you should set the session to your session id and set profile to an empty string. Don't set it to null, don't omit it. This bug is fixed in Cortex version 2.1.0 and above.

mentalCommandTrainingThreshold

This method returns the training threshold of the mental command detection. It also returns the score of the last mental command training.

The training threshold provides an indication of minimum threshold that you should target for when training the action, and it changes according to number of total actions that you have currently activated. Any training score above the threshold is very likely to improve your profile. Any training significantly below the threshold is likely to reduce the quality of your profile.

Check out the usage in our app.

Parameters

You must set one of these 2 parameters: profile or session. for details.

Result

The result is an object containing these fields:

Examples

mentalCommandGetSkillRating

This method returns the skill rating of a mental command action, or the overall mental command skill rating. This is a measure of how often you can trigger the desired action as measured in the previous trainings. A higher rating indicates stronger ability to perform that action.

Deprecated: this method is superseded by and will be removed in the future.

Parameters

You must set one of these 2 parameters: profile or session. for details.

Result

The result is a number that is the requested skill rating.

Examples

mentalCommandBrainMap

This method returns the brain map of a profile. The brain map is a graphic representation of the mental command training of the user. It indicates which actions are most distinct from each other and from the neutral state as measured by how often the training data is misclassified. The better training you do, the more separated the coordinates will be.

Check out the usage in our app.

Parameters

You must set one of these 2 parameters: profile or session. for details.

Result

The result is an array of objects. Each object is represents a trained actions and contains these fields:

Examples

authorize
createRecord
record object
authorize
subject objects
authorize
createSession
marker object
authorize
Alpha-2 ISO code
Subject object
authorize
license
license
authorize
authorize
readonly profile
authorize
queryHeadsets
authorize
Alpha-2 ISO code
Subject object
authorize
queryHeadsets
queryProfile
authorize
queryHeadsets
authorize

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

status

string

yes

Must be "get" or "set".

action

string

yes

You get or set the threshold for this action.

profile

string

no

A profile name.

session

string

no

A session id returned by createSession.

value

number

no

If the status is "set", this parameter must be a number between 0 and 1000. This will be the new threshold of the action.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "facialExpressionThreshold",
    "params": {
        "action": "blink",
        "cortexToken": "xxx",
        "session": "1d5d3655-d570-4731-9faf-967bc5440dc5",
        "status": "get"
    }
}
{
    "id":1,
    "jsonrpc":"2.0",
    "result":500
}
{
    "id": 2323514,
    "jsonrpc": "2.0",
    "method": "facialExpressionThreshold",
    "params": {
        "action": "surprise",
        "cortexToken": "xxx",
        "session": "1d5d3655-d570-4731-9faf-967bc5440dc5",
        "status": "set",
        "value": 703
    }
}
{
    "id": 2323514,
    "jsonrpc": "2.0",
    "result": "success"
}
Read this

Name

Type

Description

subjectName

string

The name of the subject.

dateOfBirth

string

The date of birth of the subject. The format is "YYYY-MM-DD", e.g. "1980-12-25".

sex

string

Can be "M", "F" or "U". These letters stands for male, female and unknown respectively.

experimentsCount

number

countryCode

string

The Alpha-2 ISO code of the country the subject lives in.

countryName

string

The name of the country the subject lives in.

state

string

The state the subject lives in.

city

string

The city the subject lives in.

attributes

array of objects

A list of demographic attribute objects. See below.

Name

Type

Required

Description

name

string

yes

The name of the attribute.

value

string

yes

The value of the attribute.

{
    "attributes": [
        {
            "name": "Handedness",
            "value": "Left"
        },
        {
            "name": "Education",
            "value": "Master's degree"
        }
    ],
    "city": "London",
    "countryCode": "GB",
    "countryName": "",
    "dateOfBirth": "1980-12-25",
    "experimentsCount": 3,
    "modifiedDatetime": "2019-07-01T11:23:11.644+07:00",
    "sex": "F",
    "state": "",
    "subjectName": "Alice Smith"
}
record
getDemographicAttributes

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

session

string

yes

A session id returned by createSession. The training will be for the headset linked to this session.

detection

string

yes

Must be "mentalCommand" or "facialExpression".

status

string

yes

Control what this method does, like start the training, or cancel it... Available status depends on which detection you selected.

action

string

yes

The action you want to train. Available actions depends on which detection you selected.

Status

Description

start

Start a new training for the specified action.

accept

Accept a successful training and add it to the profile.

reject

Reject a successful training. It is not added to the profile.

reset

Cancel the current training.

erase

Erase all the training data for the specified action.

Name

Type

Description

action

string

The action you set in the request.

status

string

The status you set in the request.

message

string

A success message.

{
    "id": 14,
    "jsonrpc": "2.0",
    "method": "training",
    "params": {
        "action": "push",
        "cortexToken": "xxx",
        "detection": "mentalCommand",
        "session": "f3a35fd0-9163-4cc4-ab30-4ed224369f91",
        "status": "start"
    }
}
{
    "id": 14,
    "jsonrpc": "2.0",
    "result": {
        "action": "push",
        "message": "Set up training successfully",
        "status": "start"
    }
}
{
    "id": 15,
    "jsonrpc": "2.0",
    "method": "training",
    "params": {
        "action": "push",
        "cortexToken": "xxx",
        "detection": "mentalCommand",
        "session": "f3a35fd0-9163-4cc4-ab30-4ed224369f91",
        "status": "accept"
    }
}
{
    "id": 15,
    "jsonrpc": "2.0",
    "result": {
        "action": "push",
        "message": "Set up training successfully",
        "status": "accept"
    }
}
subscribe
BCI
getDetectionInfo
getDetectionInfo

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

status

string

yes

Must be "get" or "set".

profile

string

no

The name of a profile.

session

string

no

A session id returned by createSession.

signature

string

no

If the status is "set", then this parameter must be "universal" or "trained".

Name

Type

Description

currentSig

string

The current signature used by the profile. Can be "universal" or "trained".

availableSig

array of strings

The signatures you can use with the profile. The "universal" one is always available, but the "trained" one requires some training.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "facialExpressionSignatureType",
    "params": {
        "cortexToken": "xxx",
        "status": "get",
        "session": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "currentSig": "universal",
        "availableSig": ["universal","trained"]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "facialExpressionSignatureType",
    "params": {
        "cortexToken": "xxx",
        "status": "set",
        "session": "xxx",
        "signature": "trained"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "currentSig": "trained",
        "availableSig": ["universal","trained"]
    }
}
training
Read this

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

status

string

yes

Must be "set" or "get".

profile

string

no

A profile name.

session

string

no

A session id returned by createSession.

actions

array of string

no

If the status is "set", this parameter is the list of actions to activate. You can't activate more than 4 actions. This doesn't include "neutral".

Name

Type

Description

actions

array of strings

The active actions.

message

string

A success message.

{
    "id": 544314,
    "jsonrpc": "2.0",
    "method": "mentalCommandActiveAction",
    "params": {
        "cortexToken": "xxx",
        "profile": "cortex-v2-example",
        "status": "get"
    }
}
{
    "id": 544314,
    "jsonrpc": "2.0",
    "result": [
        "neutral",
        "push",
        "pull"
    ]
}
{
    "id": 411114,
    "jsonrpc": "2.0",
    "method": "mentalCommandActiveAction",
    "params": {
        "actions": [
            "push"
        ],
        "cortexToken": "xxx",
        "session": "1d5d3655-d570-4731-9faf-967bc5440dc5",
        "status": "set"
    }
}
{
    "id": 411114,
    "jsonrpc": "2.0",
    "result": {
        "actions": [
            "push"
        ],
        "message": "Set MentalCommand active actions successfully"
    }
}
adding new commands
deactivating commands
Read this

Name

Type

Required

Description

profile

string

no

The name of a profile.

session

string

no

A session id returned by createSession.

BCI
EmotivBCI
save the profile

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

profile

string

no

A profile name

session

string

no

A session id returned by createSession.

Name

Type

Description

currentThreshold

number

The threshold of the mental command detection.

lastTrainingScore

number

The score of the last mental command training.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "mentalCommandTrainingThreshold",
    "params": {
        "cortexToken": "xxx",
        "session": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "currentThreshold": 0.83,
        "lastTrainingScore": 0.40
    }
}
BCI
Read this

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

detection

string

yes

Must be "mentalCommand" or "facialExpression".

session

string

yes

A session id returned by createSession.

Name

Type

Description

time

number

The approximate duration of a training, in second.

detection

string

The detection you set in the request.

BCI
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getTrainingTime",
    "params": {
        "cortexToken": "xxx",
        "detection": "mentalCommand",
        "session": "xxx"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "time": 8,
        "detection": "mentalCommand"
    }
}

Name

Type

Required

Description

detection

string

yes

Must be "mentalCommand" or "facialExpression".

Name

Type

Description

actions

array of strings

The actions that this detection can detect.

controls

array of strings

The list of the status you can use when you call the training method.

events

array of strings

The events you can receive in the "sys" data stream when you train this detection.

signature

array of strings

The different types of signature that you can get or set with facialExpressionSignatureType.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getDetectionInfo",
    "params": {
        "detection": "facialExpression"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "actions": [
            "neutral",
            "blink",
            "winkL",
            "winkR",
            "horiEye",
            "surprise",
            "frown",
            "smile",
            "clench",
            "laugh",
            "smirkLeft",
            "smirkRight"
        ],
        "controls": [
            "start",
            "accept",
            "reject",
            "erase",
            "reset"
        ],
        "events": [
            "FE_Started",
            "FE_Succeeded",
            "FE_Failed",
            "FE_Completed",
            "FE_DataErased",
            "FE_Rejected",
            "FE_Reset"
        ],
        "signature": [
            "universal",
            "trained"
        ]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getDetectionInfo",
    "params": {
        "detection": "mentalCommand"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "actions": [
            "neutral",
            "push",
            "pull",
            "lift",
            "drop",
            "left",
            "right",
            "rotateLeft",
            "rotateRight",
            "rotateClockwise",
            "rotateCounterClockwise",
            "rotateForwards",
            "rotateReverse",
            "disappear"
        ],
        "controls": [
            "start",
            "accept",
            "reject",
            "erase",
            "reset"
        ],
        "events": [
            "MC_Started",
            "MC_Succeeded",
            "MC_Failed",
            "MC_Completed",
            "MC_DataErased",
            "MC_Rejected",
            "MC_Reset",
            "MC_AutoSamplingNeutralCompleted",
            "MC_SignatureUpdated"
        ],
        "signature": []
    }
}

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

profile

string

no

A profile name.

session

string

no

A session id returned by createSession.

action

string

no

The mental command action. If omitted, then this method returns the overall skill ratting.

mentalCommandBrainMap
Read this
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "mentalCommandGetSkillRating",
    "params": {
        "cortexToken": "xxx",
        "session": "xxx",
        "action": "push"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": 0.25
}

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

profile

string

no

A profile name.

session

string

no

A session id returned by createSession.

Name

Type

Description

action

string

The action name.

coordinates

array of 2 numbers

The (x, y) coordinates of this action in the brain map. x is in range [-1.0, 1.0] and y is in range [0.0, 1.0].

BCI
Read this
{
    "id": 5891714,
    "jsonrpc": "2.0",
    "method": "mentalCommandBrainMap",
    "params": {
        "cortexToken": "xxx",
        "profile": "cortex-v2-example",
        "session": "1d5d3655-d570-4731-9faf-967bc5440dc5"
    }
}
{
    "id": 5891714,
    "jsonrpc": "2.0",
    "result": [
        {
            "action": "neutral",
            "coordinates": [0,0]
        },
        {
            "action": "push",
            "coordinates": [0.08947246481272716,0.1596770200887308]
        }
    ]
}

Troubleshooting Guide

Whitelisting Domains for EMOTIV Applications

If you are encountering issues with EMOTIV Cortex or applications communicating with the EMOTIV Cloud, it may be due to some essential domains being blocked by your firewall, network settings, or security software. To ensure smooth operation, you will need to whitelist the following domains:

Essential Domains to Whitelist:

  1. *.emotivcloud.com

  2. *.emotiv.com

  3. emotiv-cortex-prod-dropbox.s3.amazonaws.com

  4. emotiv-cortex-prod-dropbox.s3.us-east-1.amazonaws.com

  5. cerebrum-prod.s3.amazonaws.com

  6. cerebrum-prod.s3.us-east-1.amazonaws.com

Step-by-Step Instructions:

  1. Firewall Settings:

    1. Open your firewall application or built-in firewall settings.

    2. Locate the section where you can add exceptions or whitelist URLs/domains.

    3. Manually input each of the domains listed above into this section.

    4. Save or apply the changes.

  2. Security Software:

    1. Launch your antivirus or security software.

    2. Navigate to the settings or configuration section.

    3. Search for an option related to whitelisting or exclusions.

    4. Add each of the listed domains as exclusions.

    5. Confirm and save your changes.

  3. Router Settings (if you suspect your router is blocking access):

    1. Access your router's admin panel. (Refer to the router's manual or online documentation for specifics).

    2. Locate the section related to security or URL filtering.

    3. Add each domain to the list of allowed domains or URLs.

    4. Save or apply the changes.

Notes:

  • Always ensure that you are only whitelisting domains from trusted sources. The domains listed here are essential for EMOTIV Cortex and applications.

  • If you use additional network or security tools that might restrict access, ensure you update them to allow the domains listed above.

  • After whitelisting, restart your EMOTIV application and check if the issue is resolved.

  • If problems persist, consider reaching out to EMOTIV's support team or refer to other troubleshooting documentation provided by EMOTIV.

This guide aims to simplify the process for you. Depending on the specific software or hardware you are using, some steps might look a bit different. When in doubt, refer to the user manual or help section of your software or device.

Error Codes

Here is a list of the error codes that the Cortex API can return. This list is not exhaustive (yet) and will be updated in the future.

-32700 Parse Error

The message you sent to Cortex is not a valid JSON object. This is a bug is your application.

-32600 Invalid Request

The message you sent to Cortex is a valid JSON object but it doesn't contain the expected fields. This a bug is your application. Please check Connecting to the Cortex API

-32601 Method Not Found

You sent a request with an invalid method name. This a bug is your application. Please check this documentation to see which methods are available.

-32602 Invalid Parameters

You sent a request to call a valid method, but the parameters are wrong. It can be because:

  • You didn't provide a required parameter

  • You provided a parameters with an invalid name

  • The name of parameter is correct but the value is invalid

This is a bug in your application. Please check the documentation of the method.

-32603 Internal Error

An unexpected error happened in Cortex while processing your request. This is probably a bug in Cortex. If the problem persists, please contact the EMOTIV customer support.

-32000 Server Internal Error

An unexpected error happened in the EMOTIV cloud while processing your request. It can be a temporary failure of the EMOTIV servers, like when the servers are in maintenance. Or it can be a bug in Cortex. If the problem persists, please contact the EMOTIV customer support.

-32002 Invalid License ID

The EMOTIV cloud cannot find the license of the user. When you call the method authorize, please make sure that you provide a valid license ID, or no license parameter at all. If the problem persists, then the owner of the license must contact the EMOTIV customer support.

-32003 Internet Connection Error

Cortex must connect to the EMOTIV cloud to process your request, but the connection failed. Please make sure that you computer has a working internet connection.

-32004 Headset Unavailable

You sent a request to perform an action on a specific headset, but Cortex cannot find this headset. Some possible reasons for this error:

  • You provided an invalid headset ID in your request

  • The headset was disconnected (maybe it is out of range of your computer)

  • The headset was switched off

-32005 A session already exists with this headset

You called the method createSession for a specific headset, but your application already has a session for this headset. This is a bug in your application. You cannot create 2 sessions for the same headset at the same time. You must close the existing session before creating a new one.

-32006 No license to activate a session

You called createSession or updateSession with the parameter "status" set to "active", but your license doesn't authorize you to activate a session. You have a paid EMOTIV license to activate a session. If you already have such a license but the problem still persists, then contact the EMOTIV customer support. You should also read the prerequisite.

-32007 The session doesn't exist

You included a session ID in the parameters of your request, but Cortex cannot find this session. It can be because you session ID is invalid or because the session is already closed.

Many methods can return this error: updateSession, subscribe, unsubscribe, createRecord, injectMarker, training, etc...

-32012 The session must be activated

You called a method that requires an active session, but the current session is inactive. It can happen if you call createRecord on an inactive session.

-32014 Invalid Cortex token

You included a Cortex token in the parameters of your request, but this token is invalid. This is a bug in your application. When a method requires a Cortex token, please make sure that your token comes from the result of the method authorize.

-32015 The Cortex token has expired

Your Cortex token has expired. You must call the method authorize again to get a new token. The Cortex token is valid for 48 hours.

-32016 Invalid stream

You called the methods subscribe or unsubscribe with an invalid stream. The stream can be invalid for one of these reasons:

  • The name of the stream is incorrect. Check Data Subscription for the list of the available streams.

  • The stream is not available for this headset. For example, the motion data of an EPOC X headset can be disable.

  • The stream is "eeg" but the license doesn't allow you to access this stream. You can check the license with getLicenseInfo

-32017 Record already started

You called createRecord for a specific session, but your application already started a record for the same session. You cannot create 2 records for the same session at the same time.

-32019 Session limit has been reached

You tried to activate a session (with createSession or updateSession) but the "localQuota" of the license is zero. You can check the "localQuota" by calling the method getLicenseInfo. Every time you activate a session, the local quota of the license is reduced by 1.

To solve this error, you must increase the local quota of the license. Call authorize with the parameter "debit". For example, you can call authorize with a "debit" of 10, and this will increase the local quota by 10. Then you will be able to create and activate 10 sessions on this computer.

-32020 The headset must be connected with a USB cable

You called updateHeadset but the headset is connected to the computer via Bluetooth or a USB dongle. Instead, the user should connect the headset with a USB cable.

-32021 Invalid client credentials

Your request includes an invalid client ID or an invalid client secret.

-32022 Device limit has been reached

The license was used on too many devices (eg computer, tablet, phone...) The license has a device limit. You can check it by calling the method getLicenseInfo. If you want to increase the limit or transfer the license from 1 device to another, then please contact the EMOTIV customer support.

-32024 The license has expired

The license of the user has expired. You can check the license with getLicenseInfo. After the license is renewed, your application must call authorize to get a new token.

-32027 Cannot use this license

You called authorize with a valid license ID but your application doesn't have the permission to use this license.

-32029 License hard limit has been reached

When the computer is offline, you can use the license for a limited period of time. The end of this period is the "hard limit" of the license. You can check it with getLicenseInfo. After the "hard limit" has been reached, Cortex must connect to the EMOTIV cloud to validate the license again. To solve this problem, the computer must have an internet connection and then you must call authorize.

-32031 Invalid profile name

You sent a request to perform an action on a specific training profile, but Cortex cannot find this profile.

-32033 No user

Cortex cannot process your request because no user is logged in. You must ask the user to log in in EMOTIV Launcher.

-32034 The Cortex token is for another user

Your request includes a Cortex token that was created for a specific user, but the current user is a different one. In that case, that must call authorize again and get a new token. You can check the current user with getUserLogin.

-32037 Cannot train this action

You called training for an action that cannot be trained.

-32044 Profile already loaded on another headset

You tried to load a training profile for a specific headset, but this profile is already loaded for another headset. You cannot load the same profile on 2 different headset at the same time.

-32045 No profile loaded for this headset

You tried to unload a training profile from a headset, but no profile was loaded for this headset.

-32046 Profile loaded by another application

You tried to perform an operation (eg setupProfile, training...) on a training profile, but this profile was loaded by another application. An application can only access a profile that loaded by itself. You can call getCurrentProfile to check if your application loaded the profile of a headset or not.

-32102 Not approved in EMOTIV Launcher

The user didn't approved your application yet. The user must open EMOTIV Launcher and approve your application.

-32104 Failed to connect or disconnect the headset

Cortex failed to communicate with the headset. Maybe the wireless connection between the headset and the computer was interrupted. Your application should try again. You can also call queryHeadsets to check the status of the headset.

-32106 The user account is not active

The EMOTIV ID of the user is inactive. The user must contact the EMOTIV customer support. You can call getUserLogin or getUserInformation to check the current user.

-32108 Cloud token error

The EMOTIV cloud refused the user credentials provided by Cortex. The user must logout and login again.

-32109 Cortex token error

There is something wrong with the Cortex token. Your application must call authorize to get a new Cortex token.

-32110 Must be online to use this license

Your license cannot work when you are offline. You must be connected to the internet at all time to use this license. You can call getLicenseInfo to check the current license.

-32112 The session is already active

You tried to activate a session that is already active. You can call querySessions to check the status of your sessions.

-32113 Invalid record ID

You are trying to access a record that doesn't exist, or the record exist but you don't have the permission to access it.

-32114 No record in progress

You are trying to inject a marker or to stop a record but no record is is progress.

-32115 The time of the marker is too far in the past

You are trying to inject a marker but its time is too far in the past. You should inject your markers in real time, at the moment the event you want to mark happens.

-32116 The time of the marker is too far in the future

You are trying to inject a marker but its time is too far in the future. You should inject your markers in real time, at the moment the event you want to mark happens.

-32117 Marker not found

You called updateMarker with an invalid marker id.

-32118 The profile name already exists

You are trying to create or rename a training profile, but another profile with the same name already exists.

-32119 The marker is already stopped

You are trying to update a marker that was already updated before.

-32123 Corrupted database

The local Cortex database is corrupted. Please contact the EMOTIV customer support.

-32124 Subject not found

You are trying to update or delete a subject that doesn't exist. Or you are trying to create a record with an invalid subject.

-32125 Subject already exists

You are trying to create a subject, but another subject with the same name already exists.

-32127 Profile already loaded for this headset

You are trying to load a training profile for a headset, but a profile was already loaded for this headset before. You must unload the current profile before loading a new one.

-32129 Invalid record title

You are trying to create or update a record, but the record title is invalid. The title must be 200 characters long or less.

-32137 Cannot open output file

You are trying to export a record but Cortex cannot open the output CSV or EDF file.

-32138 Stream not supported for export

You are trying to export a record but one of the data streams you requested is not available.

Release Notes

Cortex 4.7.3 - May 2025

  • Fix some cloud synchronization bugs related to records/subjects.

Cortex 4.6.1 - Mar 2025

  • Hot fix MacOS security policy update.

Cortex 4.6.0 - Mar 2025

  • Support for new EpocX firmware 740 with updated encryption method for improved security.

Cortex 4.5.7 - Feb 2025

  • Hot fix for an issue related to the new developer license

Cortex 4.5.6 - Jan 2025

  • Support the new developer license (for Consumer headsets)

  • Bug fixes

Cortex 4.5.3 - Jan 2025

  • Support MW20 headset (beta support, internal use only)

  • Bug fixes

Cortex 4.4.7 - Dec 2024

  • Data synchronization improvement: download records from latest to oldest

Cortex 4.4.5 - Nov 2024

  • Bug fixes for data synchronization issue

Cortex 4.4.2 - Oct 2024

  • Bug fixes for data synchronization issue, unexpected empty record issue

  • Interpolate CQ data for MN8 when there is data lost

Cortex 4.3.15 - Sep 2024

  • Hot fix for authentication issue on LABS/Builder webapp.

Cortex 4.3.14 - Sep 2024

  • Authentication flow improvement

Cortex 4.3.7 - Aug 2024

  • Bug fixes

Cortex 4.3.5 - Aug 2024

  • Support upgrade firmware of Flex 2 via native Bluetooth connection

Cortex 4.3.3 - Jul 2024

  • Improve firmware upgrading

Cortex 4.3.0 - Jun 2024

  • Support data sharing of organization

  • Support Flex 2 via native Bluetooth connection

  • Bug fixes

Cortex 4.2.7 - Jun 2024

  • Bug fix for extender firmware upgrade (from very old version)

Cortex 4.2.4 - May 2024

  • A hotfix for marker issue

Cortex 4.2.1 - Apr 2024

  • Cortex API usage tracking

Cortex 4.2.0 - Apr 2024

  • Time synchronization between different Emotiv headsets

Cortex 3.8.0 - Jan 2024

  • Support firmware version x2F06 of Flex headset.

Cortex 3.7.8 - Jan 2024

  • Improve headset setting feature for Flex

  • Bug fixes

Cortex 3.7.5 - Jan 2024

  • Support EDF+/BDF+ file format, see exportRecord API.

  • Bug fixes

Cortex 3.7.2 - Dec 2023

  • Improve timestamp algorithm for Flex.

  • Bug fixes

Cortex 3.7.1 - Nov 2023

  • Update new certificate of the Cortex web socket server. The certificate before version 3.7.1 expires on Dec 9, 2023.

  • Bug fixes

Cortex 3.7.0 - Nov 2023

  • Support Flex

  • Upgrade the core framework for BLE connection.

  • Upgrade to OpenSSL 3.0, TLS 1.2

  • Improve data quality

  • New device scanning workflow (see controlDevice with "refresh" command mentioned here).

  • Performance enhancement and minor bug fixes

Cortex 3.6.5 - Aug 2023

  • Training profiles are now supported for only specific types of Emotiv headset. All training profiles created before 3.6.5 will become readonly profiles.

    • See Readonly training profile.

    • See new update on queryProfile API.

  • Bug fixes

Cortex 3.5.6 - Jul 2023

  • Attention detection will replace Focus detection

  • Focus detection can still be found via exportRecord API with includeDeprecatedPM option.

Cortex 3.5.5 - Jun 2023

  • Save more data into database, even there is no record.

Cortex 3.5.4 - Jun 2023

  • Update export policy on EmotivPRO with records from EmotivPRO mobile.

Cortex 3.5.3 - May 2023

  • Support Xtrodes devices on EmotivPRO

Cortex 3.5.2 - Apr 2023

  • Roll back the core framework for BLE connection (since the new version in 3.5.0/3.5.1 is not really stable).

  • Bug fixes

Cortex 3.5.1 - March 2023

  • Hotfix for BTLE connection.

Cortex 3.5.0 - March 2023

  • Improve timestamp correction algorithm.

  • exportRecord() API will also export survey data in CSV format (along with JSON format).

  • Upgrade the core framework for BLE connection.

Cortex 3.4.2 - October 2022

  • New system requirement on Raspberry Pi:

    • Raspberry Pi OS - Debian version 11 (Beta release, 32-bit)

Cortex 3.4.1 - September 2022

  • New system requirement on MacOS/Windows:

    • Windows 10 (64-bit) v1809+

    • macOS 10.14 Mojave or above

Cortex 3.2 - January 2022

  • Support the new Insight 2.0 headset

Cortex 3.1.3 - December 2021

  • Support macOS 12.1

Cortex 3.1.1, 3.1.2 - December 2021

  • Bug fixes on some instances where the database cannot be initialised properly

Cortex 3.1 - December 2021

  • New method added syncWithHeadsetClock

Cortex 3.0.1 - November 2021

  • No change in the Cortex API

  • Bug fixes, make the Bluetooth connection more stable

Cortex 3.0 - October 2021

  • No change in the Cortex API

  • EMOTIV App is now called EMOTIV Launcher

  • Cortex 3.0 is not compatible with Windows 8. See the system requirements.

Cortex 2.7.3 - August 2021

  • Fixed the scaled value from Interest / Valance that may go out of range in some cases.

  • Fixed Focus / Stress performance metrics with EPOC X.

Cortex 2.7.2 - July 2021

  • No change in the Cortex API

Cortex 2.7.1 - May 2021

  • It is now possible to run all the detections with an EPOC Flex headset. This requires a specific EEG sensor mapping. See Data Subscription for details.

  • Cortex is now available for Raspberry Pi OS

Check the Getting Started page to see all the supported headsets and platforms.

Cortex 2.7.0 - April 2021

  • New data stream "eq" to get the EEG quality. See Data sample object. Please read this page to understand the difference between the contact quality and the EEG quality.

  • New label "BatteryPercent" added to the "dev" data stream. See Data sample object.

  • The method exportRecord is now available on iOS and Android

Cortex 2.6.4 - March 2021

  • Bug fixes

  • No change in the Cortex API

Cortex 2.6.3 - January 2021

  • New parameters added to the method exportRecord

  • New parameters added to the method queryRecords

  • Cortex is now available for Linux Ubuntu (Beta release)

Check the Getting Started page to see all the supported headsets and platforms.

Cortex 2.6.2 - December 2020

  • Solve an issue on macOS 11, where EMOTIV headsets couldn't connect by Bluetooth.

  • No change in the Cortex API

Cortex 2.6.1 - November 2020

  • No change in the Cortex API

Cortex 2.6.0 - September 2020

  • The sample rate of the data stream "dev" is now 2 hertz. See Data Subscription for details.

  • macOS 10.12 Sierra is not supported anymore. In order to install Cortex 2.6.0 you must upgrade your Mac to macOS 10.13 High Sierra or above.

Check the Getting Started page to see all the supported headsets and platforms.

Cortex 2.5.0 - June 2020

  • Support the new MN8 headset

  • Support for iOS and Android (Beta release, see the announcement for details)

  • New parameter title added to the method updateRecord

  • In the method queryRecords, you can now order the records by their applicationId.

  • New warning code 112 and 113

Check the Getting Started page to see all the supported headsets and platforms.

Cortex 2.4.0 - March 2020

  • Support the new EPOC X headset

  • New field headbandPosition added in the Headset object and the Record object (EPOC X only)

  • New method added updateHeadsetCustomInfo to set the position of the headband (EPOC X only)

  • New field customName added in the Headset object

  • Change in the result of the method updateHeadset, new warning added to get the result of this method

  • New label overall in the device information sample object

Cortex 2.3.0 - December 2019

  • New parameter includeFlexMappings added to the method queryHeadsets

  • New field lastLoginTime added in the result of the method getUserLogin

Cortex 2.2.1- October 2019

  • New method added configOptOut

  • New parameter connectionType added to the method controlDevice

  • New parameter experimentId added to the method createRecord

  • New Warning added when the available space on the hard drive is too low

  • New Warning added when the opt-out configuration changes

  • New label isActive in the performance metrics sample object

Cortex 2.2.0 - September 2019

This version didn't introduce any change in the API.

Cortex 2.1.1 - August 2019

  • New method added exportRecord

Cortex 2.1.0 - August 2019

  • New methods added to manage the Subjects

Changes from Cortex 1.x to Cortex V2.0

There are significant changes from Cortex API version 1.x to 2.0.

WebSocket URL

To connect to Cortex 1.x, you used the url wss://emotivcortex.com:54321 In Cortex 2.0, you must use wss://localhost:6868

See Connecting to the Cortex API for details.

Authentication

In Cortex 2.0, the user must login with EmotivID through the EMOTIV App. So, the API doesn't have a login or logout method anymore.

Third party applications must be approved by the user before using the Cortex API. See the new method requestAccess.

The method authorize doesn't accept "anonymous mode" anymore. You must provide a client id and client secret.

See Authentication for details.

Headsets

Call the method controlDevice to connect a headset to Cortex. If the headset is not connected, then you can't create a session with this headset.

See Headsets for details.

Miscellaneous

Some methods have been removed or renamed.

Method name in v1

Equivalent in v2

login, logout

See

acceptLicense

The user must accept the EULA in EMOTIV App. You can call to check if the user already accepted the EULA or not

controlBluetoothHeadset

See

updateNote

See

The parameters and result format of some methods have changed. If you get an error when calling a method, please check its documentation.

getTrainedSignatureActions

This method returns the list of the trained actions of a profile. For each action, you also see how many times the user trained this action.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

detection

string

yes

Must be "mentalCommand" or "facialExpression".

profile

string

no

The name of a profile.

session

string

no

A session id returned by .

You must set one of these 2 parameters: profile or session. Read this for details.

If you set the session, then this method reads information from the profile that is currently loaded for the headset of this session.

If you set profile then this method reads information from the hard drive. The values you get can be different from reading from the session, especially if the profile was load, edited, and not saved yet.

Result

The result is an object containing these fields:

Name

Type

Description

trainedActions

array of objects

Contains 1 object for each trained action.

totalTimesTraining

number

The total number of training the user did since the creation of this profile.

The objects in trainedActions have 2 fields:

Name

Type

Description

action

string

The name of the action.

times

number

How many times the user trained this action.

Examples

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getTrainedSignatureActions",
    "params": {
        "cortexToken": "xxx",
        "detection": "mentalCommand",
        "profile": "cortex-v2-example"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "totalTimesTraining": 12,
        "trainedActions": [
            {
                "action": "neutral",
                "times": 1
            },
            {
                "action": "push",
                "times": 1
            },
            {
                "action": "pull",
                "times": 1
            }
        ]
    }
}

Warning Objects

In addition to method responses and data samples, Cortex can send a third type of message, called warnings.

These warnings inform your application about important events, like when the user logs in or out, or when a training profile is loaded or unloaded for a headset.

Description

A warning object contain these fields:

Name

Type

Description

jsonrpc

string

Always has the value "2.0".

warning

object

An object with the fields "code" and "message".

The warning object has 2 fields:

Name

Type

Description

code

number

The code of this warning. The possible codes are documented below.

message

any

The type and value of this field depends on the code. For most of the warnings it is just a string, but it can also be an object. See the examples below.

Warning Codes

The possible codes are:

Code

Description

0

All the data streams you subscribed to have been automatically canceled by Cortex. This can happen if the headset was disconnected.

1

Your session was automatically closed by Cortex. This can happen if the headset was disconnected.

2

The user has logged in with EMOTIV App.

3

The user has logged out with EMOTIV App.

9

The user approved your application in EMOTIV App.

10

The user declined your application in EMOTIV App.

13

A training profile was loaded for a headset using

14

A training profile was unloaded for a headset using .

15

A training profile was automatically unloaded by Cortex. This can happen if the headset was disconnected, or if the application that loaded this profile was disconnected from Cortex.

17

The user accepted the EULA in EMOTIV App.

18

The record data has been successfully saved. Cortex sends this warning when a record is done with some long-run post processing after record is stopped.

19

The available disk space is low. Cortex send this warning when there is less then 1 GB available of the hard drive.

This warning was added in Cortex 2.2.1

20

The available disk space is critically low. Cortex send this warning when there is less then 300 MB available of the hard drive. When this happens Cortex automatically disconnect all the headsets. You cannot until the user free up some space.

This warning was added in Cortex 2.2.1

21

The user has changed the configuration.

This warning was added in Cortex 2.2.1

22

Cortex has changed the configuration. This can happen when the license of the user is updated.

This warning was added in Cortex 2.2.1

26

The license of the user will expire in a few days.

This warning was added in Cortex 2.3.0

30

Data post-processing finishes. After record stops, Cortex still needs to run a lengthy process to improve timestamps or combine broken sessions. If you want to export the record just after it stops, you should wait until this warning is emitted from Cortex.

100 and 101

Cortex failed to connect to a headset. If the headset uses a Bluetooth connection, then you should try to disconnect the headset from the Bluetooth manager of the OS.

102

Cortex reached a timeout while trying to connect to a headset. This can happen if the wireless connection is of poor quality.

103

Cortex disconnected a headset because it didn't receive any data from this headset for more than 30 seconds. This can happen if the headset goes out of range of the computer, or if the wireless connection is of poor quality.

104

Cortex successfully connected to a headset.

110

Cortex successfully updated the configuration of a headset. See .

This warning was added in Cortex 2.4

111

Cortex failed to update the configuration of a headset. See .

This warning was added in Cortex 2.4

112

Cortex successfully updated a headset but the new configuration can only work with a USB dongle connection. The configuration is not compatible with a Bluetooth connection. See .

This warning was added in Cortex 2.5

113

Cortex failed to connect to an EPOC+ or EPOC X headset with Bluetooth. The configuration of the headset is not compatible with a Bluetooth connection. See .

This warning was added in Cortex 2.5

142

Cortex finishes headset scanning which is started by with "refresh" command.

Examples

0 - Data stream unsubscribed

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 0,
        "message": {
            "behavior": "Cortex has stopped all the subscriptions of session 866b8437-2380-4392-9a35-3d5957eaf95d.",
            "sessionId": "866b8437-2380-4392-9a35-3d5957eaf95d"
        }
    }
}

1 - Session closed

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 1,
        "message": {
            "behavior": "Cortex has closed the session 866b8437-2380-4392-9a35-3d5957eaf95d.",
            "sessionId": "866b8437-2380-4392-9a35-3d5957eaf95d"
        }
    }
}

2 - User login

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 2,
        "message": "User jon.snow has already logged in to Cortex."
    }
}

3 - User logout

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 3,
        "message": "User jon.snow has already logged out from Cortex."
    }
}

9 - App access granted

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 9,
        "message": "The access right to the cortex-examples has been granted"
    }
}

10 - App access declined

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 10,
        "message": "The access right to the cortex-examples has been rejected"
    }
}

13 - Profile loaded

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 13,
        "message": {
            "behavior": "Profile is loaded",
            "headset": "INSIGHT-12341234",
            "profile": "foo"
        }
    }
}

14 - 15 - Profile unloaded

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 14,
        "message": {
            "behavior": "Profile is unloaded",
            "headset": "INSIGHT-12341234",
            "profile": "foo"
        }
    }
}
{
    "jsonrpc": "2.0",
    "warning": {
        "code": 15,
        "message": {
            "behavior": "Cortex has unloaded the profile",
            "headset": "INSIGHT-12341234",
            "profile": "foo"
        }
    }
}

17 - EULA accepted

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 17,
        "message": "User jon.snow has accepted the EULA via EMOTIV App"
    }
}

19 - 20 - Disk space

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 19,
        "message": {
            "behavior": "The available disk space is low.",
            "rootPath": "/",
            "volumeName": "MAC"
        }
    }
}
{
    "jsonrpc": "2.0",
    "warning": {
        "code": 20,
        "message": {
            "behavior": "The available disk space is critically low. Cortex will disconnect all the headsets.",
            "rootPath": "C",
            "volumeName": "Windows"
        }
    }
}

21 - 22 - Opt-out configuration changed

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 21,
        "message": {
            "currOptOut": true,
            "forceOptOut": false,
            "message": "User has changed the Opt-out configuration.",
            "optOutAvail": true
        }
    }
}
{
    "jsonrpc": "2.0",
    "warning": {
        "code": 22,
        "message": {
            "currOptOut": true,
            "forceOptOut": false,
            "message": "The Opt-out configuration has been automatically changed due to change in license.",
            "optOutAvail": true
        }
    }
}

100 - 101 - 102 - 113 - Failed to connect to a headset

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 100,
        "message": {
            "headsetId": "EPOCPLUS-3B9AXXXX",
            "behavior": "Headset cannot be connected. Please try again."
        }
    }
}
{
    "jsonrpc": "2.0",
    "warning": {
        "code": 101,
        "message": {
            "headsetId": "EPOCPLUS-3B9AXXXX",
            "behavior": "Headset cannot be connected. Please try again."
        }
    }
}
{
    "jsonrpc": "2.0",
    "warning": {
        "code": 102,
        "message": {
            "headsetId": "EPOCPLUS-3B9AXXXX",
            "behavior": "Headset cannot be connected due to connection timeout."
        }
    }
}
{
    "jsonrpc": "2.0",
    "warning": {
        "code": 113,
        "message": {
            "headsetId": "EPOCPLUS-3B9AXXXX",
            "behavior": "Please disable motion data and set EEG rate to 128Hz in headset configuration when using Bluetooth connection, or use USB dongle."
        }
    }
}

103 - Headset disconnected

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 103,
        "message": {
            "headsetId": "EPOCPLUS-3B9AXXXX",
            "behavior": "Headset has been disconnected due to connection timeout."
        }
    }
}

104 - Headset connected

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 104,
        "message": {
            "headsetId": "EPOCPLUS-3B9AXXXX",
            "behavior": "The headset is connected"
        }
    }
}

110 - Headset update successful

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 110,
        "message": {
            "headsetId": "EPOCPLUS-3B9AXXXX",
            "behavior": "Headset configuration is updated."
        }
    }
}

111 - Headset update failed

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 111,
        "message": {
            "headsetId": "EPOCPLUS-3B9AXXXX",
            "behavior": "Headset configuration update failed."
        }
    }
}

112 - Headset configuration cannot work with Bluetooth

{
    "jsonrpc": "2.0",
    "warning": {
        "code": 112,
        "message": {
            "headsetId": "EPOCPLUS-3B9AXXXX",
            "behavior": "This headset configuration cannot work with BTLE on this platform."
        }
    }
}

mentalCommandActionSensitivity

This method get or set the sensitivity of the 4 active mental command actions.

Check out the usage in our BCI app.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

A token returned by .

status

string

yes

Must be "get" or "set".

profile

string

no

A profile name.

session

string

no

A session id returned by .

values

array of 4 numbers

no

If the status is "set", this parameters is the new sensitivities. Each value must be between 1 and 10. Bigger number indicates higher sensitivity.

You must set one of these 2 parameters: profile or session. Read this for details.

The array values contains the sensitivity of each active actions. The order of the values must follow the order of the active actions, as returned by mentalCommandActiveAction.

Result

If the status is "get", then the result is an array of 4 numbers. If the status is "set", then the result is a success message.

Examples

Get

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "mentalCommandActionSensitivity",
    "params": {
        "cortexToken": "xxx",
        "profile": "cortex-v2-example",
        "status": "get"
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [5,5,5,5]
}

Set

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "mentalCommandActionSensitivity",
    "params": {
        "cortexToken": "xxx",
        "session": "1d5d3655-d570-4731-9faf-967bc5440dc5",
        "status": "set",
        "values": [5,7,5,5]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": "success"
}
getUserLogin
getUserInformation
controlDevice
updateRecord
authorize
createSession
setupProfile
setupProfile
connect a headset
opt-out
opt-out
updateHeadset
updateHeadset
updateHeadset
controlDevice
controlDevice
authorize
createSession