arrow-left

All pages
gitbookPowered by GitBook
1 of 7

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

deleteSubjects

This method is to delete one or more subjects.

triangle-exclamation

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

This method was added in Cortex 2.1

hashtag
Parameters

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

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

.

updateSubject

This method is to update an existing subject.

This method was added in Cortex 2.1

hashtag
Parameters

Subjects

A subject represents a human being who is the subject of a record, 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 createSubject. Then you must specify the subject name when you call createRecord. A subject is identified by his/her name.

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

Name

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

subjects

array of strings

yes

A list a subject names.

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.

Name

Type

Description

subjectName

string

The name of the deleted subject.

Name

Type

Description

subjectName

string

The name of the subject.

code

number

The error code.

message

string

The error message.

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

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.

hashtag
Result

The result is a subject object representing the updated subject.

hashtag
Examples

Update the date of birth of a subject.

Name

Type

Required

{
    "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"
    }
}
authorize
Alpha-2 ISO codearrow-up-right
Subject object

querySubjects

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

This method was added in Cortex 2.1

hashtag
Parameters

Name

Type

triangle-exclamation

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.

hashtag
query

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

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

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

hashtag
Result

The result is an object that includes these fields:

hashtag
Examples

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

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"

The offset you specified in the parameters.

Required

Description

cortexToken

string

yes

A token returned by authorize.

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.

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

Name

Type

Description

subjects

array of objects

An array of subject objects.

count

number

The total number of subjects that match the query.

limit

number

The limit you specified in the parameters.

offset

string

number

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

createSubject

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

This method was added in Cortex 2.1

hashtag
Parameters

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 .

hashtag
Result

The result is a subject object representing the new subject.

hashtag
Examples

Create a subject with only his name.

Create a subject with more information.

Name

createRecord

Type

getDemographicAttributes

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

This method was added in Cortex 2.1

hashtag
Parameters

Name

hashtag
Result

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

hashtag
Example

{
    "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"
    }
}
{
    "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"
    }
}
authorize
Alpha-2 ISO codearrow-up-right
Subject object

Type

Required

Description

cortexToken

string

yes

A token returned by authorize.

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.

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

Subject object

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

hashtag
Description

A subject object includes these fields:

Name

Type

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

hashtag
Example

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

getDemographicAttributes
{
    "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"
}
Alpha-2 ISO codearrow-up-right