arrow-left

All pages
gitbookPowered by GitBook
1 of 5

Loading...

Loading...

Loading...

Loading...

Loading...

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.

hashtag
Description

A session object includes these fields:

hashtag
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.

hashtag
Examples

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

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 subscribe.

recordIds

array of strings

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

recording

boolean

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

headset

object

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

Status

Description

opened

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

activated

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

closed

This session is closed, you cannot use it anymore.

{
    "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"]
}

querySessions

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

circle-check

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

hashtag
Parameters

hashtag
Result

The result is an array of .

hashtag
Example

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 of the headset

  • create a and add

updateSession

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

hashtag
Parameters

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.

hashtag
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.

hashtag
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.

data stream
record
markers

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

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"]
    }]
}

cortexToken

string

yes

The token returned by .

session

string

yes

A session id returned by .

status

string

yes

Must be "active" or "close".

hashtag
Result

The result is a session object representing the updated session.

hashtag
Examples

hashtag
Activate a session

{
    "id": 1,
    "
{
    "id": 1,
    "

hashtag
Close a session

Name

Type

Required

Description

Sessions
{
    "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": []
    }
}
jsonrpc
"
:
"
2.0
"
,
"method": "updateSession",
"params": {
"cortexToken": "xxx",
"session": "38fef6d7-979b-420b-aa25-dd60ef5edc02",
"status": "active"
}
}
jsonrpc
"
:
"
2.0
"
,
"result": {
"id": "38fef6d7-979b-420b-aa25-dd60ef5edc02",
"status":"activated",
...
}
}
authorize
createSession

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 controlDevice to connect the headset. You cannot open a session with a headset connected by a USB cable. You can use queryHeadsets to check the status and connection type of the headset.

You can use updateSession to activate or close a session.

See Sessions for details.

circle-info

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

hashtag
Parameters

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

hashtag
Result

The result is a representing the created session.

hashtag
Examples

Open a session.

Open a session and activate it.

no

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

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

status

string

yes

Must be "open" or "active".

headset

queryHeadsets
updateSession
session object

string

{
    "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": {
    }
}
queryHeadsets