Skip to content

Commit

Permalink
adding ant neuro 511 (#635)
Browse files Browse the repository at this point in the history
* adding ant neuro 511

Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com>
  • Loading branch information
Andrey1994 committed Jun 4, 2023
1 parent 2a06189 commit f495392
Show file tree
Hide file tree
Showing 43 changed files with 1,975 additions and 1,877 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public enum BoardIds
GANGLION_NATIVE_BOARD = 46,
EMOTIBIT_BOARD = 47,
GALEA_BOARD_V4 = 48,
GALEA_SERIAL_BOARD_V4 = 49
GALEA_SERIAL_BOARD_V4 = 49,
ANT_NEURO_EE_511_BOARD = 51
};


Expand Down
3 changes: 2 additions & 1 deletion java_package/brainflow/src/main/java/brainflow/BoardIds.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public enum BoardIds
GANGLION_NATIVE_BOARD (46),
EMOTIBIT_BOARD (47),
GALEA_BOARD_V4 (48),
GALEA_SERIAL_BOARD_V4 (49);
GALEA_SERIAL_BOARD_V4 (49),
ANT_NEURO_EE_511_BOARD (51);

private final int board_id;
private static final Map<Integer, BoardIds> bi_map = new HashMap<Integer, BoardIds> ();
Expand Down
1 change: 1 addition & 0 deletions julia_package/brainflow/src/board_shim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export BrainFlowInputParams
EMOTIBIT_BOARD = 47
GALEA_BOARD_V4 = 48
GALEA_SERIAL_BOARD_V4 = 49
ANT_NEURO_EE_511_BOARD = 51

end

Expand Down
1 change: 1 addition & 0 deletions matlab_package/brainflow/BoardIds.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
EMOTIBIT_BOARD(47)
GALEA_BOARD_V4(48)
GALEA_SERIAL_BOARD_V4(49)
ANT_NEURO_EE_511_BOARD(51)
end
end
1 change: 1 addition & 0 deletions python_package/brainflow/board_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class BoardIds(enum.IntEnum):
EMOTIBIT_BOARD = 47 #:
GALEA_BOARD_V4 = 48 #:
GALEA_SERIAL_BOARD_V4 = 49 #:
ANT_NEURO_EE_511_BOARD = 51 #:


class IpProtocolTypes(enum.IntEnum):
Expand Down
1 change: 0 additions & 1 deletion python_package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
os.path.join('lib', 'eego-SDK32.dll'),
os.path.join('lib', 'eego-SDK.dll'),
os.path.join('lib', 'libeego-SDK.so'),
os.path.join('lib', 'libeego-SDK32.so'),
os.path.join('lib', 'BrainFlowBluetooth.dll'),
os.path.join('lib', 'BrainFlowBluetooth32.dll'),
os.path.join('lib', 'libBrainFlowBluetooth.so'),
Expand Down
74 changes: 66 additions & 8 deletions src/board_controller/ant_neuro/ant_neuro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ AntNeuroBoard::AntNeuroBoard (int board_id, struct BrainFlowInputParams params)

keep_alive = false;
initialized = false;
fact = NULL;
amp = NULL;
stream = NULL;
try
Expand All @@ -66,9 +67,10 @@ AntNeuroBoard::AntNeuroBoard (int board_id, struct BrainFlowInputParams params)
}
catch (...)
{
sampling_rate = 2000;
sampling_rate = -1.0;
}
reference_range = 1.0;
reference_range = -1.0;
bipolar_range = -1.0;
}

AntNeuroBoard::~AntNeuroBoard ()
Expand All @@ -87,14 +89,29 @@ int AntNeuroBoard::prepare_session ()

try
{
factory fact (ant_neuro_lib_path);
amp = fact.getAmplifier ();
fact = new factory (ant_neuro_lib_path);
safe_logger (spdlog::level::info, "eego sdk version is: {}.{}.{}.{}",
fact->getVersion ().major, fact->getVersion ().minor, fact->getVersion ().micro,
fact->getVersion ().build);
amp = fact->getAmplifier ();
reference_range = amp->getReferenceRangesAvailable ()[0];
bipolar_range = amp->getBipolarRangesAvailable ()[0];
if (sampling_rate < 0)
{
sampling_rate = amp->getSamplingRatesAvailable ()[0];
}
}
catch (const exceptions::notFound &e)
{
safe_logger (spdlog::level::err, "No devices found, {}", e.what ());
return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
}
catch (const std::runtime_error &e)
{
safe_logger (spdlog::level::err, "Exception, {}. Lib path {}", e.what (),
ant_neuro_lib_path.c_str ());
return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR;
}
catch (...)
{
safe_logger (
Expand Down Expand Up @@ -126,12 +143,14 @@ int AntNeuroBoard::start_stream (int buffer_size, const char *streamer_params)

try
{
stream = amp->OpenEegStream (sampling_rate,
reference_range); // todo do we need other args? If yes pass them via config_board
safe_logger (spdlog::level::info,
"sampling rate: {}, reference range: {}, bipolar range: {}", sampling_rate,
reference_range, bipolar_range);
stream = amp->OpenEegStream (sampling_rate, reference_range, bipolar_range);
}
catch (...)
catch (const std::runtime_error &e)
{
safe_logger (spdlog::level::err, "Failed to start acquisition.");
safe_logger (spdlog::level::err, "Failed to start acquisition: {}", e.what ());
return (int)BrainFlowExitCodes::STREAM_THREAD_ERROR;
}
if (stream == NULL)
Expand Down Expand Up @@ -174,6 +193,11 @@ int AntNeuroBoard::release_session ()
delete amp;
amp = NULL;
}
if (fact != NULL)
{
delete fact;
fact = NULL;
}
return (int)BrainFlowExitCodes::STATUS_OK;
}

Expand Down Expand Up @@ -268,6 +292,7 @@ int AntNeuroBoard::config_board (std::string config, std::string &response)

std::string prefix = "sampling_rate:";
std::string rv_prefix = "reference_range:";
std::string bv_prefix = "bipolar_range:";

if (config.find (prefix) != std::string::npos)
{
Expand Down Expand Up @@ -333,6 +358,39 @@ int AntNeuroBoard::config_board (std::string config, std::string &response)

return (int)BrainFlowExitCodes::STATUS_OK;
}
else if (config.find (bv_prefix) != std::string::npos)
{
double new_bipolar_range = 0.0;
std::string value = config.substr (bv_prefix.size ());
try
{
new_bipolar_range = std::stod (value);
}
catch (...)
{
safe_logger (spdlog::level::err, "format is '{}value'", bv_prefix.c_str ());
return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
}
// check that provided value is correct
std::vector<double> allowed_values = amp->getBipolarRangesAvailable ();
if (std::find (allowed_values.begin (), allowed_values.end (), new_bipolar_range) !=
allowed_values.end ())
{
bipolar_range = new_bipolar_range;
return (int)BrainFlowExitCodes::STATUS_OK;
}
else
{
safe_logger (spdlog::level::err, "not supported value provided");
for (int i = 0; i < (int)allowed_values.size (); i++)
{
safe_logger (spdlog::level::debug, "supported value: {}", allowed_values[i]);
}
return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
}

return (int)BrainFlowExitCodes::STATUS_OK;
}
safe_logger (spdlog::level::err, "format is '{}value'", prefix.c_str ());
return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
}
Expand Down
5 changes: 3 additions & 2 deletions src/board_controller/ant_neuro/build.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (UNIX AND NOT APPLE AND NOT ANDROID)
SET (ANT_LIB_NAME "libeego-SDK.so")
SET (ANT_LIB_NAME "libeego-SDK.so")
endif (UNIX AND NOT APPLE AND NOT ANDROID)
if (MSVC)
SET (ANT_LIB_NAME "eego-SDK.dll")
endif (MSVC)
else (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (UNIX AND NOT APPLE)
SET (ANT_LIB_NAME "libeego-SDK32.so")
message (WARNING "32 bit lib is not available for linux")
SET (ANT_LIB_NAME "libeego-SDK.so")
endif (UNIX AND NOT APPLE)
if (MSVC)
SET (ANT_LIB_NAME "eego-SDK32.dll")
Expand Down
11 changes: 6 additions & 5 deletions src/board_controller/ant_neuro/inc/ant_neuro.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

#include "board.h"

#if defined __linux__ || defined _WIN32
// required to dont link ant neuro sdk
#define EEGO_SDK_BIND_DYNAMIC

#include <eemagine/sdk/amplifier.h>
#include <eemagine/sdk/stream.h>
#endif
#include "eemagine/sdk/amplifier.h"
#include "eemagine/sdk/factory.h"
#include "eemagine/sdk/stream.h"
#include "eemagine/sdk/wrapper.h"


class AntNeuroBoard : public Board
Expand All @@ -23,10 +22,12 @@ class AntNeuroBoard : public Board
bool initialized;
std::thread streaming_thread;
std::string ant_neuro_lib_path;
eemagine::sdk::factory *fact;
eemagine::sdk::amplifier *amp;
eemagine::sdk::stream *stream;
int sampling_rate;
double reference_range;
double bipolar_range;

void read_thread ();
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/board_controller/board_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ int prepare_session (int board_id, const char *json_brainflow_input_params)
case BoardIds::GALEA_SERIAL_BOARD_V4:
board = std::shared_ptr<Board> (new GaleaSerialV4 (params));
break;
case BoardIds::ANT_NEURO_EE_511_BOARD:
board = std::shared_ptr<Board> (
new AntNeuroBoard ((int)BoardIds::ANT_NEURO_EE_511_BOARD, params));
break;
default:
return (int)BrainFlowExitCodes::UNSUPPORTED_BOARD_ERROR;
}
Expand Down
15 changes: 14 additions & 1 deletion src/board_controller/brainflow_boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ BrainFlowBoards::BrainFlowBoards()
{"46", json::object()},
{"47", json::object()},
{"48", json::object()},
{"49", json::object()}
{"49", json::object()},
{"51", json::object()}
}
}};

Expand Down Expand Up @@ -945,6 +946,18 @@ BrainFlowBoards::BrainFlowBoards()
{"other_channels", {15, 16}},
{"temperature_channels", {4}}
};
brainflow_boards_json["boards"]["51"]["default"] =
{
{"name", "AntNeuroEE511"},
{"sampling_rate", 4096},
{"timestamp_channel", 30},
{"marker_channel", 31},
{"package_num_channel", 0},
{"num_rows", 32},
{"eeg_channels", {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}},
{"emg_channels", {25, 26, 27, 28}},
{"other_channels", {29}}
};
}

BrainFlowBoards boards_struct;
3 changes: 2 additions & 1 deletion src/utils/inc/brainflow_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ enum class BoardIds : int
EMOTIBIT_BOARD = 47,
GALEA_BOARD_V4 = 48,
GALEA_SERIAL_BOARD_V4 = 49,
ANT_NEURO_EE_511_BOARD = 51,
// use it to iterate
FIRST = PLAYBACK_FILE_BOARD,
LAST = GALEA_SERIAL_BOARD_V4
LAST = ANT_NEURO_EE_511_BOARD
};

enum class IpProtocolTypes : int
Expand Down

0 comments on commit f495392

Please sign in to comment.