-
-
Notifications
You must be signed in to change notification settings - Fork 385
Add optional ANT Neuro EDX support #799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -602,4 +602,4 @@ std::string BoardShim::get_version () | |
| std::string verion_str (version, string_len); | ||
|
|
||
| return verion_str; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,8 +193,8 @@ Windows | |
| ~~~~~~~~ | ||
|
|
||
| - Install CMake>=3.16 you can install it from PYPI via pip or from `CMake website <https://cmake.org/>`_ | ||
| - Install Visual Studio 2019(preferred) or Visual Studio 2017. Other versions may work but not tested | ||
| - In VS installer make sure you selected "Visual C++ ATL support" | ||
| - Install Visual Studio with C++ build tools | ||
| - In Visual Studio installer make sure you selected "Visual C++ ATL support" | ||
| - Build it as a standard CMake project, you don't need to set any options | ||
|
|
||
| .. compound:: | ||
|
|
@@ -208,6 +208,18 @@ Windows | |
| # to get info about args and configure your build you can run | ||
| python build.py --help | ||
|
|
||
| .. compound:: | ||
|
|
||
| EDX profile on Windows (gRPC transport) example: :: | ||
|
|
||
| # make sure gRPC and protobuf are available in your CMake toolchain, | ||
| # for example via vcpkg or another preinstalled toolchain package | ||
|
|
||
| mkdir build-edx | ||
| cd build-edx | ||
| cmake -G "Visual Studio 17 2022" -A x64 -DBUILD_ANT_EDX=ON -DMSVC_RUNTIME=dynamic -DCMAKE_INSTALL_PREFIX=../installed-edx .. | ||
| cmake --build . --target install --config Release -j 2 --parallel 2 | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is it here? just add a cmake option and build.py option and set a default for this option properly, I dont think it requires mentioning it here |
||
|
|
||
| Linux | ||
| ~~~~~~ | ||
|
|
@@ -227,6 +239,23 @@ Linux | |
| # to get info about args and configure your build you can run | ||
| python3 build.py --help | ||
|
|
||
| .. compound:: | ||
|
|
||
| EDX profile on Linux example: :: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
|
|
||
| # install grpc/protobuf development dependencies first | ||
| # protobuf-compiler-grpc provides grpc_cpp_plugin used by CMake | ||
| sudo apt-get update | ||
| sudo apt-get install -y libprotobuf-dev protobuf-compiler libgrpc++-dev protobuf-compiler-grpc | ||
|
|
||
| mkdir build-edx | ||
| cd build-edx | ||
| cmake -DBUILD_ANT_EDX=ON -DBUILD_SYNCHRONI_SDK=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../installed-edx .. | ||
| make | ||
| make install | ||
|
|
||
| For EDX board configuration details, see :ref:`ant-neuro-edx-label`. | ||
|
|
||
| MacOS | ||
| ~~~~~~~ | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1148,6 +1148,136 @@ Available commands: | |
|
|
||
| For more information about Ant Neuro boards please refer to their User Manual. | ||
|
|
||
| Ant Neuro EDX | ||
| ~~~~~~~~~~~~~~ | ||
|
|
||
| EDX is a transport board that exposes ANT Neuro amplifiers through an external gRPC service. | ||
|
|
||
| Use board id: | ||
|
|
||
| - explicit self-describing EDX ids for known amplifiers: | ||
|
|
||
| - :code:`BoardIds.ANT_NEURO_EE_410_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_411_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_430_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_211_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_212_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_213_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_214_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_215_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_221_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_222_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_223_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_224_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_225_EDX_BOARD` | ||
| - :code:`BoardIds.ANT_NEURO_EE_511_EDX_BOARD` | ||
|
|
||
| Use one of the explicit EDX ids when you know the amplifier model. | ||
|
|
||
| Required BrainFlowInputParams fields: | ||
|
|
||
| - :code:`ip_address`, EDX service host (for example :code:`localhost`) | ||
| - :code:`ip_port`, EDX service port (for example :code:`3390`) | ||
|
|
||
| Optional fields: | ||
|
|
||
| - :code:`ip_protocol`, optional; :code:`IpProtocolTypes.EDX` is accepted for clarity | ||
| - :code:`timeout`, timeout for discovery and session operations, default is 15 sec | ||
|
|
||
| Important notes: | ||
|
|
||
| - Explicit EDX ids are self-describing and do not require :code:`master_board`. | ||
| - Available sampling rates and signal ranges are discovered from the amplifier at runtime via :code:`board.config_board("edx:get_capabilities")`. | ||
|
|
||
| Available commands: | ||
|
|
||
| - Get runtime capabilities: :code:`board.config_board("edx:get_capabilities")` | ||
| - Set sampling rate: :code:`board.config_board("sampling_rate:500")` | ||
| - Set reference range: :code:`board.config_board("reference_range:0.15")` | ||
| - Set bipolar range: :code:`board.config_board("bipolar_range:2.5")` | ||
| - Set impedance mode: :code:`board.config_board("impedance_mode:1")`, mode 0 or 1 | ||
|
|
||
| Initialization example (Python): | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| params = BrainFlowInputParams() | ||
| params.ip_address = "localhost" | ||
| params.ip_port = 3390 | ||
| params.ip_protocol = IpProtocolTypes.EDX | ||
| board = BoardShim(BoardIds.ANT_NEURO_EE_511_EDX_BOARD, params) | ||
|
|
||
| Configuration example (Python): | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| params = BrainFlowInputParams() | ||
| params.ip_address = "localhost" | ||
| params.ip_port = 3390 | ||
| params.ip_protocol = IpProtocolTypes.EDX | ||
| board = BoardShim(BoardIds.ANT_NEURO_EE_511_EDX_BOARD, params) | ||
| board.prepare_session() | ||
| print(board.config_board("edx:get_capabilities")) | ||
| board.config_board("sampling_rate:500") | ||
| board.config_board("reference_range:0.15") | ||
| board.config_board("bipolar_range:2.5") | ||
| board.start_stream() | ||
|
|
||
| Initialization example (C++): | ||
|
|
||
| .. code-block:: cpp | ||
|
|
||
| BrainFlowInputParams params; | ||
| params.ip_address = "localhost"; | ||
| params.ip_port = 3390; | ||
| params.ip_protocol = (int)IpProtocolTypes::EDX; | ||
| BoardShim board ((int)BoardIds::ANT_NEURO_EE_511_EDX_BOARD, params); | ||
|
|
||
| Configuration example (C++): | ||
|
|
||
| .. code-block:: cpp | ||
|
|
||
| BrainFlowInputParams params; | ||
| params.ip_address = "localhost"; | ||
| params.ip_port = 3390; | ||
| params.ip_protocol = (int)IpProtocolTypes::EDX; | ||
|
|
||
| BoardShim board ((int)BoardIds::ANT_NEURO_EE_511_EDX_BOARD, params); | ||
| board.prepare_session (); | ||
| std::string caps = board.config_board ("edx:get_capabilities"); | ||
| board.config_board ("sampling_rate:500"); | ||
| board.config_board ("reference_range:0.15"); | ||
| board.config_board ("bipolar_range:2.5"); | ||
| board.start_stream (); | ||
|
|
||
| Initialization example (Rust): | ||
|
|
||
| .. code-block:: rust | ||
|
|
||
| let params = BrainFlowInputParamsBuilder::default() | ||
| .ip_address("localhost") | ||
| .ip_port(3390) | ||
| .ip_protocol(IpProtocolTypes::Edx) | ||
| .build(); | ||
| let board = BoardShim::new(BoardIds::AntNeuroEe511EdxBoard, params)?; | ||
|
|
||
| Configuration example (Rust): | ||
|
|
||
| .. code-block:: rust | ||
|
|
||
| let params = BrainFlowInputParamsBuilder::default() | ||
| .ip_address("localhost") | ||
| .ip_port(3390) | ||
| .ip_protocol(IpProtocolTypes::Edx) | ||
| .build(); | ||
| let board = BoardShim::new(BoardIds::AntNeuroEe511EdxBoard, params)?; | ||
| board.prepare_session()?; | ||
| let caps = board.config_board("edx:get_capabilities")?; | ||
| board.config_board("sampling_rate:500")?; | ||
| board.config_board("reference_range:0.15")?; | ||
| board.config_board("bipolar_range:2.5")?; | ||
| board.start_stream(45000, "")?; | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its too much, just one example is enough |
||
| Enophone | ||
| --------- | ||
|
|
||
|
|
@@ -1560,4 +1690,4 @@ Supported platforms: | |
| - Windows | ||
| - Linux | ||
| - MacOS | ||
| - Devices like Raspberry Pi | ||
| - Devices like Raspberry Pi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| import org.apache.commons.lang3.SystemUtils; | ||
|
|
||
| import com.google.gson.Gson; | ||
| import com.google.gson.JsonObject; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is it needed here? |
||
| import com.sun.jna.JNIEnv; | ||
| import com.sun.jna.Library; | ||
| import com.sun.jna.Native; | ||
|
|
@@ -18,7 +19,6 @@ | |
| @SuppressWarnings ("deprecation") | ||
| public class BoardShim | ||
| { | ||
|
|
||
| private interface DllInterface extends Library | ||
| { | ||
| int prepare_session (int board_id, String params); | ||
|
|
@@ -1303,7 +1303,8 @@ public BoardShim (int board_id, BrainFlowInputParams params) | |
| { | ||
| if (params.get_master_board () == BoardIds.NO_BOARD.get_code ()) | ||
| { | ||
| throw new BrainFlowError ("need to set master board attribute in BrainFlowInputParams", | ||
| throw new BrainFlowError ( | ||
| "need to set master board attribute in BrainFlowInputParams", | ||
| BrainFlowExitCode.INVALID_ARGUMENTS_ERROR.get_code ()); | ||
| } else | ||
| { | ||
|
|
@@ -1328,7 +1329,8 @@ public BoardShim (BoardIds board_id, BrainFlowInputParams params) | |
| { | ||
| if (params.get_master_board () == BoardIds.NO_BOARD.get_code ()) | ||
| { | ||
| throw new BrainFlowError ("need to set master board attribute in BrainFlowInputParams", | ||
| throw new BrainFlowError ( | ||
| "need to set master board attribute in BrainFlowInputParams", | ||
| BrainFlowExitCode.INVALID_ARGUMENTS_ERROR.get_code ()); | ||
| } else | ||
| { | ||
|
|
@@ -1640,3 +1642,4 @@ public double[][] get_board_data (int num_datapoints) throws BrainFlowError | |
| return get_board_data (num_datapoints, BrainFlowPresets.DEFAULT_PRESET); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,8 @@ public enum IpProtocolTypes | |
|
|
||
| NO_IP_PROTOCOL (0), | ||
| UDP (1), | ||
| TCP (2); | ||
| TCP (2), | ||
| EDX (3); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed since you added new board ids to specify EDX, its not like the single board id which picks implementation based on this param, so no reasons to make it public |
||
|
|
||
| private final int protocol; | ||
| private static final Map<Integer, IpProtocolTypes> ip_map = new HashMap<Integer, IpProtocolTypes> (); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should not be here, its a public enum to specify which protocol to use if device supports multiple. This one supports just one