arrow-left

All pages
gitbookPowered by GitBook
1 of 4

Loading...

Loading...

Loading...

Loading...

Data Subscription

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

Each data stream 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.

hashtag
Data streams

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

hashtag
Data streams availability

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

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.

2

pow

All

8

met

All (EPOC Flex requires a ).

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

8

fac

All (EPOC Flex requires a ) except MN8.

32

sys

All

No fixed rate, see for details.

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 pagearrow-up-right 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.

Stream

Supported headsets

Sample rate in hertz

eeg

All, but requires a license

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

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

Please check the documentationarrow-up-right of your headset.

mot

All

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

6.4 hertz for MN8.

Please check the documentationarrow-up-right of your headset.

dev

All

2

eq

data samples objects

met

All

load a profile
BCI
special EEG sensor mapping
session
special EEG sensor mapping
special EEG sensor mapping
BCI

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

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

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

The important part is the field cols:

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:

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.

hashtag
EEG

The stream "eeg" uses these labels:

The maker objects include these fields:

Example for an INSIGHT:

Example for an EPOC+ or EPOC X:

hashtag
Motion

The stream "mot" uses these labels:

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:

Example for an older INSIGHT:

To understand the meaning of motion data, you can refer .

hashtag
Device information

The stream "dev" uses these labels:

Example with INSIGHT:

Example with EPOC+ or EPOC X:

hashtag
EEG Quality

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

The stream "eq" uses these labels:

This stream was added in Cortex 2.7.0

Example with INSIGHT:

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

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

Example with INSIGHT:

Example with EPOC+ or EPOC X:

hashtag
Performance metric

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

The "met" stream labels vary depending on the headset type, as shown in the tables below:

hashtag
The "met" Stream Labels of MN8

hashtag
Example

hashtag
The "met" Stream Labels of EPOC / INSIGHT / FLEX - (with EPOC config only)

hashtag
Example

To understand the meaning of each performance metrics, you can refer .

hashtag
Mental command

The stream "com" uses these labels:

hashtag
Facial expression

The stream "fac" uses these labels:

Use the method to get the possible actions.

hashtag
System events

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

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

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

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)

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

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

betaH (high beta, 16-25Hz)
  • gamma (25-45Hz)

  • Active flag for attention.

    Stress measures emotional tension experienced when completing a task.

    rel

    number

    Relaxation measures calm focus after a period of intense concentration.

    int

    number

    Interest measures attraction or aversion to stimuli.

    attention

    number

    Attention measures sustained focus on a single task.

    eng.isActive

    boolean

    Active flag for engagement.

    exc.isActive

    boolean

    Active flag for excitement.

    str.isActive

    boolean

    Active flag for stress.

    rel.isActive

    boolean

    Active flag for relaxation.

    int.isActive

    boolean

    Active flag for interest

    attention.isActive

    boolean

    Active flag for attention.

    The lower face action.

    lPow

    number

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

    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.

    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

    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

    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

    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

    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>

    Label

    Type

    Description

    cognitiveStress

    number

    Cognitive Stress measures the mental strain caused by challenging tasks or environments.

    attention

    number

    Attention measures sustained focus on a single task.

    cognitiveStress.isActive

    boolean

    Active flag for cognitiveStress

    attention.isActive

    Label

    Type

    Description

    eng

    number

    Engagement measures immersion in an activity.

    exc

    number

    Excitement measures the intensity of reactions to stimuli or environments.

    lex

    number

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

    str

    Label

    Type

    Description

    act

    string

    A mental command action. Use the method getDetectionInfo 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".

    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

    Label

    Type

    Description

    event

    string

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

    msg

    string

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

    subscribe
    pagearrow-up-right
    getDetectionInfo
    training

    number

    string or number

    number

    number

    number

    boolean

    number

    string

    unsubscribe

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

    hashtag
    Parameters

    Name

    Type

    Required

    Description

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

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

    hashtag
    Examples

    Unsubscribe successfully from the performance metrics and motion streams.

    subscribe

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

    See Data Subscription for details.

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

    circle-info

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

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

    hashtag
    Examples

    Subscribe successfully to motion and performance metrics.

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

    {
        "id":8,
        "jsonrpc":"2.0",
        "result":{
            "failure":[],
            "success":[{
                "cols":["act","pow"],
                "sid":"7f899d66-442b-4bf4-9752-ed06d57b72c3",
                "streamName":"com"
            }]
        }
    }
    ["act","pow"]
    {
        "com": ["push", 0.376],
        "sid": "7f899d66-442b-4bf4-9752-ed06d57b72c3",
        "time": 1559900743.3318
    }
    [
      "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
    }
    [
        "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
    }
    [
      "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
    }
    [
        "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
    }
    [
      "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
    }
    [
        "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
    }
    [
      "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
    }
    [
        "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
    }
    [
        "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
    }
    [
        "attention.isActive",
        "attention",
        "cognitiveStress.isActive",
        "cognitiveStress"
    ]
    {
      "met": [True, 0.8, True, 0.4],
      "sid":"6a68b92a-cb1f-4062-bf1f-74424fbae066",
      "time": 1759225262.5052
      }
    [
        "eng.isActive","eng",
        "exc.isActive","exc","lex",
        "str.isActive","str",
        "rel.isActive","rel",
        "int.isActive","int",
        "attention.isActive","attention"
    ]
    {
        "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
    }
    ["act","pow"]
    {
        "com":["pull",0.564],
        "sid":"79cc669b-af2e-465a-bdc2-0e9bd4aebe80",
        "time":1559903099.348
    }
    ["eyeAct","uAct","uPow","lAct","lPow"]
    {
        "fac":["neutral","neutral",0,"clench",0.0576],
        "sid":"a4f69c56-9769-4a4d-950c-490eb5ebe372",
        "time":1559903035.2961
    }
    ["event","msg"]
    {
        "sid":"c7e7b527-2b2e-4ec6-8c74-cf16aae8540b",
        "sys":["mentalCommand","MC_Started"],
        "time":1559903035.2961
    }

    cortexToken

    string

    yes

    A token returned by .

    session

    string

    yes

    A session id returned by .

    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.

    Data Subscription

    Name

    Type

    Required

    Description

    cortexToken

    string

    yes

    A token returned by .

    session

    string

    yes

    A session id returned by .

    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.

    Data Subscription
    activate
    Data sample object
    markers
    injectMarker
    injectMarker
    injectMarker
    {
        "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"}
            ]
        }
    }
    {
        "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"
                }
            ]
        }
    }
    authorize
    createSession
    authorize
    createSession
    EmotivPRO Documentation
    EmotivPRO Documentation