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
Andrey1994 committed Sep 25, 2019
2 parents 32fe04d + 96a35b6 commit dcc37c2
Show file tree
Hide file tree
Showing 48 changed files with 1,104 additions and 148 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,25 @@ before_script:
- sudo -H pip3 install $TRAVIS_BUILD_DIR/python-package
- cd $TRAVIS_BUILD_DIR/r-package/brainflow && sudo -H R CMD build . && sudo -H R CMD INSTALL brainflow_0.0.0.9000.tar.gz
- cd $TRAVIS_BUILD_DIR/tests/cpp && mkdir build && cd build && cmake -DCMAKE_PREFIX_PATH=$TRAVIS_BUILD_DIR/installed .. && make
- cd $TRAVIS_BUILD_DIR && cd java-package/brainflow && mvn package

script:
# tests for cyton
- sudo -H python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/cyton_linux.py python3 $TRAVIS_BUILD_DIR/tests/python/brainflow_get_data.py --log --board 0 --port
# Disable this test temporary, dont know whats wrong can not reproduce locally, will investigate later
#- cd $TRAVIS_BUILD_DIR && cd java-package/brainflow && mvn package && cd $TRAVIS_BUILD_DIR/tests/java/ && sudo -H javac -classpath $TRAVIS_BUILD_DIR/java-package/brainflow/target/brainflow-jar-with-dependencies.jar BrainFlowTest.java && ls -l . && sudo -H python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/cyton_linux.py java -classpath ".:$TRAVIS_BUILD_DIR/java-package/brainflow/target/brainflow-jar-with-dependencies.jar" BrainFlowTest 0
- sudo -H python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/cyton_linux.py Rscript $TRAVIS_BUILD_DIR/tests/r/brainflow_get_data.R
- LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TRAVIS_BUILD_DIR/installed/lib python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/cyton_linux.py $TRAVIS_BUILD_DIR/tests/cpp/build/test_get_data 0
# temp disable java test
# - cd $TRAVIS_BUILD_DIR/tests/java/ && sudo -H javac -classpath $TRAVIS_BUILD_DIR/java-package/brainflow/target/brainflow-java-jar-with-dependencies.jar BrainFlowTest.java && ls -l . && sudo -H python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/cyton_linux.py java -classpath ".:$TRAVIS_BUILD_DIR/java-package/brainflow/target/brainflow-java-jar-with-dependencies.jar" BrainFlowTest 0
# tests for synthetic board
- python3 $TRAVIS_BUILD_DIR/tests/python/brainflow_get_data.py --log --board -1 --port "smth"
- python3 $TRAVIS_BUILD_DIR/tests/python/brainflow_multiboard_get_data.py --log --first-board -1 --first-port "smth1" --second-board -1 --second-port "smth2"
- $TRAVIS_BUILD_DIR/tests/cpp/build/test_get_data -1 "smth"
# tests for cyton daisy
- sudo -H python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/cyton_linux.py python3 $TRAVIS_BUILD_DIR/tests/python/brainflow_get_data.py --log --board 2 --port
- LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TRAVIS_BUILD_DIR/installed/lib python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/cyton_linux.py $TRAVIS_BUILD_DIR/tests/cpp/build/test_get_data 2
# tests for novaxr
- sudo -H python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/novaxr_udp.py python3 $TRAVIS_BUILD_DIR/tests/python/brainflow_get_data.py --board 3 --port 127.0.0.1
- LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TRAVIS_BUILD_DIR/installed/lib python3 $TRAVIS_BUILD_DIR/emulator/brainflow_emulator/novaxr_udp.py $TRAVIS_BUILD_DIR/tests/cpp/build/test_get_data 3 127.0.0.1

# deploy only in openbci's fork
#after_success:
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ set (LIBRARY_SRC
"src/utils/timestamp.cpp"
"src/utils/data_buffer.cpp"
"src/utils/serial.cpp"
"src/utils/socket.cpp"
"src/board_controller/openbci/openbci_serial_board.cpp"
"src/board_controller/openbci/ganglion.cpp"
"src/board_controller/openbci/cyton.cpp"
"src/board_controller/openbci/cyton_daisy.cpp"
"src/board_controller/board_controller.cpp"
"src/board_controller/board.cpp"
"src/board_controller/synthetic_board.cpp"
"src/board_controller/openbci/novaxr.cpp"
)

add_library (
Expand Down
26 changes: 0 additions & 26 deletions CONTRIBUTING.md

This file was deleted.

10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ Brainflow is a library intended to obtain, parse and analyze EEG\EMG\ECG data fr

Core module of this library is implemented in C\C++ and available for all bindings as a dynamic library. This approach allows to reduce code duplication and simplify maintenance, also it's better than any streaming based solution because using this library you don't need to worry about inter process communication and it's a single dependency.


#### *NOTE: Brainflow was forked by OpenBCI community, I will contribute to [OpenBCI's fork](https://github.com/OpenBCI/brainflow) and maintain it. To download the latest stable version of Brainflow feel free to use OpenBCI's fork. Both versions are exactly the same*

## Build status
*Linux(Travis)*:
Compiled with:
* MSVC on Windows
* GCC on Linux
* Clang on MacOS

*Linux and MacOS(Travis)*:

[![Build Status](https://travis-ci.com/Andrey1994/brainflow.svg?branch=master)](https://travis-ci.com/Andrey1994/brainflow)

Expand All @@ -27,7 +31,5 @@ We support bindings for:
* [Matlab](./matlab-package/brainflow/)
* [C# (Windows only)](./csharp-package/brainflow/)

These bindings just call methods from dynamic libraries, if you are interested in other programming languages - feel free to create feature request

## License:
MIT
24 changes: 20 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ init:
- cmd: set BRAINFLOW_VERSION=%APPVEYOR_REPO_TAG_NAME%

install:
# compile brainflow for 32 and 64
- mkdir %APPVEYOR_BUILD_FOLDER%\build32 && cd %APPVEYOR_BUILD_FOLDER%\build32 && cmake -G "Visual Studio 15 2017" -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_INSTALL_PREFIX=..\installed32\ .. && cmake --build . --target install --config Release > brainflow_build32_stdout.txt
- mkdir %APPVEYOR_BUILD_FOLDER%\build64 && cd %APPVEYOR_BUILD_FOLDER%\build64 && cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_INSTALL_PREFIX=..\installed64\ .. && cmake --build . --target install --config Release > brainflow_build64_stdout.txt
# build csharp (in order for copy ganglion mock into csharp test folder)
## nuget package for csharp
- nuget install Accord -OutputDirectory ../csharp-package/brainflow/packages && nuget install Accord.Math -OutputDirectory ../csharp-package/brainflow/packages && nuget install MathNet.Filtering -OutputDirectory ../csharp-package/brainflow/packages
## 64
- cd %APPVEYOR_BUILD_FOLDER%\csharp-package\brainflow && msbuild brainflow.sln /p:Configuration=Release /p:Platform=x64 /p:OutDir=..\..\..\tests\csharp\build\Release
- cd %APPVEYOR_BUILD_FOLDER%\csharp-package\brainflow\brainflow\lib && cp BoardController.dll ..\..\..\..\tests\csharp\build\Release\
# install emulator for cyton
- pip install %APPVEYOR_BUILD_FOLDER%\emulator\
- cd %APPVEYOR_BUILD_FOLDER% && %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\com0com\certmgr.exe /add %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\com0com\com0com.cer /s /r localMachine root
Expand All @@ -34,18 +43,16 @@ install:
- cd %APPVEYOR_BUILD_FOLDER%\GanglionBLEAPI\Mock\build
- cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_SYSTEM_VERSION=8.1 ..
- cmake --build . --config Release > ganglion_mock_build64_stdout.txt
# compile brainflow for 32 and 64
- mkdir %APPVEYOR_BUILD_FOLDER%\build32 && cd %APPVEYOR_BUILD_FOLDER%\build32 && cmake -G "Visual Studio 15 2017" -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_INSTALL_PREFIX=..\installed32\ .. && cmake --build . --target install --config Release > brainflow_build32_stdout.txt
- mkdir %APPVEYOR_BUILD_FOLDER%\build64 && cd %APPVEYOR_BUILD_FOLDER%\build64 && cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_INSTALL_PREFIX=..\installed64\ .. && cmake --build . --target install --config Release > brainflow_build64_stdout.txt
# store real ganglion libs libraries in compiled folder
- cp %APPVEYOR_BUILD_FOLDER%\installed64\lib\GanglionLibNative64.dll %APPVEYOR_BUILD_FOLDER%\compiled\GanglionLibNative64.dll
- cp %APPVEYOR_BUILD_FOLDER%\installed32\lib\GanglionLibNative32.dll %APPVEYOR_BUILD_FOLDER%\compiled\GanglionLibNative32.dll
# replace real ganglion libs by mocks
- cp %APPVEYOR_BUILD_FOLDER%\GanglionBLEAPI\Mock\compiled\Release\GanglionLibNative64.dll %APPVEYOR_BUILD_FOLDER%\python-package\brainflow\lib\GanglionLibNative64.dll
- cp %APPVEYOR_BUILD_FOLDER%\GanglionBLEAPI\Mock\compiled\Release\GanglionLibNative64.dll %APPVEYOR_BUILD_FOLDER%\installed64\lib\GanglionLibNative64.dll
- cp %APPVEYOR_BUILD_FOLDER%\GanglionBLEAPI\Mock\compiled\Release\GanglionLibNative64.dll %APPVEYOR_BUILD_FOLDER%\java-package\brainflow\src\main\resources\GanglionLibNative64.dll
- cp %APPVEYOR_BUILD_FOLDER%\GanglionBLEAPI\Mock\compiled\Release\GanglionLibNative64.dll %APPVEYOR_BUILD_FOLDER%\tests\csharp\build\Release\
# install python package
- pip install %APPVEYOR_BUILD_FOLDER%\python-package\
- pip install %APPVEYOR_BUILD_FOLDER%\python-package\
# build cpp
- mkdir %APPVEYOR_BUILD_FOLDER%\tests\cpp\build && cd %APPVEYOR_BUILD_FOLDER%\tests\cpp\build && cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_PREFIX_PATH=%APPVEYOR_BUILD_FOLDER%\installed64\ .. && cmake --build . --config Release > cpp_test_build64_stdout.txt
- mkdir %APPVEYOR_BUILD_FOLDER%\tests\cpp\build32 && cd %APPVEYOR_BUILD_FOLDER%\tests\cpp\build32 && cmake -G "Visual Studio 15 2017" -DCMAKE_SYSTEM_VERSION=8.1 -DCMAKE_PREFIX_PATH=%APPVEYOR_BUILD_FOLDER%\installed32\ .. && cmake --build . --config Release > cpp_test_build32_stdout.txt
Expand All @@ -57,16 +64,25 @@ test_script:
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\cyton_windows.py python %APPVEYOR_BUILD_FOLDER%\tests\python\brainflow_get_data.py --log --board 0 --port
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\cyton_windows.py %APPVEYOR_BUILD_FOLDER%\tests\cpp\build\Release\test_get_data.exe 0
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\cyton_windows.py %APPVEYOR_BUILD_FOLDER%\tests\cpp\build32\Release\test_get_data.exe 0
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\cyton_windows.py %APPVEYOR_BUILD_FOLDER%\tests\csharp\build\Release\test.exe 0
# tests for ganglion
- python %APPVEYOR_BUILD_FOLDER%\tests\python\brainflow_get_data.py --log --board 1 --port e6:73:73:18:09:b1
- echo "stub text to dont start command with special character" && %APPVEYOR_BUILD_FOLDER%\tests\cpp\build\Release\test_get_data.exe 1 e6:73:73:18:09:b1
- cd %APPVEYOR_BUILD_FOLDER%\tests\csharp\build\Release && test.exe 1 e6:73:73:18:09:b1
# tests for synthetic
- python %APPVEYOR_BUILD_FOLDER%\tests\python\brainflow_get_data.py --log --board -1 --port "smth"
- python %APPVEYOR_BUILD_FOLDER%\tests\python\brainflow_multiboard_get_data.py --log --first-board -1 --first-port "smth1" --second-board -1 --second-port "smth2"
- echo "stub text to dont start command with special character" && %APPVEYOR_BUILD_FOLDER%\tests\cpp\build\Release\test_get_data.exe -1 "smth"
- cd %APPVEYOR_BUILD_FOLDER%\tests\csharp\build\Release && test.exe -1
# tests for cyton daisy
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\cyton_windows.py python %APPVEYOR_BUILD_FOLDER%\tests\python\brainflow_get_data.py --log --board 2 --port
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\cyton_windows.py %APPVEYOR_BUILD_FOLDER%\tests\cpp\build\Release\test_get_data.exe 2
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\cyton_windows.py %APPVEYOR_BUILD_FOLDER%\tests\csharp\build\Release\test.exe 2
# tests for novaxr
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\novaxr_udp.py python %APPVEYOR_BUILD_FOLDER%\tests\python\brainflow_get_data.py --board 3 --port 127.0.0.1
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\novaxr_udp.py %APPVEYOR_BUILD_FOLDER%\tests\cpp\build\Release\test_get_data.exe 3 127.0.0.1
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\novaxr_udp.py %APPVEYOR_BUILD_FOLDER%\tests\cpp\build32\Release\test_get_data.exe 3 127.0.0.1
- python %APPVEYOR_BUILD_FOLDER%\emulator\brainflow_emulator\novaxr_udp.py %APPVEYOR_BUILD_FOLDER%\tests\csharp\build\Release\test.exe 3 127.0.0.1

# replace mocked libraries by real libs
after_test:
Expand Down
19 changes: 19 additions & 0 deletions cpp-package/src/board_info_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ class SYNTHETIC
static const int first_eeg_channel = 1;
};


class NOVAXR
{
public:
static const int fs_hz = 2000;
static const int num_eeg_channels = 16;
static const int package_length = 25;
static const int first_eeg_channel = 1;
};


// todo: move it to low level api during implementation of signal processing in c++
class BoardInfoGetter
{
Expand All @@ -59,6 +70,8 @@ class BoardInfoGetter
return SYNTHETIC::package_length;
case CYTON_DAISY_BOARD:
return CYTON_DAISY::package_length;
case NOVAXR_BOARD:
return NOVAXR::package_length;
default:
throw BrainFlowException ("Unsupported Board Error", UNSUPPORTED_BOARD_ERROR);
}
Expand All @@ -76,6 +89,8 @@ class BoardInfoGetter
return SYNTHETIC::num_eeg_channels;
case CYTON_DAISY_BOARD:
return CYTON_DAISY::num_eeg_channels;
case NOVAXR_BOARD:
return NOVAXR::num_eeg_channels;
default:
throw BrainFlowException ("Unsupported Board Error", UNSUPPORTED_BOARD_ERROR);
}
Expand All @@ -93,6 +108,8 @@ class BoardInfoGetter
return SYNTHETIC::fs_hz;
case CYTON_DAISY_BOARD:
return CYTON_DAISY::fs_hz;
case NOVAXR_BOARD:
return NOVAXR::fs_hz;
default:
throw BrainFlowException ("Unsupported Board Error", UNSUPPORTED_BOARD_ERROR);
}
Expand All @@ -110,6 +127,8 @@ class BoardInfoGetter
return SYNTHETIC::first_eeg_channel;
case CYTON_DAISY_BOARD:
return CYTON_DAISY::first_eeg_channel;
case NOVAXR_BOARD:
return NOVAXR::first_eeg_channel;
default:
throw BrainFlowException ("Unsupported Board Error", UNSUPPORTED_BOARD_ERROR);
}
Expand Down
36 changes: 36 additions & 0 deletions cpp-package/src/board_shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,42 @@
#include "board_controller.h"
#include "board_shim.h"

void BoardShim::enable_board_logger ()
{
int res = set_log_level (2);
if (res != STATUS_OK)
{
throw BrainFlowException ("failed to enable board logger", res);
}
}

void BoardShim::disable_board_logger ()
{
int res = set_log_level (6);
if (res != STATUS_OK)
{
throw BrainFlowException ("failed to disable board logger", res);
}
}

void BoardShim::enable_dev_board_logger ()
{
int res = set_log_level (0);
if (res != STATUS_OK)
{
throw BrainFlowException ("failed to enable dev board logger", res);
}
}

void BoardShim::set_log_file (char *log_file)
{
int res = ::set_log_file (log_file);
if (res != STATUS_OK)
{
throw BrainFlowException ("failed to set log file", res);
}
}

BoardShim::BoardShim (int board_id, const char *port_name)
{
strcpy (this->port_name, port_name);
Expand Down
5 changes: 5 additions & 0 deletions cpp-package/src/board_shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class BoardShim
void reshape_data (int data_count, float *buf, double *ts_buf, double **output_buf);

public:
static void disable_board_logger ();
static void enable_board_logger ();
static void enable_dev_board_logger ();
static void set_log_file (char *log_file);

int num_data_channels;
int board_id;
char port_name[1024];
Expand Down
2 changes: 1 addition & 1 deletion csharp-package/brainflow/brainflow/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>
8 changes: 8 additions & 0 deletions csharp-package/brainflow/brainflow/board_info_getter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public static int get_fs_hz (int board_id)
return Synthetic.fs_hz;
case (int)BoardIds.CYTON_DAISY_BOARD:
return CytonDaisy.fs_hz;
case (int)BoardIds.NOVAXR_BOARD:
return Novaxr.fs_hz;
default:
throw new BrainFlowExceptioin ((int)CustomExitCodes.UNSUPPORTED_BOARD_ERROR);
}
Expand All @@ -31,6 +33,8 @@ public static int get_first_eeg_channel (int board_id)
return Synthetic.first_eeg_channel;
case (int)BoardIds.CYTON_DAISY_BOARD:
return CytonDaisy.first_eeg_channel;
case (int)BoardIds.NOVAXR_BOARD:
return Novaxr.first_eeg_channel;
default:
throw new BrainFlowExceptioin ((int)CustomExitCodes.UNSUPPORTED_BOARD_ERROR);
}
Expand All @@ -48,6 +52,8 @@ public static int get_num_eeg_channels (int board_id)
return Synthetic.num_eeg_channels;
case (int)BoardIds.CYTON_DAISY_BOARD:
return CytonDaisy.num_eeg_channels;
case (int)BoardIds.NOVAXR_BOARD:
return Novaxr.num_eeg_channels;
default:
throw new BrainFlowExceptioin ((int)CustomExitCodes.UNSUPPORTED_BOARD_ERROR);
}
Expand All @@ -65,6 +71,8 @@ public static int get_package_length (int board_id)
return Synthetic.package_length;
case (int)BoardIds.CYTON_DAISY_BOARD:
return CytonDaisy.package_length;
case (int)BoardIds.NOVAXR_BOARD:
return Novaxr.package_length;
default:
throw new BrainFlowExceptioin ((int)CustomExitCodes.UNSUPPORTED_BOARD_ERROR);
}
Expand Down
9 changes: 9 additions & 0 deletions csharp-package/brainflow/brainflow/board_shim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ public static void enable_dev_board_logger ()
}
}

public static void set_log_file (string log_file)
{
int res = Library.set_log_file (log_file);
if (res != (int)CustomExitCodes.STATUS_OK)
{
throw new BrainFlowExceptioin (res);
}
}

public void prepare_session ()
{
int res = Library.prepare_session (board_id, port_name);
Expand Down
3 changes: 2 additions & 1 deletion csharp-package/brainflow/brainflow/brainflow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>brainflow</RootNamespace>
<AssemblyName>brainflow</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
Expand Down Expand Up @@ -124,6 +124,7 @@
<Compile Include="board_info_getter.cs" />
<Compile Include="board_data.cs" />
<Compile Include="board_shim.cs" />
<Compile Include="novaxr.cs" />
<Compile Include="cyton.cs" />
<Compile Include="cyton_daisy.cs" />
<Compile Include="ganglion.cs" />
Expand Down

0 comments on commit dcc37c2

Please sign in to comment.