emotiv / cortex-example Goto Github PK
View Code? Open in Web Editor NEWExample with Cortex V2/V3 API
Home Page: https://emotiv.com
License: MIT License
Example with Cortex V2/V3 API
Home Page: https://emotiv.com
License: MIT License
We are trying to get the command stream, we have modified the DataStreamExample.
Everything is fine until the _sessionCreator.Create(_cortexToken, headsetId), where we get the error code -32019.
This is our code:
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
namespace CortexAccess
{
public class DataStreamExample
{
private CortexClient _ctxClient;
private List _streams;
private string _cortexToken;
private string _sessionId;
private HeadsetFinder _headsetFinder;
private Authorizer _authorizer;
private SessionCreator _sessionCreator;
public List<string> Streams
{
get
{
return _streams;
}
set
{
_streams = value;
}
}
public string SessionId
{
get
{
return _sessionId;
}
}
// Event
public event EventHandler<ArrayList> OnMotionDataReceived; // motion data
public event EventHandler<ArrayList> OnEEGDataReceived; // eeg data
//public event EventHandler<ArrayList> OnDevDataReceived; // contact quality data
public event EventHandler<ArrayList> OnPerfDataReceived; // performance metric
public event EventHandler<ArrayList> OnBandPowerDataReceived; // band power
public event EventHandler<ArrayList> OnCommandDataReceived; // mental commands
public event EventHandler<Dictionary<string, JArray>> OnSubscribed;
private List<string> _profileLists;
// Constructor
public DataStreamExample(string AppClientId, string AppClientSecret) {
// Event register
_ctxClient = CortexClient.Instance;
//
_ctxClient.AppClientId = AppClientId;
_ctxClient.AppClientSecret = AppClientSecret;
_authorizer = new Authorizer();
_headsetFinder = new HeadsetFinder();
_sessionCreator = new SessionCreator();
_cortexToken = "";
_sessionId = "";
_streams = new List<string>();
_profileLists = new List<string>();
//
_ctxClient.OnErrorMsgReceived += MessageErrorRecieved;
_ctxClient.OnStreamDataReceived += StreamDataReceived;
_ctxClient.OnSubscribeData += SubscribeDataOK;
_ctxClient.OnUnSubscribeData += UnSubscribeDataOK;
_ctxClient.OnQueryProfile += QueryProfileOK;
_authorizer.OnAuthorized += AuthorizedOK;
_headsetFinder.OnHeadsetConnected += HeadsetConnectedOK;
_sessionCreator.OnSessionActivated += SessionActivatedOk;
_sessionCreator.OnSessionClosed += SessionClosedOK;
}
private void QueryProfileOK(object sender, JArray profiles)
{
//Console.WriteLine("QueryProfileOK" + profiles);
foreach (JObject ele in profiles)
{
string name = (string)ele["name"];
_profileLists.Add(name);
}
// find headset
_headsetFinder.FindHeadset();
}
public void LoadProfile(string profileName)
{
if (_profileLists.Contains(profileName))
_ctxClient.SetupProfile(_cortexToken, profileName, "load");
//else
//Console.WriteLine("The profile can not be loaded. The name " + profileName + " has not existed.");
}
private void SessionClosedOK(object sender, string sessionId)
{
//Console.WriteLine("The Session " + sessionId + " has closed successfully.");
}
private void UnSubscribeDataOK(object sender, MultipleResultEventArgs e)
{
foreach (JObject ele in e.SuccessList)
{
string streamName = (string)ele["streamName"];
if (_streams.Contains(streamName))
{
_streams.Remove(streamName);
}
}
foreach (JObject ele in e.FailList)
{
string streamName = (string)ele["streamName"];
int code = (int)ele["code"];
string errorMessage = (string)ele["message"];
//Console.WriteLine("UnSubscribe stream " + streamName + " unsuccessfully." + " code: " + code + " message: " + errorMessage);
}
}
private void SubscribeDataOK(object sender, MultipleResultEventArgs e)
{
foreach (JObject ele in e.FailList)
{
string streamName = (string)ele["streamName"];
int code = (int)ele["code"];
string errorMessage = (string)ele["message"];
//Console.WriteLine("Subscribe stream " + streamName + " unsuccessfully." + " code: " + code + " message: " + errorMessage);
if (_streams.Contains(streamName))
{
_streams.Remove(streamName);
}
}
Dictionary<string, JArray> header = new Dictionary<string, JArray>();
foreach (JObject ele in e.SuccessList)
{
string streamName = (string)ele["streamName"];
JArray cols = (JArray)ele["cols"];
header.Add(streamName, cols);
}
if (header.Count > 0)
{
OnSubscribed(this, header);
}
else
{
//Console.WriteLine("No Subscribe Stream Available");
}
}
private void SessionActivatedOk(object sender, string sessionId)
{
// subscribe
_sessionId = sessionId;
_ctxClient.Subscribe(_cortexToken, _sessionId, Streams);
}
private void HeadsetConnectedOK(object sender, string headsetId)
{
////Console.WriteLine("HeadsetConnectedOK " + headsetId);
// CreateSession
_sessionCreator.Create(_cortexToken, headsetId);
}
private void AuthorizedOK(object sender, string cortexToken)
{
if (!String.IsNullOrEmpty(cortexToken))
{
_cortexToken = cortexToken;
// find headset
_headsetFinder.FindHeadset();
}
}
private void StreamDataReceived(object sender, StreamDataEventArgs e)
{
//Console.WriteLine(e.StreamName + " data received.");
ArrayList data = e.Data.ToObject<ArrayList>();
// insert timestamp to datastream
data.Insert(0, e.Time);
if (e.StreamName == "eeg")
{
OnEEGDataReceived(this, data);
}
else if (e.StreamName == "mot")
{
OnMotionDataReceived(this, data);
}
else if (e.StreamName == "met")
{
OnPerfDataReceived(this, data);
}
else if (e.StreamName == "pow")
{
OnBandPowerDataReceived(this, data);
}
else if (e.StreamName == "com")
{
OnCommandDataReceived(this, data);
}
}
private void MessageErrorRecieved(object sender, ErrorMsgEventArgs e)
{
Console.WriteLine("MessageErrorRecieved :code " + e.Code + " message " + e.MessageError);
}
// set Streams
public void AddStreams(string stream)
{
if (!_streams.Contains(stream))
{
_streams.Add(stream);
}
}
// start
public void Start()
{
_authorizer.Start();
}
// Unsubscribe
public void UnSubscribe(List<string> streams = null)
{
if (streams == null)
{
// unsubscribe all data
_ctxClient.UnSubscribe(_cortexToken, _sessionId, _streams);
}
else
_ctxClient.UnSubscribe(_cortexToken, _sessionId, streams);
}
public void CloseSession()
{
_sessionCreator.CloseSession();
}
}
}
Greetings.
I have been attempting to develop an in-house research app using the Cortex API, and am working on getting it to create and export records. Unfortunately, I consistently get failure reports like these:
{'code': -32138, 'message': 'The stream data is not supported.', 'recordId': '1cb8542a-9364-4c81-ab8f-9982bd5cf702'}
{'code': -32147, 'message': 'Data is corrupted by internal error.', 'recordId': '277ce3e0-f095-4444-9131-ea73ce52f96b'}
I have attached 3 files: the Python code I have been using to test this, the raw JSON replies from the Cortex service, and the stdout from the Python program.
pycortex.py.txt
cortexRawFile.txt
Cortex Test Output 2019-10-03.txt
Any assistance with this would be most appreciated.
Can we get examples for Unity similar to the ones that we had for the community SDK, just the connection part at least and generic commands like connecting to the headset on the using buttons?
For some reason I am able to train lift command in another user's profile after physically selecting the profile in EmotivBCI. Hows that possible?
Has anybody faced that issue?
How many minimum trainings are required to close this issue?
I am interested to create an Android application to interact with a EMOTIV Insight, but I am wondering is it possible to connect to Cortex API using Android Studio?
Hello, I would like you to help me with a problem that I have.
I'm trying to run the cortex_example_export_record.py to get the csv file, but the export_record method doesn't work well.
What can cause the problem?
Thank you!
export record request {
"jsonrpc": "2.0",
"id": 113,
"method": "exportRecord",
"params": {
"cortexToken": "",
"folder": "C:\export",
"format": "CSV",
"streamTypes": [
"EEG"
],
"recordIds": [
""
],
"version": "V2"
}
}
export record result {
"jsonrpc": "2.0",
"warning": {
"code": 0,
"message": "All subscriptions of session *** was stopped by Cortex"
}
}
export record result {
"id": 113,
"jsonrpc": "2.0",
"result": {
"failure": [
{
"code": -32138,
"message": "The stream data is not supported.",
"recordId": "***"
}
],
"success": []
}
}
I am trying to access the raw EEG data via Cortex v2 API using the example code from this repo. I made sure I have a pro license and I was granted access to the raw EEG data. Nevertheless I keep getting messages saying that I have no access to the eeg data stream.
I logged out and logged in of my account on the Emotiv App. I even uninstalled the emotiv apps, removed any emotiv data folders left on the my computer and installed it again. Same result.
I also tried to remove the current app, create and authorize a new one with new client_id and client_secret codes, but same result.
I copied and pasted the debugging messages from the python example code here. I tried it with the CSharp code and I get the same result. I removed the credentials, user-related ids, tokens and so on by "foo":
** USER LOGIN **
Sending request:
{"jsonrpc": "2.0", "method": "getUserLogin", "params": {}, "id": 1}
sent; awaiting response
lib.cortex resp:
{'currentOSUId': '1002', 'currentOSUsername': 'foo', 'loggedInOSUId': '1002', 'loggedInOSUsername': 'foo', 'username': 'foo'}
** GET CORTEX INFO **
Sending request:
{"jsonrpc": "2.0", "method": "getCortexInfo", "params": {}, "id": 2}
sent; awaiting response
lib.cortex resp:
{'id': 2, 'jsonrpc': '2.0', 'result': {'buildDate': '2019-11-12T09:47:41', 'buildNumber': 'v2.2.1-10-ge7781ad', 'version': '2.2.3'}}
** HAS ACCESS RIGHT **
Sending request:
{"jsonrpc": "2.0", "method": "requestAccess", "params": {"clientId": "foo", "clientSecret": "foo"}, "id": 3}
sent; awaiting response
lib.cortex resp:
{'id': 3, 'jsonrpc': '2.0', 'result': {'accessGranted': True, 'message': 'The user has granted access right to this application.'}}
** REQUEST ACCESS **
Sending request:
{"jsonrpc": "2.0", "method": "requestAccess", "params": {"clientId": "foo", "clientSecret": "foo"}, "id": 4}
sent; awaiting response
lib.cortex resp:
{'id': 4, 'jsonrpc': '2.0', 'result': {'accessGranted': True, 'message': 'The user has granted access right to this application.'}}
** AUTHORIZE **
Sending request:
{"jsonrpc": "2.0", "method": "authorize", "params": {"clientId": "foo", "clientSecret": "foo", "debit": 100}, "id": 5}
sent; awaiting response
lib.cortex resp:
{'id': 5, 'jsonrpc': '2.0', 'result': {'cortexToken': 'foo'}}
** GET LICENSE INFO **
Sending request:
{"jsonrpc": "2.0", "method": "getLicenseInfo", "params": {"cortexToken": "foo"}, "id": 6}
sent; awaiting response
lib.cortex resp:
{'id': 6, 'jsonrpc': '2.0', 'result': {'isOnline': True, 'license': {'applications': ['com.emotiv.sdk.basic'], 'billingFrom': '2019-10-29T01:00:00.000+01:00', 'billingTo': '2029-10-26T02:00:00.000+02:00', 'deviceInfo': {'deviceLimit': 3, 'devicesPerSeat': 3, 'sessionLimit': {'day': None, 'month': None, 'year': None}}, 'expired': False, 'extenderLimit': 0, 'hardLimitTime': '2019-12-07T00:59:59.999+01:00', 'isCommercial': False, 'licenseId': 'foo', 'licenseName': 'Basic License', 'localQuota': 218, 'maxDebit': None, 'scopes': [''], 'seatCount': 1, 'sessionCount': 10, 'softLimitTime':
'2019-11-30T00:59:59.999+01:00', 'totalDebit': 3130, 'totalRegisteredDevices': 1, 'validFrom': '2019-10-29T01:00:00.000+01:00', 'validTo': '2029-10-27T01:59:59.999+02:00'}}}
** QUERY HEADSETS **
Sending request:
{"jsonrpc": "2.0", "method": "queryHeadsets", "params": {}, "id": 7}
sent; awaiting response
lib.cortex found headsets ['EPOC-60874887']
lib.cortex resp:
{'id': 7, 'jsonrpc': '2.0', 'result': [{'connectedBy': 'dongle', 'customName': '', 'dongle': '565', 'firmware': '565', 'id': 'EPOC-60874887', 'motionSensors': ['GYROX', 'GYROY'], 'sensors': ['AF3', 'F7', 'F3', 'FC5', 'T7', 'P7', 'O1', 'O2', 'P8', 'T8', 'FC6', 'F4', 'F8', 'AF4'], 'settings': {'eegRate': 128, 'eegRes': 14, 'memsRate': 128, 'memsRes': 14, 'mode': 'STANDARD'}, 'status': 'connected'}]}
** CREATE SESSION **
Sending request:
{"jsonrpc": "2.0", "method": "createSession", "params": {"cortexToken": "foo", "headset": "EPOC-60874887", "status": "active"}, "id": 8}
sent; awaiting response
lib.cortex resp:
{'id': 8, 'jsonrpc': '2.0', 'result': {'appId': 'com.mvidaldepalo.rawdata', 'headset': {'connectedBy': 'dongle', 'customName': '', 'dongle': '565', 'firmware': '565', 'id': 'EPOC-60874887', 'motionSensors': ['GYROX', 'GYROY'], 'sensors': ['AF3', 'F7', 'F3', 'FC5', 'T7', 'P7', 'O1', 'O2', 'P8', 'T8', 'FC6', 'F4', 'F8', 'AF4'], 'settings': {'eegRate': 128, 'eegRes': 14, 'memsRate': 128, 'memsRes': 14, 'mode': 'STANDARD'}, 'status': 'connected'}, 'id': 'd2d02ae5-490a-485c-b1b1-2e48de2ddb86', 'license': '6cba759c-a9fc-48af-9dd8-0b3220d9dfa7', 'owner': 'mvidaldepalo', 'recordIds': [], 'recording': False, 'started': '2019-11-19T12:13:30.136+01:00', 'status': 'activated', 'stopped': '', 'streams': []}}
** CREATE RECORD **
Sending request:
{"jsonrpc": "2.0", "method": "createRecord", "params": {"cortexToken": "foo", "session": "d2d02ae5-490a-485c-b1b1-2e48de2ddb86", "title": "test record 1"}, "id": 9}
sent; awaiting response
lib.cortex resp:
{'id': 9, 'jsonrpc': '2.0', 'result': {'record': {'applicationId': 'com.mvidaldepalo.rawdata', 'applicationVersion': '1.0', 'description': '', 'endDatetime': '', 'experimentId': 0, 'licenseId': 'foo', 'licenseScope': [''], 'localOnly': False, 'ownerId': 'foo', 'startDatetime': '2019-11-19T12:13:30.058710+01:00', 'tags': [], 'title': 'test record 1', 'uuid': '63b7d15c-cbda-4e6e-a834-ebdd8cfdc95e'}, 'sessionId': 'foo'}}
** SUBSCRIBE POW & MET **
Sending request:
{"jsonrpc": "2.0", "method": "subscribe", "params": {"cortexToken": "foo", "session": "d2d02ae5-490a-485c-b1b1-2e48de2ddb86", "streams": ["eeg"]}, "id": 10}
sent; awaiting response
lib.cortex resp:
{'id': 10, 'jsonrpc': '2.0', 'result': {'failure': [{'code': -32016, 'message': 'The stream is unavailable or unsupported.', 'streamName': 'eeg'}], 'success': []}}
Hi everybody,
I need to use the Cortex V2.0 with the examples presented on C# but it didn't work and I always get this error "MessageErrorRecieved :code -32019 message Session limit on this device has been reached."
I have a free license and it does this error on all examples. I only use an Epoc+ headset.
If you have any clue about this please tell me,
Thanks in advance.
I am pasting the console output showing the JSON messages exchange:
BAND POWER LOGGER
Please wear Headset with good signal!!!
Send getUserLogin
{
"jsonrpc": "2.0",
"id": 1,
"method": "getUserLogin"
}
Press Esc to exit
Received: {"id":1,"jsonrpc":"2.0","result":[{"currentOSUId":"1001","currentOSUsername":"sbyyu","loggedInOSUId":"1001","loggedInOSUsername":"sbyyu","username":"geosbyr96"}]}
handleResponse: getUserLogin
Send hasAccessRight
{
"jsonrpc": "2.0",
"id": 2,
"method": "hasAccessRight",
"params": {
"clientId": "KrhZPx9ky2Xa9NyffNUv1yIYtlfw32vVTmcDPh29",
"clientSecret": "nBa4u3tkXGfzB6xsuzbJDxgxTEGPGBPRnxp07ZvOKvp3L1PfkJavkI4cVgXrOcP92dDhIickBBqFF6KAOSSXUWq0axIa9iG0g9WHEbH338fTL4lDrSKwrRXCIZUMOiSM"
}
}
Received: {"id":2,"jsonrpc":"2.0","result":{"accessGranted":true,"message":"The access right to the application has already been granted."}}
handleResponse: hasAccessRight
Send authorize
{
"jsonrpc": "2.0",
"id": 3,
"method": "authorize",
"params": {
"clientId": "KrhZPx9ky2Xa9NyffNUv1yIYtlfw32vVTmcDPh29",
"clientSecret": "nBa4u3tkXGfzB6xsuzbJDxgxTEGPGBPRnxp07ZvOKvp3L1PfkJavkI4cVgXrOcP92dDhIickBBqFF6KAOSSXUWq0axIa9iG0g9WHEbH338fTL4lDrSKwrRXCIZUMOiSM",
"debit": 0
}
}
Received: {"id":3,"jsonrpc":"2.0","result":{"cortexToken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS5nZW9zYnlyOTYuYnJhaW5jb21wdXRlcmludGVyYWN0aW9uIiwiYXBwVmVyc2lvbiI6IjEuMCIsImV4cCI6MTU2NTA4NTQ5MywibGljZW5zZUlkIjoiZGRhMjRhYTItNDZhMi00Y2QwLTk5MDctZDdmNGI3MzFlMGE0IiwibmJmIjoxNTY0ODI2MjkzLCJ1c2VySWQiOiI4NDYwZjVjOS02MDVjLTQwZGItOGY1Yi1mYjdhM2ExYWVlYzEiLCJ1c2VybmFtZSI6Imdlb3NieXI5NiIsInZlcnNpb24iOiIyLjAifQ==.JLmQXLLhXya38RcwavJG3n0fRkXLUgeCI4hH8rDwW/0="}}
handleResponse: authorize
Authorize successfully.
FindHeadset
Send queryHeadsets
{
"jsonrpc": "2.0",
"id": 4,
"method": "queryHeadsets"
}
Received: {"id":4,"jsonrpc":"2.0","result":[{"connectedBy":"dongle","customName":"","dongle":"6ff","firmware":"633","id":"EPOCPLUS-4A2C04F1","motionSensors":["Q0","Q1","Q2","Q3","ACCX","ACCY","ACCZ","MAGX","MAGY","MAGZ"],"sensors":["AF3","F7","F3","FC5","T7","P7","O1","O2","P8","T8","FC6","F4","F8","AF4"],"settings":{"eegRate":128,"eegRes":16,"memsRate":32,"memsRes":16,"mode":"EPOCPLUS"},"status":"connected"}]}
handleResponse: queryHeadsets
Send createSession
{
"jsonrpc": "2.0",
"id": 5,
"method": "createSession",
"params": {
"headset": "EPOCPLUS-4A2C04F1",
"cortexToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS5nZW9zYnlyOTYuYnJhaW5jb21wdXRlcmludGVyYWN0aW9uIiwiYXBwVmVyc2lvbiI6IjEuMCIsImV4cCI6MTU2NTA4NTQ5MywibGljZW5zZUlkIjoiZGRhMjRhYTItNDZhMi00Y2QwLTk5MDctZDdmNGI3MzFlMGE0IiwibmJmIjoxNTY0ODI2MjkzLCJ1c2VySWQiOiI4NDYwZjVjOS02MDVjLTQwZGItOGY1Yi1mYjdhM2ExYWVlYzEiLCJ1c2VybmFtZSI6Imdlb3NieXI5NiIsInZlcnNpb24iOiIyLjAifQ==.JLmQXLLhXya38RcwavJG3n0fRkXLUgeCI4hH8rDwW/0=",
"status": "active"
}
}
Send querySessions
{
"jsonrpc": "2.0",
"id": 6,
"method": "querySessions",
"params": {
"cortexToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS5nZW9zYnlyOTYuYnJhaW5jb21wdXRlcmludGVyYWN0aW9uIiwiYXBwVmVyc2lvbiI6IjEuMCIsImV4cCI6MTU2NTA4NTQ5MywibGljZW5zZUlkIjoiZGRhMjRhYTItNDZhMi00Y2QwLTk5MDctZDdmNGI3MzFlMGE0IiwibmJmIjoxNTY0ODI2MjkzLCJ1c2VySWQiOiI4NDYwZjVjOS02MDVjLTQwZGItOGY1Yi1mYjdhM2ExYWVlYzEiLCJ1c2VybmFtZSI6Imdlb3NieXI5NiIsInZlcnNpb24iOiIyLjAifQ==.JLmQXLLhXya38RcwavJG3n0fRkXLUgeCI4hH8rDwW/0="
}
}
Received: {"error":{"code":-32019,"message":"Session limit on this device has been reached."},"id":5,"jsonrpc":"2.0"}
Received: Session limit on this device has been reached.
MessageErrorRecieved :code -32019 message Session limit on this device has been reached.
Received: {"id":6,"jsonrpc":"2.0","result":[]}
handleResponse: querySessions
The data folder, example, '''ProgramData''', has some Sqlite databases. In order to best get the data we tried to access that database, but it has a password.
It's OK to access this database locally? In case of yes, what password we should use in order to access the data?
Thank you.
(emotiv) C:\Users\Zabir\Desktop\emotiv\cortex-v2-example-master\cortex-v2-example-master\python>python example.py ** USER LOGIN ** Sending request: {"jsonrpc": "2.0", "method": "getUserLogin", "params": {}, "id": 1} sent; awaiting response lib.cortex resp: {'currentOSUId': '1001', 'currentOSUsername': 'Zabir', 'loggedInOSUId': '1001', 'loggedInOSUsername': 'Zabir', 'username': 'zabir_nabil'} ** GET CORTEX INFO ** Sending request: {"jsonrpc": "2.0", "method": "getCortexInfo", "params": {}, "id": 2} sent; awaiting response lib.cortex resp: {'id': 2, 'jsonrpc': '2.0', 'result': {'buildDate': '2019-08-01T15:09:03', 'buildNumber': '01f5820', 'version': '2.1.0'}} ** HAS ACCESS RIGHT ** Sending request: {"jsonrpc": "2.0", "method": "requestAccess", "params": {"clientId": "zVGvkZG66axd2MsjKg8azGB8dZtnC5nVJyWV3xJz", "clientSecret": "yJG5GhzRIuzSmhWmjpjJg6VbhZXypzTIyfNZFlGVxAZLEzVjwpa6NEYvbCydp0Kbo6e4uPbJc1Fr9YYNgNlTKukpAByTjjPeo4FsKN1RWA8ewfEidmyYTEqCwErWYH2T"}, "id": 3} sent; awaiting response lib.cortex resp: {'id': 3, 'jsonrpc': '2.0', 'result': {'accessGranted': True, 'message': 'The User has access right to this application.'}} ** REQUEST ACCESS ** Sending request: {"jsonrpc": "2.0", "method": "requestAccess", "params": {"clientId": "zVGvkZG66axd2MsjKg8azGB8dZtnC5nVJyWV3xJz", "clientSecret": "yJG5GhzRIuzSmhWmjpjJg6VbhZXypzTIyfNZFlGVxAZLEzVjwpa6NEYvbCydp0Kbo6e4uPbJc1Fr9YYNgNlTKukpAByTjjPeo4FsKN1RWA8ewfEidmyYTEqCwErWYH2T"}, "id": 4} sent; awaiting response lib.cortex resp: {'id': 4, 'jsonrpc': '2.0', 'result': {'accessGranted': True, 'message': 'The User has access right to this application.'}} ** AUTHORIZE ** Sending request: {"jsonrpc": "2.0", "method": "authorize", "params": {"clientId": "zVGvkZG66axd2MsjKg8azGB8dZtnC5nVJyWV3xJz", "clientSecret": "yJG5GhzRIuzSmhWmjpjJg6VbhZXypzTIyfNZFlGVxAZLEzVjwpa6NEYvbCydp0Kbo6e4uPbJc1Fr9YYNgNlTKukpAByTjjPeo4FsKN1RWA8ewfEidmyYTEqCwErWYH2T"}, "id": 5} sent; awaiting response lib.cortex resp: {'id': 5, 'jsonrpc': '2.0', 'result': {'cortexToken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS56YWJpcl9uYWJpbC5icmFpbmVjdCIsImFwcFZlcnNpb24iOiIxLjAiLCJleHAiOjE1NjY0ODA4MDQsImxpY2Vuc2VJZCI6ImZlMWZmMGU3LTc5YzgtNDEzZC1hOGVhLTg4Mzg2OTEyYWMxOCIsIm5iZiI6MTU2NjIyMTYwNCwidXNlcklkIjoiMGFiOWY3OTUtNWFhZS00MTMxLWE1MTAtMTJlOTYzNzY4MTM4IiwidXNlcm5hbWUiOiJ6YWJpcl9uYWJpbCIsInZlcnNpb24iOiIyLjAifQ==.5FtvYz0RxBmPW2nHQTfFnrhb1gKseBkEdejGTNc3/2g='}} ** GET LICENSE INFO ** Sending request: {"jsonrpc": "2.0", "method": "getLicenseInfo", "params": {"cortexToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS56YWJpcl9uYWJpbC5icmFpbmVjdCIsImFwcFZlcnNpb24iOiIxLjAiLCJleHAiOjE1NjY0ODA4MDQsImxpY2Vuc2VJZCI6ImZlMWZmMGU3LTc5YzgtNDEzZC1hOGVhLTg4Mzg2OTEyYWMxOCIsIm5iZiI6MTU2NjIyMTYwNCwidXNlcklkIjoiMGFiOWY3OTUtNWFhZS00MTMxLWE1MTAtMTJlOTYzNzY4MTM4IiwidXNlcm5hbWUiOiJ6YWJpcl9uYWJpbCIsInZlcnNpb24iOiIyLjAifQ==.5FtvYz0RxBmPW2nHQTfFnrhb1gKseBkEdejGTNc3/2g="}, "id": 6} sent; awaiting response lib.cortex resp: {'id': 6, 'jsonrpc': '2.0', 'result': {'isOnline': True, 'license': {'applications': ['com.emotiv.sdk.basic'], 'billingFrom': '2019-07-31T06:00:00.000+06:00', 'billingTo': '2029-07-28T06:00:00.000+06:00', 'deviceInfo': {'deviceLimit': 3, 'devicesPerSeat': 3, 'sessionLimit': {'day': None, 'month': None, 'year': None}}, 'expired': False, 'extenderLimit': 6, 'hardLimitTime': '2019-09-08T05:59:59.999+06:00', 'isCommercial': False, 'licenseId': 'fe1ff0e7-79c8-413d-a8ea-88386912ac18', 'licenseName': 'Basic License', 'localQuota': 0, 'maxDebit': None, 'scopes': [''], 'seatCount': 1, 'sessionCount': 0, 'softLimitTime': '2019-09-01T05:59:59.999+06:00', 'totalDebit': 0, 'totalRegisteredDevices': 1, 'validFrom': '2019-07-31T06:00:00.000+06:00', 'validTo': '2029-07-29T05:59:59.999+06:00'}}} ** QUERY HEADSETS ** Sending request: {"jsonrpc": "2.0", "method": "queryHeadsets", "params": {}, "id": 7} sent; awaiting response lib.cortex found headsets ['INSIGHT-A1D202AA'] lib.cortex resp: {'id': 7, 'jsonrpc': '2.0', 'result': [{'connectedBy': 'bluetooth', 'customName': '', 'dongle': '0', 'firmware': '930', 'id': 'INSIGHT-A1D202AA', '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'}, 'status': 'connected'}]} ** CREATE SESSION ** Sending request: {"jsonrpc": "2.0", "method": "createSession", "params": {"cortexToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS56YWJpcl9uYWJpbC5icmFpbmVjdCIsImFwcFZlcnNpb24iOiIxLjAiLCJleHAiOjE1NjY0ODA4MDQsImxpY2Vuc2VJZCI6ImZlMWZmMGU3LTc5YzgtNDEzZC1hOGVhLTg4Mzg2OTEyYWMxOCIsIm5iZiI6MTU2NjIyMTYwNCwidXNlcklkIjoiMGFiOWY3OTUtNWFhZS00MTMxLWE1MTAtMTJlOTYzNzY4MTM4IiwidXNlcm5hbWUiOiJ6YWJpcl9uYWJpbCIsInZlcnNpb24iOiIyLjAifQ==.5FtvYz0RxBmPW2nHQTfFnrhb1gKseBkEdejGTNc3/2g=", "headset": "INSIGHT-A1D202AA", "status": "active"}, "id": 8} sent; awaiting response Got error in createSession with params {'cortexToken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS56YWJpcl9uYWJpbC5icmFpbmVjdCIsImFwcFZlcnNpb24iOiIxLjAiLCJleHAiOjE1NjY0ODA4MDQsImxpY2Vuc2VJZCI6ImZlMWZmMGU3LTc5YzgtNDEzZC1hOGVhLTg4Mzg2OTEyYWMxOCIsIm5iZiI6MTU2NjIyMTYwNCwidXNlcklkIjoiMGFiOWY3OTUtNWFhZS00MTMxLWE1MTAtMTJlOTYzNzY4MTM4IiwidXNlcm5hbWUiOiJ6YWJpcl9uYWJpbCIsInZlcnNpb24iOiIyLjAifQ==.5FtvYz0RxBmPW2nHQTfFnrhb1gKseBkEdejGTNc3/2g=', 'headset': 'INSIGHT-A1D202AA', 'status': 'active'}: {"error":{"code":-32019,"message":"Session limit on this device has been reached."},"id":8,"jsonrpc":"2.0"} Traceback (most recent call last): File "example.py", line 45, in <module> test() File "example.py", line 40, in test asyncio.run(do_stuff(cortex)) File "C:\Anaconda_3\envs\emotiv\lib\asyncio\runners.py", line 43, in run return loop.run_until_complete(main) File "C:\Anaconda_3\envs\emotiv\lib\asyncio\base_events.py", line 579, in run_until_complete return future.result() File "example.py", line 24, in do_stuff headset_id=cortex.headsets[0]) File "C:\Users\Zabir\Desktop\emotiv\cortex-v2-example-master\cortex-v2-example-master\python\lib\cortex.py", line 254, in create_session resp = await self.send_command('createSession', **params) File "C:\Users\Zabir\Desktop\emotiv\cortex-v2-example-master\cortex-v2-example-master\python\lib\cortex.py", line 135, in send_command raise CortexApiException(resp) lib.cortex.CortexApiException: {"error":{"code":-32019,"message":"Session limit on this device has been reached."},"id":8,"jsonrpc":"2.0"}
I am not able to find C# code for getDetectionInfo()
can someone please help me
how can i connect the emostate of the emotiv insight and getting the detected events with matlab
Got error in createSession with params {'cortexToken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS5oX2Fsamlib3J5LmhqYXBwIiwiYXBwVmVyc2lvbiI6IjEuMCIsImV4cCI6MTU2OTU3OTMxMywibGljZW5zZUlkIjoiMzEwMDk0ZDItYjUzNi00YzJjLWJhNzYtM2Q3YWI2NTk2YmEyIiwibmJmIjoxNTY5MzIwMTEzLCJ1c2VySWQiOiI4MGE4ZTM1NS1hMWQ1LTRhMGMtYjIxYy0yMjVjN2Q2ZTU0OTciLCJ1c2VybmFtZSI6ImhfYWxqaWJvcnkiLCJ2ZXJzaW9uIjoiMi4wIn0=.DxnhnzUS4R7k+35ar3qlF6/+QJ6NUO+gP1af7uFuX1A=', 'headset': 'EPOCPLUS-4A2C045C', 'status': 'active'}:
{"error":{"code":-32019,"message":"Session limit on this device has been reached."},"id":8,"jsonrpc":"2.0"}
Traceback (most recent call last):
File "C:\Users\Hammody\Desktop\BCI\pyemotivcortexv2\demo.py", line 53, in
test()
File "C:\Users\Hammody\Desktop\BCI\pyemotivcortexv2\demo.py", line 44, in test
asyncio.run(do_stuff(cortex))
File "C:\Users\Hammody\AppData\Local\Programs\Python\Python37-32\lib\asyncio\runners.py", line 43, in run
return loop.run_until_complete(main)
File "C:\Users\Hammody\AppData\Local\Programs\Python\Python37-32\lib\asyncio\base_events.py", line 579, in run_until_complete
return future.result()
File "C:\Users\Hammody\Desktop\BCI\pyemotivcortexv2\demo.py", line 25, in do_stuff
headset_id=cortex.headsets[0])
File "C:\Users\Hammody\Desktop\BCI\pyemotivcortexv2\lib\cortex.py", line 258, in create_session
resp = await self.send_command('createSession', **params)
File "C:\Users\Hammody\Desktop\BCI\pyemotivcortexv2\lib\cortex.py", line 133, in send_command
raise CortexApiException(resp)
lib.cortex.CortexApiException: {"error":{"code":-32019,"message":"Session limit on this device has been reached."},"id":8,"jsonrpc":"2.0"}
Hello!
I am trying to use the C# wrapper to get streams from the EPOC+ device, however I am having trouble running the authorize method.
I open the connection CortexClient.Instance.Open(), run GetUserLogin() (this returns correct user) and after that I run the Authorize method, which I've modified to pass empty params as specified in the documentation (https://emotiv.github.io/cortex-docs/#authorize).
However this results in "Error: Missing required parameters." code: -32018
Here's full sequence of the sent and received JSON messages:
Send getUserLogin
{
"jsonrpc": "2.0",
"id": 1,
"method": "getUserLogin"
}
Received: {"id":1,"jsonrpc":"2.0","result":[{"currentOSUId":"1001","currentOSUsername":"Tomas","loggedInOSUId":"1001","loggedInOSUsername":"Tomas","username":"frooxius"}]}
handleResponse: getUserLogin
GetUserLogin: frooxius
Send authorize
{
"jsonrpc": "2.0",
"id": 2,
"method": "authorize",
"params": {}
}
Received: {"error":{"code":-32018,"message":"Missing required parameters."},"id":2,"jsonrpc":"2.0"}
Is there a step that I am missing?
Hello,
If someone has a simple way to export data to a csv file using python it would be very helpful (few lines of code). In addition, getting the EEG data for exemple on a float array would be great.
Thank you,
Xavier
Hello team Emotiv,
Recently I and a couple of my friends were working with the API V2 and we noticed that the API sends data at a much faster rate than expected for power bands and it would be great if you could take a look at it
I'm currently working on a project that involves the Emotiv insight to communicate data directly to an arduino through bluetooth. So, this would not be using the websocket-client that was used in Cortex API.
I was wondering if anyone has done this successfully and wouldn't mind explaining the basics of connecting the two devices and send information from the Emotiv device to the arduino through bluetooth,
Hello all,
I am having trouble with creating a profile via code in python. I tried creating profile in the EmotivBci and then loading it in the project, but it keeps giving me the error of missing parameters or invalid parameters.
I have followed the documentation of cortex 2.0 completely.
def setup_profile(self,name):
create_request = {
"id": 1,
"jsonrpc": "2.0",
"method": "setupProfile",
"params": {
"cortexToken": self.auth,
"profile": name,
'status': 'create'
}}
self.ws.send(json.dumps(create_request))
result = self.ws.recv()
result_dic = json.loads(result)
print('setting up profile', json.dumps(result_dic, indent=4))
def load_profile(self):
load_request = {
"id": 1,
"jsonrpc": "2.0",
"method": "setupProfile",
"params": {
"cortexToken": self.auth,
'headset_id' : self.headset_id,
"profile": "Aniruddha",
'status' : 'load'
}}
self.ws.send(json.dumps(load_request))
result = self.ws.recv()
result_dic = json.loads(result)
print('loading up profile', json.dumps(result_dic, indent=4))
I am using this in a GUI application. I am able to subscribe to 'com' for mental commands but getting stuck with loading the profile even though I have trained the profile in the EmotivBCI.
I would really appreciate it if someone could pinpoint my mistake here.
now as I have the access to emotivePRO and its raw EEG, I face the problem of sending the signal from Matlab to emotivePRO raw eeg in order to mark the input events. I wrote visual stimulus interface in Matlab (psychtoolbox), namely SSVEP/ERP. Thus I need to send data through matlab to emotivePro so that the raw data can be marked markers. Only the raw data with marker can be for further processing, such as superposition, ophthalmogram removal, filtering and so on. So how can I solve this problem.
Hi, I can't seem to find a mental command stream example for C#, but I see one for c++. Is there a reason it's not implemented?
Hello,
I'm trying to train a command, accept the command, then print to screen when the command is active.
1st Question: Should I use time.sleep(> 8s) function between the training and accepting action to have enough time to train the command? Is this the right idea?
2nd Question: Is mentalCommandActiveAction the right function to use if I want to print out the command that is detected in real time?
Thanks for your time and help.
Hi everybody,
I wanted to try the Cortex V2.0 with the examples presented on C# but it didn't work and I always get this error "MessageErrorRecieved :code -32019 message Session limit on this device has been reached."
I have a free license and it does this error on all examples.
I didn't have any problem with the former version and according to emotiv website it is noted "Unlimited sessions on 3 devices". So how can I have a session limit ? I only use an Epoc+ headset with Bluetooth.
If you have any clue about this please tell me,
Thanks in advance
MessageErrorRecieved :code -32019 message Session limit on this device has been reached.
Error recieved while trying to run Mental Commands program in C# example
I am facing this issue on the basic license, how many session can we have in the basic license?
Greetings
A pleasure to greet you, I would like to help me with a problem that I have for now, in python 3.7 after successfully making the streams of "com" with the following lines of code:
{
"id": 1,
"jsonrpc": "2.0",
"method": "subscribe",
"params": {
"cortexToken": "xxx",
"session": "f8cb7289-9a92-438b-8281-e5fdffe8166e",
"streams": ["com"]
}
}
I get this answer:
{
"id": 8,
"jsonrpc": "2.0",
"result": {
"failure": [],
"success": [{
"cols": ["act", "pow"],
"sid": "7f899d66-442b-4bf4-9752-ed06d57b72c3",
"streamName": "com"
}]
}
}
same that allows me to obtain data of some specific activity but I wanted to please help me with the line of code that allows me to obtain this result for example:
{
"com": ["push", 0.376],
"sid": "7f899d66-442b-4bf4-9752-ed06d57b72c3",
"time": 1559900743.3318
}
How can I print on screen the action that is currently being done with the Emotiv ?, I thank you very much in advance.
P.S. I am based on the use of its website: https://emotiv.gitbook.io/cortex-api/data-subscription/data-sample-object
but I can't find a way to show the specific action.
REQUEST_____
#neutral
ws.send(json.dumps({
"id": 1,
"jsonrpc": "2.0",
"method": "training",
"params": {
"action": "neutral",
"cortexToken": cortexToken,
"detection": "mentalCommand",
"session": sessionId,
"status": "start"
}
}))
print("_1",ws.recv()+"\n")
time.sleep(5)
print(ws.recv())
time.sleep(10)
print(ws.recv())
print("Start training for neutral ---> ",ws.recv()+"\n")
ws.send(json.dumps({
"id": 1,
"jsonrpc": "2.0",
"method": "training",
"params": {
"action": "neutral",
"cortexToken": cortexToken,
"detection": "mentalCommand",
"session": sessionId,
"status": "accept"
}
}))
print("Accept Training for neutral---> ",ws.recv()+"\n")
print(ws.recv())
time.sleep(2)
print(ws.recv())
RESPONSE_____
***************** START TRAINING **********************
_1 {"id":1,"jsonrpc":"2.0","result":{"action":"neutral","message":"Set up training successfully","status":"start"}}
{"sid":"1b467357-39c8-4c3f-bf8d-d701968414ac","sys":["mentalCommand","MC_Started"],"time":1573177873.6001072}
{"sid":"1b467357-39c8-4c3f-bf8d-d701968414ac","sys":["mentalCommand","MC_Failed"],"time":1573177883.698816}
Hi i am working with Emotiv Flex. While calling EEgLogger. exe simultaneously with another modality it starts with authorization everytime in the same application, due to which I am not able to fix both modalities timings. Also whenever I start EEGLogger It's time starts decreasing after ever run and than becomes constant.
How to save the cortex token and change the create session files for solving the above problem.
I have an Emotiv PRO License (academic) and I'm trying to access the raw eeg data stream. We keep encountering an error that says "The stream is unavailable or unsupported." although we do specify the license ID in the authorize API call. We looked at this issue but we were still unable to resolve the problem. Our licence is active.
self.send_command_to_cortex('authorize', { 'clientId': self.client_id, 'clientSecret': self.client_secret, 'license': license_id, 'debit': debit})
REQUEST ACCESS
cortex response:
{'id': 1, 'jsonrpc': '2.0', 'result': {'accessGranted': True, 'message': 'The user has granted access right to this application.'}}
AUTHORIZE
cortex reponse:
{'id': 2, 'jsonrpc': '2.0', 'result': {'cortexToken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS5qLmVsaGFicm91ay5oZWFkc2V0cmVhZGVyIiwiYXBwVmVyc2lvbiI6IjEuMCIsImV4cCI6MTU3MjAyMjk1NCwibmJmIjoxNTcxNzYzNzU0LCJ1c2VySWQiOiIyYzEsdkhjfkjsnfjnskldfksjdlMS1mNjQzNTMwMDYwOWMiLCJ1c2VybmFtZSI6ImouZWxoYWJyb3VrIiwidmVyc2lvbiI6IjIuMCJ9.2+9wjeMMA5m+V3gasiCDwpJdOpVe3NFAfwKNK26Qrjg='}}
QUERY HEADSETS
cortex found headsets ['INSIGHT-A1D20287']
cortex response:
{'id': 3, 'jsonrpc': '2.0', 'result': [{'connectedBy': 'bluetooth', 'customName': '', 'dongle': '0', 'firmware': '930', 'id': 'INSIGHT-A1D20287', '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'}, 'status': 'connected'}]}
CREATE SESSION
QUERY SESSIONS
cortex response:
{'id': 5, 'jsonrpc': '2.0', 'result': [{'appId': 'com.j.sdsd.sdsd', 'headset': {'connectedBy': 'bluetooth', 'customName': '', 'dongle': '0', 'firmware': '930', 'id': 'INSIGHT-A1D20287', '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'}, 'status': 'connected'}, 'id': 'f032341-a25b-450e-9826-cf28ba934e19', 'license': '', 'owner': 'j.sdsd', 'recordIds': [], 'recording': False, 'started': '2019-10-23T13:02:34.897-04:00', 'status': 'opened', 'stopped': '', 'streams': []}]}
DEBUG:cortex:cortex response:
{'id': 5, 'jsonrpc': '2.0', 'result': [{'appId': 'com.j.dssd.sdsd', 'headset': {'connectedBy': 'bluetooth', 'customName': '', 'dongle': '0', 'firmware': '930', 'id': 'INSIGHT-A1D20287', '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'}, 'status': 'connected'}, 'id': 'f03sdj1-a25b-47e-93f6-cf28ba934e19', 'license': '', 'owner': 'j.sdsd', 'recordIds': [], 'recording': False, 'started': '2019-10-23T13:02:34.897-04:00', 'status': 'opened', 'stopped': '', 'streams': []}]}
SUBSCRIBE
cortex response:
{'id': 6, 'jsonrpc': '2.0', 'result': {'failure': [{'code': -32016, 'message': 'The stream is unavailable or unsupported.', 'streamName': 'eeg'}], 'success': []}}
DEBUG:cortex:cortex response:
{'id': 6, 'jsonrpc': '2.0', 'result': {'failure': [{'code': -32016, 'message': 'The stream is unavailable or unsupported.', 'streamName': 'eeg'}], 'success': []}}
Thanks.
The requirements.txt file in the python example lists websocket
as a requirement instead of websockets
The right parameter name (key) is license, not license_id. So:
params['license'] = license_id
Hi,
I am trying to export data on a CSV file using python and for this I added the following lines to cortex.py
async def export_record(self, recordIds, folder, format, stream_types):
params = {'cortexToken': self.auth_token,
'recordIds': recordIds,
'folder': folder,
'format': format,
'streamTypes': stream_types}
resp = await self.send_command('exportRecord', **params)
logger.debug(f"{__name__} resp:\n{resp}")
return resp
I am calling the function in the main file (example.py) :
while cortex.packet_count < 100:
await cortex.get_data()
await cortex.export_record(recordIds="test_record_1" ,folder="/Users/xav/Desktop/",format="CSV",stream_types={'pow','met'})
await cortex.close_session()
My issue is to get the recordIds variable. Tried several things but get errors such as TypeError: Object of type set is not JSON serializable
My question is how can I get recordlds ?
Thank you,
Xavier
We have created the cortex_creds using Notepad, including the below information. And the EMOTIV App has been connected with the equipment. Then the example.py has been run and the obtained information is shown as below. We have tried many ways and can not solve it. Please you help us!
client_id ..................
client_secret ..................
D:\Python\Python37\python.exe E:/myTFileschx/EmotivTesting/cortex-v2-example-master/python/example.py
** USER LOGIN **
Sending request:
{"jsonrpc": "2.0", "method": "getUserLogin", "params": {}, "id": 1}
sent; awaiting response
lib.cortex resp:
{'currentOSUId': '1001', 'currentOSUsername': 'lenovo', 'loggedInOSUId': '1001', 'loggedInOSUsername': 'lenovo', 'username': '2259b2ef9eeebb5'}
Sending request:
{"jsonrpc": "2.0", "method": "getCortexInfo", "params": {}, "id": 2}
sent; awaiting response
lib.cortex resp:
{'id': 2, 'jsonrpc': '2.0', 'result': {'buildDate': '2019-09-03T09:40:00', 'buildNumber': 'v2.0.2-417-g3845976', 'version': '2.2.0'}}
Sending request:
{"jsonrpc": "2.0", "method": "requestAccess", "params": {"clientId": "JwoNlMmZ7LqXAafsbr3ldnGIoF2F0W5DdUQ27mN9", "clientSecret": "D9LHZtzlgYvBEJegWLCMNXhyXCEIimga0W3PSTLJNaOMJDjCXzC8ULmZQ1bXOqaCCrsVbBTOec1bbPhXXCskfk2DbqMrRiDFgA8Ia2pAQhDXjnsAkJZPqcmeRo5bNkE8"}, "id": 3}
sent; awaiting response
** GET CORTEX INFO **
** HAS ACCESS RIGHT **
lib.cortex resp:
{'id': 3, 'jsonrpc': '2.0', 'result': {'accessGranted': True, 'message': 'The User has access right to this application.'}}
Sending request:
** REQUEST ACCESS **
{"jsonrpc": "2.0", "method": "requestAccess", "params": {"clientId": "JwoNlMmZ7LqXAafsbr3ldnGIoF2F0W5DdUQ27mN9", "clientSecret": "D9LHZtzlgYvBEJegWLCMNXhyXCEIimga0W3PSTLJNaOMJDjCXzC8ULmZQ1bXOqaCCrsVbBTOec1bbPhXXCskfk2DbqMrRiDFgA8Ia2pAQhDXjnsAkJZPqcmeRo5bNkE8"}, "id": 4}
sent; awaiting response
** AUTHORIZE **
lib.cortex resp:
{'id': 4, 'jsonrpc': '2.0', 'result': {'accessGranted': True, 'message': 'The User has access right to this application.'}}
Sending request:
{"jsonrpc": "2.0", "method": "authorize", "params": {"clientId": "JwoNlMmZ7LqXAafsbr3ldnGIoF2F0W5DdUQ27mN9", "clientSecret": "D9LHZtzlgYvBEJegWLCMNXhyXCEIimga0W3PSTLJNaOMJDjCXzC8ULmZQ1bXOqaCCrsVbBTOec1bbPhXXCskfk2DbqMrRiDFgA8Ia2pAQhDXjnsAkJZPqcmeRo5bNkE8"}, "id": 5}
sent; awaiting response
lib.cortex resp:
{'id': 5, 'jsonrpc': '2.0', 'result': {'cortexToken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS4yMjU5YjJlZjllZWViYjUuamFja2Nhb18yMDE5ODMwIiwiYXBwVmVyc2lvbiI6IjEuMCIsImV4cCI6MTU2ODc2NjU1MSwibGljZW5zZUlkIjoiYWZiMzU5NGMtNTQ2OS00YTFmLWE3MjctNDQ5OTE2NjU4NGEyIiwibmJmIjoxNTY4NTA3MzUxLCJ1c2VySWQiOiIyOTkwZDlmNy1jMWYyLTQ1YWUtYmNmMy0zMjMzODExZDM5MzciLCJ1c2VybmFtZSI6IjIyNTliMmVmOWVlZWJiNSIsInZlcnNpb24iOiIyLjAifQ==.09oJ1w6mDPucPxlSFzHUp6A+o7GeigZxTzacHpbaSaE='}}
Sending request:
{"jsonrpc": "2.0", "method": "getLicenseInfo", "params": {"cortexToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS4yMjU5YjJlZjllZWViYjUuamFja2Nhb18yMDE5ODMwIiwiYXBwVmVyc2lvbiI6IjEuMCIsImV4cCI6MTU2ODc2NjU1MSwibGljZW5zZUlkIjoiYWZiMzU5NGMtNTQ2OS00YTFmLWE3MjctNDQ5OTE2NjU4NGEyIiwibmJmIjoxNTY4NTA3MzUxLCJ1c2VySWQiOiIyOTkwZDlmNy1jMWYyLTQ1YWUtYmNmMy0zMjMzODExZDM5MzciLCJ1c2VybmFtZSI6IjIyNTliMmVmOWVlZWJiNSIsInZlcnNpb24iOiIyLjAifQ==.09oJ1w6mDPucPxlSFzHUp6A+o7GeigZxTzacHpbaSaE="}, "id": 6}
sent; awaiting response
** GET LICENSE INFO **
** QUERY HEADSETS **
** CREATE SESSION **
lib.cortex resp:
{'id': 6, 'jsonrpc': '2.0', 'result': {'isOnline': True, 'license': {'applications': ['com.emotiv.sdk.basic'], 'billingFrom': '2019-08-27T08:00:00.000+08:00', 'billingTo': '2029-08-24T08:00:00.000+08:00', 'deviceInfo': {'deviceLimit': 3, 'devicesPerSeat': 3, 'sessionLimit': {'day': None, 'month': None, 'year': None}}, 'expired': False, 'extenderLimit': 6, 'hardLimitTime': '2019-10-05T07:59:59.999+08:00', 'isCommercial': False, 'licenseId': 'afb3594c-5469-4a1f-a727-4499166584a2', 'licenseName': 'Basic License', 'localQuota': 0, 'maxDebit': None, 'scopes': [''], 'seatCount': 1, 'sessionCount': 0, 'softLimitTime': '2019-09-28T07:59:59.999+08:00', 'totalDebit': 0, 'totalRegisteredDevices': 1, 'validFrom': '2019-08-27T08:00:00.000+08:00', 'validTo': '2029-08-25T07:59:59.999+08:00'}}}
Sending request:
{"jsonrpc": "2.0", "method": "queryHeadsets", "params": {}, "id": 7}
sent; awaiting response
lib.cortex found headsets ['EPOCPLUS-3B9AEBCD']
lib.cortex resp:
{'id': 7, 'jsonrpc': '2.0', 'result': [{'connectedBy': 'dongle', 'customName': '', 'dongle': '6ff', 'firmware': '625', 'id': 'EPOCPLUS-3B9AEBCD', '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': 0, 'memsRes': 16, 'mode': 'EPOCPLUS'}, 'status': 'connected'}]}
Sending request:
{"jsonrpc": "2.0", "method": "createSession", "params": {"cortexToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS4yMjU5YjJlZjllZWViYjUuamFja2Nhb18yMDE5ODMwIiwiYXBwVmVyc2lvbiI6IjEuMCIsImV4cCI6MTU2ODc2NjU1MSwibGljZW5zZUlkIjoiYWZiMzU5NGMtNTQ2OS00YTFmLWE3MjctNDQ5OTE2NjU4NGEyIiwibmJmIjoxNTY4NTA3MzUxLCJ1c2VySWQiOiIyOTkwZDlmNy1jMWYyLTQ1YWUtYmNmMy0zMjMzODExZDM5MzciLCJ1c2VybmFtZSI6IjIyNTliMmVmOWVlZWJiNSIsInZlcnNpb24iOiIyLjAifQ==.09oJ1w6mDPucPxlSFzHUp6A+o7GeigZxTzacHpbaSaE=", "headset": "EPOCPLUS-3B9AEBCD", "status": "active"}, "id": 8}
sent; awaiting response
Got error in createSession with params {'cortexToken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS4yMjU5YjJlZjllZWViYjUuamFja2Nhb18yMDE5ODMwIiwiYXBwVmVyc2lvbiI6IjEuMCIsImV4cCI6MTU2ODc2NjU1MSwibGljZW5zZUlkIjoiYWZiMzU5NGMtNTQ2OS00YTFmLWE3MjctNDQ5OTE2NjU4NGEyIiwibmJmIjoxNTY4NTA3MzUxLCJ1c2VySWQiOiIyOTkwZDlmNy1jMWYyLTQ1YWUtYmNmMy0zMjMzODExZDM5MzciLCJ1c2VybmFtZSI6IjIyNTliMmVmOWVlZWJiNSIsInZlcnNpb24iOiIyLjAifQ==.09oJ1w6mDPucPxlSFzHUp6A+o7GeigZxTzacHpbaSaE=', 'headset': 'EPOCPLUS-3B9AEBCD', 'status': 'active'}:
{"error":{"code":-32019,"message":"Session limit on this device has been reached."},"id":8,"jsonrpc":"2.0"}
Traceback (most recent call last):
File "E:/myTFileschx/EmotivTesting/cortex-v2-example-master/python/example.py", line 44, in
test()
File "E:/myTFileschx/EmotivTesting/cortex-v2-example-master/python/example.py", line 39, in test
asyncio.run(do_stuff(cortex))
File "D:\Python\Python37\lib\asyncio\runners.py", line 43, in run
return loop.run_until_complete(main)
File "D:\Python\Python37\lib\asyncio\base_events.py", line 579, in run_until_complete
return future.result()
File "E:/myTFileschx/EmotivTesting/cortex-v2-example-master/python/example.py", line 23, in do_stuff
await cortex.create_session(activate=True, headset_id=cortex.headsets[0])
File "E:\myTFileschx\EmotivTesting\cortex-v2-example-master\python\lib\cortex.py", line 271, in create_session
resp = await self.send_command('createSession', **params)
File "E:\myTFileschx\EmotivTesting\cortex-v2-example-master\python\lib\cortex.py", line 154, in send_command
raise CortexApiException(resp)
lib.cortex.CortexApiException: {"error":{"code":-32019,"message":"Session limit on this device has been reached."},"id":8,"jsonrpc":"2.0"}
Process finished with exit code 1
Hi there,
I'm currently working on Emotiv Insight device using C# and I've installed the SDK provided as well as using Cortex V2 examples for my reference. My plan is to use the free version which I don't need to provide the license.
So I did all the necessary steps to achieve that, I received my client id and client secret from my account then included that in the Config.cs.
However, when I ran the application from project FacialExpressionTraining (which don't require license key), I received an error stating that I need one to run this. The error is stated as below:
-32002 message Invalid license key
Is there a way to fix this ? Please help me with this. I'm relatively new to Emotiv devices.
MessageErrorRecieved :code -32027
message: The application do not have permission to use the license.
Note: I have already added a licence key for pro version as well as client id and secret key
I'm attempting to replicate the power band data provided from the headset using my own operations. I was wondering what the required steps were in detail. My current steps are as follows:
Following this process my results aren't consistent with the power band data provided. They are much higher values and don't follow the same pattern (betaH might be higher than betaL in my data but much lower in the provided data).
Hello!
I want to get eeg data and dev data at same time so I subscribe to stream_list:['eeg', 'dev'], I got the following logging info after I run example.py. I called cortex.get_data() once per 0.2s, but I got the eeg and dev data irregularly.
get_data got {"eeg":[61,0,0.007,0.383,-3.775,0.169,0.671,-2.068,0.643,0.642,0.535,-0.636,0.218,0.412,3.971,0.223,-0.325,-0.021,-0.446,0.024,0.478,0.388,-3.604,-0.375,0.036,0.828,1.65,0.712,0.326,-0.554,-1.979,-4.646,-2.841,0.095,8064.0,0.0,0,[]],"sid":"98bc0ab6-7b56-4235-b336-f1e020a20330","time":1575369399.2567} get_data got {"eeg":[62,0,0.007,0.383,-4.285,0.169,0.671,-0.015,0.643,0.641,0.535,0.903,0.218,0.412,3.967,0.223,-0.837,-0.021,-0.446,0.024,0.477,0.388,-3.6,-0.375,0.036,0.827,1.648,0.711,0.325,-0.553,-1.977,-5.154,-3.864,0.094,8064.0,0.0,0,[]],"sid":"98bc0ab6-7b56-4235-b336-f1e020a20330","time":1575369399.2645} get_data got {"dev":[-1,0,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],"sid":"98bc0ab6-7b56-4235-b336-f1e020a20330","time":1575369399.3645} get_data got {"eeg":[63,0,0.007,0.382,-2.229,0.169,0.67,-0.015,0.642,0.64,0.534,0.389,0.218,0.411,3.963,0.223,-0.323,-0.021,-0.446,0.024,0.477,0.387,-3.596,-0.375,0.036,0.826,2.159,0.71,0.325,-0.553,-1.975,-4.636,-3.347,0.094,8064.0,0.0,0,[]],"sid":"98bc0ab6-7b56-4235-b336-f1e020a20330","time":1575369399.2721} get_data got {"eeg":[64,0,0.007,0.382,-0.175,0.168,0.669,-0.015,0.128,0.64,0.534,0.389,0.218,0.411,3.959,0.222,0.19,-0.021,-0.445,0.024,0.476,0.387,-3.593,0.139,0.036,0.825,1.644,0.71,0.325,-0.552,-1.973,-4.631,-3.344,0.094,0.0,0.0,0,[]],"sid":"98bc0ab6-7b56-4235-b336-f1e020a20330","time":1575369399.2799} get_data got {"dev":[-1,0,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],"sid":"98bc0ab6-7b56-4235-b336-f1e020a20330","time":1575369399.3723} get_data got {"dev":[-1,0,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],"sid":"98bc0ab6-7b56-4235-b336-f1e020a20330","time":1575369399.3801} get_data got {"eeg":[65,0,0.007,0.381,-0.688,0.168,0.669,-0.015,1.667,0.126,0.533,0.388,0.218,0.41,3.955,0.222,-3.4,-0.021,-0.445,0.024,0.476,0.386,-3.589,-0.887,0.036,0.824,-0.922,0.709,0.324,-0.551,-1.971,-5.14,-3.853,0.094,0.0,0.0,0,[]],"sid":"98bc0ab6-7b56-4235-b336-f1e020a20330","time":1575369399.2875} get_data got {"eeg":[66,0,0.007,0.381,-0.175,0.168,0.668,-0.015,3.716,0.639,0.533,0.901,0.217,0.41,3.951,0.222,-3.91,-0.021,-0.444,0.024,0.475,0.386,-3.586,-2.937,0.036,0.824,-0.921,0.708,0.324,-0.038,-1.969,-4.622,-3.336,0.094,0.0,0.0,0,[]],"sid":"98bc0ab6-7b56-4235-b336-f1e020a20330","time":1575369399.2953} get_data got {"dev":[-1,0,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],"sid":"98bc0ab6-7b56-4235-b336-f1e020a20330","time":1575369399.3879}
How can I get eeg data and dev data at the same time? And what should I do if I want to get different data in different frequency?(The api get_data requires no args, how to get data flexibly?)
Thank u very much.
I'm interested in exporting real-time performance metric (such as focus, interest) into CSV files or other files and then visualizing the data, aiming to create an interactive experience. However, since Cortex has just upgraded to V2, I'm not sure which example suits my goal. It will be great if someone could tell me more about exporting the real-time data into CSV files.
Thank you so much!
I am trying to access the getDetectionInfo to read the mental commands but I am having a problem after that. I am new to programming and I need help on how to solve this.
{"id":411114,"jsonrpc":"2.0","result":{"actions":["push"],"message":"Set MentalCommand active actions successfully"}}
{'com': ['neutral', 0], 'sid': '81cd0e6e-e530-4552-a77c-14e9e7d1ada8', 'time': 1567649902.0082}
1
neutral
{'com': ['neutral', 0], 'sid': '81cd0e6e-e530-4552-a77c-14e9e7d1ada8', 'time': 1567649902.2596}
2
neutral
{'com': ['neutral', 0], 'sid': '81cd0e6e-e530-4552-a77c-14e9e7d1ada8', 'time': 1567649902.5101}
3
neutral
{'com': ['neutral', 0], 'sid': '81cd0e6e-e530-4552-a77c-14e9e7d1ada8', 'time': 1567649902.7606}
4
neutral
{'com': ['neutral', 0], 'sid': '81cd0e6e-e530-4552-a77c-14e9e7d1ada8', 'time': 1567649903.011}
5
neutral
{'com': ['neutral', 0], 'sid': '81cd0e6e-e530-4552-a77c-14e9e7d1ada8', 'time': 1567649903.2607}
6
neutral
{'com': ['neutral', 0], 'sid': '81cd0e6e-e530-4552-a77c-14e9e7d1ada8', 'time': 1567649903.5115}
7
neutral
{'com': ['neutral', 0], 'sid': '81cd0e6e-e530-4552-a77c-14e9e7d1ada8', 'time': 1567649903.7623}
Traceback (most recent call last):
File "", line 1, in
runfile('C:/Users/Rakesh Chandrakant/.spyder-py3/eegrover.py', wdir='C:/Users/Rakesh Chandrakant/.spyder-py3')
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Rakesh Chandrakant/.spyder-py3/eegrover.py", line 223, in
thought = json.loads(ws.recv())["com"][0]
KeyError: 'com'
Consider the following sample code:
https://gist.github.com/shohamj/ee93f5b86f226e84c98f11e8b8356404
On my system:
Example Output (No headsets are connected):
** Cortex V1 **
Connection took 0.0929114818572998 seconds
Query took 0.0009982585906982422 seconds
Headsets: []
** Cortex V2 **
Connection took 0.006994962692260742 seconds
Query took 1.0240464210510254 seconds
Headsets: []
Hi,
In our profile we have "only one command" trained - that is PUSH
We have coded for the Subscribe API( for mental commands).. While listening to the socket/stream, without thinking anything or being in neutral state -we are getting PUSH command in the socket or API response..
This is not correct.. We should only got "neutral" in the response..
Interestingly, with BCI standalone application's "LIVE testing" mode doesn't behave as above.. That is "the cube doesn't get pushed" and it stays still while being in "neutral" or not thinking about PUSH..
Kindly request you to correct this flaw at the earliest.
Our profile details
UserId: zabibaig
Profile Name: aci12345
Hello,
Even if I am connected through CORTEX App, I have the following message.
How can I solve this issue ?
Thanks,
Xavier
air-de-xav:nodejs xav$ sudo node cortex_code_example.js
Password:
(node:3628) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
You must login on CortexUI before request for grant access then rerun
(node:3628) UnhandledPromiseRejectionWarning: Error: You must login on CortexUI before request for grant access
at Cortex.checkGrantAccessAndQuerySessionInfo (/Users/xav/Desktop/GitHub/cortex-v2-example/nodejs/cortex_code_example.js:400:19)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
at async WebSocket. (/Users/xav/Desktop/GitHub/cortex-v2-example/nodejs/cortex_code_example.js:423:13)
(node:3628) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3628) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Hello,
I tried to run example.py and I have the error below (Session limit on this device has been reached). I have a EPOC+ and a EmotivPro (Academic) license. Can you please help ?
Thanks
air-de-xav:python xav$ python3 example.py
** USER LOGIN **
Sending request:
{"jsonrpc": "2.0", "method": "getUserLogin", "params": {}, "id": 1}
sent; awaiting response
lib.cortex resp:
{'currentOSUId': '501', 'currentOSUsername': 'xav', 'loggedInOSUId': '501', 'loggedInOSUsername': 'xav', 'username': 'lrenc'}
** GET CORTEX INFO **
Sending request:
{"jsonrpc": "2.0", "method": "getCortexInfo", "params": {}, "id": 2}
sent; awaiting response
lib.cortex resp:
{'id': 2, 'jsonrpc': '2.0', 'result': {'buidDate': '2019-06-24T15:05:21', 'buildNumber': '4eeba8e2', 'version': '2.0.2'}}
** HAS ACCESS RIGHT **
Sending request:
{"jsonrpc": "2.0", "method": "requestAccess", "params": {"clientId": "wW844zQFhtnzHZNdJbfWyE3x5M7qbXxrE0xL7Je7", "clientSecret": "KxcrcJa0MohokLA6pQSfHG1bob0M7FSRtQlpNzjBgCQfRSTdvikXlwLujgbGCLSEf0AdoveHwh2mObe5RytGgXwT2lElj4biL7pTTyzvTnI3u4RyFqwagbWPjGkpdSZl"}, "id": 3}
sent; awaiting response
lib.cortex resp:
{'id': 3, 'jsonrpc': '2.0', 'result': {'accessGranted': True, 'message': 'The User has access right to this application.'}}
** REQUEST ACCESS **
Sending request:
{"jsonrpc": "2.0", "method": "requestAccess", "params": {"clientId": "wW844zQFhtnzHZNdJbfWyE3x5M7qbXxrE0xL7Je7", "clientSecret": "KxcrcJa0MohokLA6pQSfHG1bob0M7FSRtQlpNzjBgCQfRSTdvikXlwLujgbGCLSEf0AdoveHwh2mObe5RytGgXwT2lElj4biL7pTTyzvTnI3u4RyFqwagbWPjGkpdSZl"}, "id": 4}
sent; awaiting response
lib.cortex resp:
{'id': 4, 'jsonrpc': '2.0', 'result': {'accessGranted': True, 'message': 'The User has access right to this application.'}}
** AUTHORIZE **
Sending request:
{"jsonrpc": "2.0", "method": "authorize", "params": {"clientId": "wW844zQFhtnzHZNdJbfWyE3x5M7qbXxrE0xL7Je7", "clientSecret": "KxcrcJa0MohokLA6pQSfHG1bob0M7FSRtQlpNzjBgCQfRSTdvikXlwLujgbGCLSEf0AdoveHwh2mObe5RytGgXwT2lElj4biL7pTTyzvTnI3u4RyFqwagbWPjGkpdSZl"}, "id": 5}
sent; awaiting response
lib.cortex resp:
{'id': 5, 'jsonrpc': '2.0', 'result': {'cortexToken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS5scmVuYy50ZXN0XzEiLCJhcHBWZXJzaW9uIjoiMS4wIiwiZXhwIjoxNTY0MjQwMTE5LCJsaWNlbnNlSWQiOiI5YzU4NTA4NS01ZTNhLTQyZmEtYTE2NS0xMzUxY2ExOGFhN2EiLCJuYmYiOjE1NjM5ODA5MTksInVzZXJJZCI6IjQ2Zjc2NzQwLTFlYWYtNDAzOS04Yzk1LTdhMzFkZGFkOWYwZSIsInVzZXJuYW1lIjoibHJlbmMiLCJ2ZXJzaW9uIjoiMi4wIn0=.DgDomts+xgC7Gqg/xwojSSHD7omrrX8FXE02OiGXRFI='}}
** GET LICENSE INFO **
Sending request:
{"jsonrpc": "2.0", "method": "getLicenseInfo", "params": {"cortexToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS5scmVuYy50ZXN0XzEiLCJhcHBWZXJzaW9uIjoiMS4wIiwiZXhwIjoxNTY0MjQwMTE5LCJsaWNlbnNlSWQiOiI5YzU4NTA4NS01ZTNhLTQyZmEtYTE2NS0xMzUxY2ExOGFhN2EiLCJuYmYiOjE1NjM5ODA5MTksInVzZXJJZCI6IjQ2Zjc2NzQwLTFlYWYtNDAzOS04Yzk1LTdhMzFkZGFkOWYwZSIsInVzZXJuYW1lIjoibHJlbmMiLCJ2ZXJzaW9uIjoiMi4wIn0=.DgDomts+xgC7Gqg/xwojSSHD7omrrX8FXE02OiGXRFI="}, "id": 6}
sent; awaiting response
lib.cortex resp:
{'id': 6, 'jsonrpc': '2.0', 'result': {'isOnline': True, 'license': {'applications': ['com.emotiv.sdk.basic'], 'billingFrom': '2019-04-18T02:00:00.000+02:00', 'billingTo': '2029-04-15T02:00:00.000+02:00', 'deviceInfo': {'deviceLimit': 3, 'devicesPerSeat': 3, 'sessionLimit': {'day': None, 'month': None, 'year': None}}, 'expired': False, 'extenderLimit': 6, 'hardLimitTime': '2019-08-26T01:59:59.999+02:00', 'isCommercial': False, 'licenseId': '9c585085-5e3a-42fa-a165-1351ca18aa7a', 'licenseName': 'Basic License', 'localQuota': 0, 'maxDebit': None, 'scopes': [], 'seatCount': 1, 'sessionCount': 0, 'softLimitTime': '2019-08-19T01:59:59.999+02:00', 'totalDebit': 2, 'totalRegisteredDevices': 1, 'validFrom': '2019-04-18T02:00:00.000+02:00', 'validTo': '2029-04-16T01:59:59.999+02:00'}}}
** QUERY HEADSETS **
Sending request:
{"jsonrpc": "2.0", "method": "queryHeadsets", "params": {}, "id": 7}
sent; awaiting response
lib.cortex found headsets ['EPOCPLUS-4A2C06E7']
lib.cortex resp:
{'id': 7, 'jsonrpc': '2.0', 'result': [{'connectedBy': 'bluetooth', 'customName': '', 'dongle': '0', 'firmware': '633', 'id': 'EPOCPLUS-4A2C06E7', 'motionSensors': ['Q0', 'Q1', 'Q2', 'Q3', 'ACCX', 'ACCY', 'ACCZ', 'MAGX', 'MAGY', 'MAGZ'], 'sensors': ['AF3', 'F7', 'F3', 'FC5', 'T7', 'P7', 'O1', 'O2', 'P8', 'T8', 'FC6', 'F4', 'F8', 'AF4'], 'settings': {'eegRate': 128, 'eegRes': 16, 'memsRate': 64, 'memsRes': 16, 'mode': 'EPOCPLUS'}, 'status': 'connected'}]}
** CREATE SESSION **
Sending request:
{"jsonrpc": "2.0", "method": "createSession", "params": {"cortexToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS5scmVuYy50ZXN0XzEiLCJhcHBWZXJzaW9uIjoiMS4wIiwiZXhwIjoxNTY0MjQwMTE5LCJsaWNlbnNlSWQiOiI5YzU4NTA4NS01ZTNhLTQyZmEtYTE2NS0xMzUxY2ExOGFhN2EiLCJuYmYiOjE1NjM5ODA5MTksInVzZXJJZCI6IjQ2Zjc2NzQwLTFlYWYtNDAzOS04Yzk1LTdhMzFkZGFkOWYwZSIsInVzZXJuYW1lIjoibHJlbmMiLCJ2ZXJzaW9uIjoiMi4wIn0=.DgDomts+xgC7Gqg/xwojSSHD7omrrX8FXE02OiGXRFI=", "headset": "EPOCPLUS-4A2C06E7", "status": "active"}, "id": 8}
sent; awaiting response
Got error in createSession with params {'cortexToken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNvbS5scmVuYy50ZXN0XzEiLCJhcHBWZXJzaW9uIjoiMS4wIiwiZXhwIjoxNTY0MjQwMTE5LCJsaWNlbnNlSWQiOiI5YzU4NTA4NS01ZTNhLTQyZmEtYTE2NS0xMzUxY2ExOGFhN2EiLCJuYmYiOjE1NjM5ODA5MTksInVzZXJJZCI6IjQ2Zjc2NzQwLTFlYWYtNDAzOS04Yzk1LTdhMzFkZGFkOWYwZSIsInVzZXJuYW1lIjoibHJlbmMiLCJ2ZXJzaW9uIjoiMi4wIn0=.DgDomts+xgC7Gqg/xwojSSHD7omrrX8FXE02OiGXRFI=', 'headset': 'EPOCPLUS-4A2C06E7', 'status': 'active'}:
{"error":{"code":-32019,"message":"Session limit on this device has been reached."},"id":8,"jsonrpc":"2.0"}
Traceback (most recent call last):
File "example.py", line 45, in
test()
File "example.py", line 40, in test
asyncio.run(do_stuff(cortex))
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
return future.result()
File "example.py", line 24, in do_stuff
headset_id=cortex.headsets[0])
File "/Users/xav/Desktop/GitHub/cortex-v2-example/python/lib/cortex.py", line 271, in create_session
resp = await self.send_command('createSession', **params)
File "/Users/xav/Desktop/GitHub/cortex-v2-example/python/lib/cortex.py", line 154, in send_command
raise CortexApiException(resp)
lib.cortex.CortexApiException: {"error":{"code":-32019,"message":"Session limit on this device has been reached."},"id":8,"jsonrpc":"2.0"}
air-de-xav:python xav$
Hello,
As I am a beginner in Unity and C#, I would like to know how it was possible to setup Cortex in Unity.
Thanks !
I'm programming with C #
with the examples that come in CORTEXUI2
But I couldn't resolve the error Received: Session limit on this device has been reached.
MessageErrorRecieved: code -32019 message Session limit on this device has been reached.
In the config file I don't have anything in LicenseId,
ย In DebitNumber I set the value 0.
And I could not solve the error.
Hello,
I am actually testing EmotivBCI Node-RED Toolbox. Although EmotivApp and Emotiv BCI are open and running, Node-Red displays the following message "Please ensure that you have Cortex installed and running in the background".
(I followed all the emotiv gitbook's instructions (Nodejs, Node-red and Node-red-contrib-emotiv-bci are correctly installed on the computer, my emotiv Insight is connected and I have a training profile with mental commands)
How can I solve this issue ?
Thanks,
Paul
I quite liked the cortex.js provided with the V1.0 example code; in particular how it queried the API from the service. I've updated the previous code to be v2.0 compliant, if you have any interest in including it here.
/*
* JS Cortex Wrapper
* *****************
*
* This library is intended to make working with Cortex easier in Javascript.
* We use it both in the browser and NodeJS code.
*
* It makes extensive use of Promises for flow control; all requests return a
* Promise with their result.
*
* For the subscription types in Cortex, we use an event emitter. Each kind of
* event (mot, eeg, etc) is emitted as its own event that you can listen for
* whether or not there are any active subscriptions at the time.
*
* The API methods are defined by using Cortex's inspectApi call. We mostly
* just pass information back and forth without doing much with it, with the
* exception of the login/auth flow, which we expose as the init() method.
*/
const WebSocket = require("ws");
const EventEmitter = require("events");
const CORTEX_URL = "wss://localhost:6868";
const safeParse = msg => {
try {
return JSON.parse(msg);
} catch (_) {
return null;
}
};
if (global.process) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
}
class JSONRPCError extends Error {
constructor(err) {
super(err.message);
this.name = this.constructor.name;
this.message = err.message;
this.code = err.code;
}
toString() {
return `${super.toString()} (${this.code})`;
}
}
class Cortex extends EventEmitter {
constructor(options = {}) {
super();
this.options = options;
this.host = options.host ? options.host : CORTEX_URL;
this.ws = new WebSocket(this.host);
this.msgId = 0;
this.requests = {};
this.streams = {};
this.ws.addEventListener("message", this._onmsg.bind(this));
this.ws.addEventListener("close", () => {
this._log("ws: Socket closed");
});
this.verbose = options.verbose !== null ? options.verbose : 1;
this.handleError = error => {
throw new JSONRPCError(error);
};
this.ready = new Promise(
resolve => this.ws.addEventListener("open", resolve),
this.handleError
)
.then(() => this._log("ws: Socket opened"))
.then(() => this.call("inspectApi"))
.then(methods => {
for (const m of methods) this.defineMethod(m.methodName, m.params);
this._log(`rpc: Added ${methods.length} methods from inspectApi`);
});
}
_onmsg(msg) {
const data = safeParse(msg.data);
if (!data) return this._warn("unparseable message", msg);
this._debug("ws: <-", msg.data);
if ("id" in data) {
const id = data.id;
this._log(
`[${id}] <-`,
data.result ? "success" : `error (${data.error.message})`
);
if (this.requests[id]) {
this.requests[id](data.error, data.result);
} else {
this._warn("rpc: Got response for unknown id", id);
}
} else if ("sid" in data) {
const dataKeys = Object.keys(data).filter(
k => k !== "sid" && k !== "time" && Array.isArray(data[k])
);
for (const k of dataKeys) {
this.emit(k, data) || this._warn("no listeners for stream event", k);
}
} else {
this._log("rpc: Unrecognised data", data);
}
}
_warn(...msg) {
if (this.verbose > 0) console.warn("[Cortex WARN]", ...msg);
}
_log(...msg) {
if (this.verbose > 1) console.warn("[Cortex LOG]", ...msg);
}
_debug(...msg) {
if (this.verbose > 2) console.warn("[Cortex DEBUG]", ...msg);
}
init({ clientId, clientSecret, debit } = {}) {
const result = this.getUserLogin()
.then(users => {
if (users[0])
this._log("init: Logged in user:", users[0].username);
})
.then(() => this.requestAccess({ clientId, clientSecret }))
.then(({ accessGranted }) => this.authorize({ clientId, clientSecret, debit }))
.then(({ cortexToken }) => {
this._log("init: Got auth token");
this._debug("init: Auth token", cortexToken);
this.cortexToken = cortexToken;
});
return result;
}
close() {
return new Promise(resolve => {
this.ws.close();
this.ws.once("close", resolve);
});
}
call(method, params = {}) {
const id = this.msgId++;
const msg = JSON.stringify({ jsonrpc: "2.0", method, params, id });
this.ws.send(msg);
this._log(`[${id}] -> ${method}`);
this._debug("ws: ->", msg);
return new Promise((resolve, reject) => {
this.requests[id] = (err, data) => {
delete this.requests[id];
this._debug("rpc: err", err, "data", data);
if (err) return reject(new JSONRPCError(err));
if (data) return resolve(data);
return reject(new Error("Invalid JSON-RPC response"));
};
});
}
defineMethod(methodName, paramDefs = []) {
if (this[methodName]) return;
const needsAuth = paramDefs.some(p => p.name === "cortexToken");
this._log("method: ", methodName, " needs auth: ", needsAuth);
const requiredParams = paramDefs.filter(p => p.required).map(p => p.name);
this[methodName] = (params = {}) => {
if (needsAuth && this.cortexToken && !params.cortexToken) {
params = Object.assign({}, params, { cortexToken: this.cortexToken });
}
const missingParams = requiredParams.filter(p => params[p] == null);
if (missingParams.length > 0) {
return this.handleError(
new Error(
`Missing required params for ${methodName}: ${missingParams.join(
", "
)}`
)
);
}
return this.call(methodName, params);
};
}
}
Cortex.JSONRPCError = JSONRPCError;
module.exports = Cortex;
I have already paid for the pro Version of Emotiv and registered for the EmotivProAPI I am still facing this error, is there any solution?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.