Skip to content

Commit

Permalink
Merge remote-tracking branch 'openbci/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Parfenov committed Oct 22, 2019
2 parents 182a73f + 465e90d commit 1050c9e
Show file tree
Hide file tree
Showing 26 changed files with 330 additions and 45 deletions.
6 changes: 5 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,13 @@ after_test:
# New-Item $env:APPVEYOR_BUILD_FOLDER\linux -itemtype directory
# New-Item $env:APPVEYOR_BUILD_FOLDER\osx -itemtype directory
# aws s3 cp s3://brainflow-artifacts/$env:APPVEYOR_REPO_COMMIT/linux/ $env:APPVEYOR_BUILD_FOLDER\linux\ --recursive
# ls $env:APPVEYOR_BUILD_FOLDER\linux
# aws s3 cp s3://brainflow-artifacts/$env:APPVEYOR_REPO_COMMIT/osx/ $env:APPVEYOR_BUILD_FOLDER\osx\ --recursive
# ls $env:APPVEYOR_BUILD_FOLDER\osx
# cd $env:APPVEYOR_BUILD_FOLDER\java-package\brainflow
# Copy-Item "$env:APPVEYOR_BUILD_FOLDER\linux\*" -Destination "$env:APPVEYOR_BUILD_FOLDER\java-package\brainflow\src\main\resources" -Recurse
# Copy-Item "$env:APPVEYOR_BUILD_FOLDER\osx\*" -Destination "$env:APPVEYOR_BUILD_FOLDER\java-package\brainflow\src\main\resources" -Recurse
# ls $env:APPVEYOR_BUILD_FOLDER\java-package\brainflow\src\main\resources;
# mvn package > mvn_final_stdout.txt
# #upload .jars to aws
# aws s3 cp %APPVEYOR_BUILD_FOLDER%\java-package\brainflow\target\ s3://brainflow-artifacts/%APPVEYOR_REPO_COMMIT%/jars --recursive
Expand All @@ -163,7 +168,6 @@ after_test:
# Else {
# write-output "Failed to wait for mac and linux libs"
# }

# on_finish:
# - appveyor PushArtifact %APPVEYOR_BUILD_FOLDER%\build32\brainflow_build32_stdout.txt
# - appveyor PushArtifact %APPVEYOR_BUILD_FOLDER%\build64\brainflow_build64_stdout.txt
Expand Down
30 changes: 19 additions & 11 deletions brainflow_boards.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@
"eda_channels" : [1, 2, 3, 4, 5, 6, 7, 8],
"ppg_channels" : [],
"accel_channels" : [9, 10, 11],
"analog_channels" : [],
"gyro_channels": [],
"other_channels": []
},
"0" : {
"name": "Cyton",
"sampling_rate": 250,
"package_num_channel" : 0,
"timestamp_channel" : 19,
"num_rows" : 20,
"timestamp_channel" : 22,
"num_rows" : 23,
"eeg_channels" : [1, 2, 3, 4, 5, 6, 7, 8],
"emg_channels" : [1, 2, 3, 4, 5, 6, 7, 8],
"ecg_channels" : [1, 2, 3, 4, 5, 6, 7, 8],
"eog_channels" : [1, 2, 3, 4, 5, 6, 7, 8],
"eda_channels" : [1, 2, 3, 4, 5, 6, 7, 8],
"ppg_channels" : [],
"accel_channels" : [9, 10, 11],
"analog_channels" : [19, 20, 21],
"gyro_channels": [],
"other_channels": [12, 13, 14, 15, 16, 17, 18]
},
Expand All @@ -45,22 +47,24 @@
"eda_channels" : [1, 2, 3, 4],
"ppg_channels" : [],
"accel_channels" : [5, 6, 8],
"analog_channels" : [],
"gyro_channels": [],
"other_channels": []
},
"2" : {
"name": "CytonDaisy",
"sampling_rate": 125,
"package_num_channel" : 0,
"timestamp_channel" : 27,
"num_rows" : 28,
"timestamp_channel" : 30,
"num_rows" : 31,
"eeg_channels" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"emg_channels" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"ecg_channels" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"eog_channels" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"eda_channels" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"ppg_channels" : [],
"accel_channels" : [17, 18, 19],
"analog_channels" : [27, 28, 29],
"gyro_channels": [],
"other_channels": [20, 21, 22, 23, 24, 25, 26]
},
Expand All @@ -77,56 +81,60 @@
"eda_channels" : [18],
"ppg_channels" : [17],
"accel_channels" : [19, 20, 21],
"analog_channels" : [],
"gyro_channels": [22, 23, 24],
"other_channels": []
},
"4" : {
"name": "GanglionWifi",
"sampling_rate": 1600,
"package_num_channel" : 0,
"timestamp_channel" : 15,
"num_rows" : 16,
"timestamp_channel" : 18,
"num_rows" : 19,
"eeg_channels" : [1, 2, 3, 4],
"emg_channels" : [1, 2, 3, 4],
"ecg_channels" : [1, 2, 3, 4],
"eog_channels" : [1, 2, 3, 4],
"eda_channels" : [1, 2, 3, 4],
"ppg_channels" : [],
"accel_channels" : [5, 6, 7],
"analog_channels" : [15, 16, 17],
"gyro_channels": [],
"other_channels": [8, 9, 10, 11, 12, 13, 14]
},
"5" : {
"name": "CytonWifi",
"sampling_rate": 1000,
"package_num_channel" : 0,
"timestamp_channel" : 19,
"num_rows" : 20,
"timestamp_channel" : 22,
"num_rows" : 23,
"eeg_channels" : [1, 2, 3, 4, 5, 6, 7, 8],
"emg_channels" : [1, 2, 3, 4, 5, 6, 7, 8],
"ecg_channels" : [1, 2, 3, 4, 5, 6, 7, 8],
"eog_channels" : [1, 2, 3, 4, 5, 6, 7, 8],
"eda_channels" : [1, 2, 3, 4, 5, 6, 7, 8],
"ppg_channels" : [],
"accel_channels" : [8, 10, 11],
"analog_channels" : [19, 20, 21],
"gyro_channels": [],
"other_channels": [12, 13, 14, 15, 16, 17, 18]
},
"6" : {
"name": "CytonDaisyWifi",
"sampling_rate": 1000,
"package_num_channel" : 0,
"timestamp_channel" : 27,
"num_rows" : 28,
"timestamp_channel" : 30,
"num_rows" : 31,
"eeg_channels" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"emg_channels" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"ecg_channels" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"eog_channels" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"eda_channels" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
"ppg_channels" : [],
"accel_channels" : [17, 18, 19],
"analog_channels" : [27, 28, 29],
"gyro_channels": [],
"other_channels": [20, 21, 22, 23, 24, 25, 26, 27]
"other_channels": [20, 21, 22, 23, 24, 25, 26]
}
}
}
11 changes: 11 additions & 0 deletions cpp-package/src/board_shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,17 @@ int *BoardShim::get_accel_channels (int board_id, int *len)
return accel_channels;
}

int *BoardShim::get_analog_channels (int board_id, int *len)
{
int *analog_channels = new int[MAX_CHANNELS];
int res = ::get_analog_channels (board_id, analog_channels, len);
if (res != STATUS_OK)
{
throw BrainFlowException ("failed get board info", res);
}
return analog_channels;
}

int *BoardShim::get_other_channels (int board_id, int *len)
{
int *other_channels = new int[MAX_CHANNELS];
Expand Down
1 change: 1 addition & 0 deletions cpp-package/src/board_shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class BoardShim
static int *get_ppg_channels (int board_id, int *len);
static int *get_eda_channels (int board_id, int *len);
static int *get_accel_channels (int board_id, int *len);
static int *get_analog_channels (int board_id, int *len);
static int *get_gyro_channels (int board_id, int *len);
static int *get_other_channels (int board_id, int *len);

Expand Down
12 changes: 12 additions & 0 deletions csharp-package/brainflow/brainflow/board_controller_library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public static class BoardControllerLibrary64
[DllImport ("BoardController.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_accel_channels (int board_id, int[] channels, int[] len);
[DllImport ("BoardController.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_analog_channels (int board_id, int[] channels, int[] len);
[DllImport ("BoardController.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_gyro_channels (int board_id, int[] channels, int[] len);
[DllImport ("BoardController.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_other_channels (int board_id, int[] channels, int[] len);
Expand Down Expand Up @@ -139,6 +141,8 @@ public static class BoardControllerLibrary32
[DllImport ("BoardController32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_accel_channels (int board_id, int[] channels, int[] len);
[DllImport ("BoardController32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_analog_channels (int board_id, int[] channels, int[] len);
[DllImport ("BoardController32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_gyro_channels (int board_id, int[] channels, int[] len);
[DllImport ("BoardController32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_other_channels (int board_id, int[] channels, int[] len);
Expand Down Expand Up @@ -314,6 +318,14 @@ public static int get_accel_channels (int board_id, int[] channels, int[] len)
return BoardControllerLibrary32.get_accel_channels (board_id, channels, len);
}

public static int get_analog_channels (int board_id, int[] channels, int[] len)
{
if (System.Environment.Is64BitProcess)
return BoardControllerLibrary64.get_analog_channels (board_id, channels, len);
else
return BoardControllerLibrary32.get_analog_channels (board_id, channels, len);
}

public static int get_gyro_channels (int board_id, int[] channels, int[] len)
{
if (System.Environment.Is64BitProcess)
Expand Down
17 changes: 17 additions & 0 deletions csharp-package/brainflow/brainflow/board_shim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,23 @@ public static int[] get_accel_channels (int board_id)
return result;
}

public static int[] get_analog_channels (int board_id)
{
int[] len = new int[1];
int[] channels = new int[512];
int res = BoardControllerLibrary.get_analog_channels (board_id, channels, len);
if (res != (int)CustomExitCodes.STATUS_OK)
{
throw new BrainFlowException (res);
}
int[] result = new int[len[0]];
for (int i = 0; i < len[0]; i++)
{
result[i] = channels[i];
}
return result;
}

public static int[] get_gyro_channels (int board_id)
{
int[] len = new int[1];
Expand Down
4 changes: 2 additions & 2 deletions docs/BuildBrainFlow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Common requirements

- Windows >= 8.1/Linux/MacOS
- On Windows we support x86/x64 libraries, for MacOS and Linux - only x64 bit libraries, if you need 32bit libraries for Linux you should compile them by yourself
- For Ganglion on Windows if you dont compile brainflow by yorself you may need to install `redist_x64 <https://aka.ms/vs/16/release/vc_redist.x64.exe>`_ or `redist_x86 <https://aka.ms/vs/16/release/vc_redist.x86.exe>`_ (but more likely you have it preinstalled) to use built-in Bluetooth API also you need Windows >= 10
- For Ganglion on Windows if you dont compile brainflow by yourself you may need to install `redist_x64 <https://aka.ms/vs/16/release/vc_redist.x64.exe>`_ or `redist_x86 <https://aka.ms/vs/16/release/vc_redist.x86.exe>`_ (but more likely you have it preinstalled) to use built-in Bluetooth API also you need Windows >= 10
- For Ganglion on Linux/MacOS you need to use dongle, for Windows dongle is not required if you have Bluetooth on your laptop

Compilation (Core module)
Expand Down Expand Up @@ -73,7 +73,7 @@ C#

For C# only Windows is currently supported

You can download latest release from `Nuget <https://www.nuget.org/packages/brainflow/>`_ or build it youself:
You can download latest release from `Nuget <https://www.nuget.org/packages/brainflow/>`_ or build it yourself:

- Compile BrainFlow's core module
- open Visual Studio Solution
Expand Down
68 changes: 68 additions & 0 deletions docs/DataFormatDesc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Data Format Description
=========================

**Methods like:**

.. code-block:: python
get_board_data ()
get_current_board_data (max_num_packages)
**Return 2d double array [num_channels x num_data_points], rows of this array contain data for EEG, EMG, Accel, Timesteps and other kinds of data.**

Exact format for this array is board specific but to keep API uniform we have methods like:

.. code-block:: python
# these methods return an array of rows in this 2d array containing eeg\emg\ecg\accel data
get_eeg_channels (board_id)
get_emg_channels (board_id)
get_ecg_channels (board_id)
get_accel_channels (board_id)
# and so on, check docs for full list
# also we have methods to get sampling rate from board id, get number of timestamp channel and others
get_sampling_rate (board_id)
get_timestamp_channel (board_id)
# and so on
Using methods above you can write completely board agnostic code and switch boards using single parameter! Even if you have only one board using these methods you can easily switch to Synthetic board for development and run code without real hardware.

Special channels for Cyton Based boards
-----------------------------------------

`Cyton based boards from OpenBCI <https://docs.openbci.com/Tutorials/00-Tutorials>`_ suport different output formats like described `here <https://docs.openbci.com/docs/02Cyton/CytonDataFormat#firmware-version-200-fall-2016-to-now-1>`_.

**For Cyton based boards we add Cyton End byte to a first channel from:**

.. code-block:: python
get_other_channels (board_id)
**If Cyton End bytes is equal to 0xC0 we add accel data, to get rows which contain accel data use:**

.. code-block:: python
get_accel_channels (board_id)
**If Cyton End bytes is equal to 0xC1 we add analog data, to get rows which contain analog data use:**

.. code-block:: python
get_analog_channels (board_id)
For analog data we return int32 values but from low level API we return double array so these values were casted to double wo any changes.

**If Cyton End Byte is between 0xC2 and 0xC6 we add raw unprocessed bytes to the second and following channels returned by:**

.. code-block:: python
get_other_channels (board_id)
For such data we return unprocessed raw bytes you should cast them to integer or floats

If Cyton End Byte outside `this range <https://docs.openbci.com/docs/02Cyton/CytonDataFormat#firmware-version-200-fall-2016-to-now-1>`_ we drop entire package.

**Check this example for details:**

.. literalinclude:: ../tests/python/brainflow_analog_mode_other_data.py
:language: py
2 changes: 1 addition & 1 deletion docs/UserAPI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ Check R sample to see how to use it.
Full code for R binding:

.. literalinclude:: ../r-package/brainflow/R/board_shim.R
:language: r
:language: r
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ These versions are exactly the same, choose one and use it
BuildBrainFlow
CoreModuleAPI
UserAPI
DataFormatDesc
Examples
BrainFlowDev
BrainFlowEmulator
Expand Down
2 changes: 1 addition & 1 deletion java-package/brainflow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<include>libBoardController.dylib</include>
<include>brainflow_boards.json</include>
<include>DataHandler.dll</include>
<include>libDataHandler.dll</include>
<include>libDataHandler.so</include>
<include>libDataHandler.dylib</include>
</includes>
</resource>
Expand Down
12 changes: 12 additions & 0 deletions java-package/brainflow/src/main/java/brainflow/BoardShim.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private interface DllInterface extends Library {
int get_eda_channels (int board_id, int[] eda_channels, int[] len);
int get_ppg_channels (int board_id, int[] ppg_channels, int[] len);
int get_accel_channels (int board_id, int[] accel_channels, int[] len);
int get_analog_channels (int board_id, int[] analog_channels, int[] len);
int get_gyro_channels (int board_id, int[] gyro_channels, int[] len);
int get_other_channels (int board_id, int[] other_channels, int[] len);
}
Expand Down Expand Up @@ -212,6 +213,17 @@ public static int[] get_accel_channels (int board_id) throws BrainFlowError {

return Arrays.copyOfRange(channels, 0, len[0]);
}

public static int[] get_analog_channels (int board_id) throws BrainFlowError {
int[] len = new int[1];
int[] channels = new int[512];
int ec = instance.get_analog_channels (board_id, channels, len);
if (ec != ExitCode.STATUS_OK.get_code ()) {
throw new BrainFlowError ("Error in board info getter", ec);
}

return Arrays.copyOfRange(channels, 0, len[0]);
}

public static int[] get_gyro_channels (int board_id) throws BrainFlowError {
int[] len = new int[1];
Expand Down

0 comments on commit 1050c9e

Please sign in to comment.