Skip to content
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

Freeeeg128 #662

Merged
merged 14 commits into from
Aug 13, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public enum BoardIds
GALEA_BOARD_V4 = 48,
GALEA_SERIAL_BOARD_V4 = 49,
NTL_WIFI_BOARD = 50,
ANT_NEURO_EE_511_BOARD = 51
ANT_NEURO_EE_511_BOARD = 51,
FREEEEG128_BOARD = 52
};


Expand Down
29 changes: 27 additions & 2 deletions docs/SupportedBoards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,8 @@ Supported platforms:

*Note: Unlike other boards it returns ADC values instead uV.*

FreeEEG32
----------
FreeEEG
--------

FreeEEG32
~~~~~~~~~~
Expand Down Expand Up @@ -719,6 +719,31 @@ Supported platforms:
- MacOS
- Devices like Raspberry Pi

FreeEEG128
~~~~~~~~~~

To create such board you need to specify the following board ID and fields of BrainFlowInputParams object:

- :code:`BoardIds.FREEEEG128_BOARD`
- :code:`serial_port`, e.g. COM6

Initialization Example:

.. code-block:: python
params = BrainFlowInputParams()
params.serial_port = "COM6"
board = BoardShim(BoardIds.FREEEEG128_BOARD, params)

**On Unix-like systems you may need to configure permissions for serial port or run with sudo.**

Supported platforms:

- Windows
- Linux
- MacOS
- Devices like Raspberry Pi


Muse
------

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 @@ -60,7 +60,8 @@ public enum BoardIds
GALEA_BOARD_V4 (48),
GALEA_SERIAL_BOARD_V4 (49),
NTL_WIFI_BOARD (50),
ANT_NEURO_EE_511_BOARD (51);
ANT_NEURO_EE_511_BOARD (51),
FREEEEG128_BOARD (52);

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 @@ -56,6 +56,7 @@ export BrainFlowInputParams
GALEA_SERIAL_BOARD_V4 = 49
NTL_WIFI_BOARD = 50
ANT_NEURO_EE_511_BOARD = 51
FREEEEG128_BOARD = 52

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 @@ -54,5 +54,6 @@
GALEA_SERIAL_BOARD_V4(49)
NTL_WIFI_BOARD(50)
ANT_NEURO_EE_511_BOARD(51)
FREEEEG128_BOARD(52)
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 @@ -70,6 +70,7 @@ class BoardIds(enum.IntEnum):
GALEA_SERIAL_BOARD_V4 = 49 #:
NTL_WIFI_BOARD = 50 #:
ANT_NEURO_EE_511_BOARD = 51 #:
FREEEEG128_BOARD = 52 #:


class IpProtocolTypes(enum.IntEnum):
Expand Down
3 changes: 2 additions & 1 deletion rust_package/brainflow/src/ffi/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl BoardIds {
pub const FIRST: BoardIds = BoardIds::PlaybackFileBoard;
}
impl BoardIds {
pub const LAST: BoardIds = BoardIds::AntNeuroEe511Board;
pub const LAST: BoardIds = BoardIds::Freeeeg128Board;
}
#[repr(i32)]
#[derive(FromPrimitive, ToPrimitive, Debug, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down Expand Up @@ -90,6 +90,7 @@ pub enum BoardIds {
GaleaSerialBoardV4 = 49,
NtlWifiBoard = 50,
AntNeuroEe511Board = 51,
Freeeeg128Board = 52,
}
#[repr(i32)]
#[derive(FromPrimitive, ToPrimitive, Debug, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down
7 changes: 5 additions & 2 deletions src/board_controller/board_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "emotibit.h"
#include "enophone.h"
#include "explore.h"
#include "freeeeg32.h"
#include "freeeeg.h"
#include "galea.h"
#include "galea_serial.h"
#include "galea_serial_v4.h"
Expand Down Expand Up @@ -152,7 +152,10 @@ int prepare_session (int board_id, const char *json_brainflow_input_params)
board = std::shared_ptr<Board> (new GforcePro (params));
break;
case BoardIds::FREEEEG32_BOARD:
board = std::shared_ptr<Board> (new FreeEEG32 (params));
board = std::shared_ptr<Board> (new FreeEEG ((int)BoardIds::FREEEEG32_BOARD, params));
break;
case BoardIds::FREEEEG128_BOARD:
board = std::shared_ptr<Board> (new FreeEEG ((int)BoardIds::FREEEEG128_BOARD, params));
break;
case BoardIds::BRAINBIT_BLED_BOARD:
board = std::shared_ptr<Board> (new BrainBitBLED (params));
Expand Down
17 changes: 15 additions & 2 deletions src/board_controller/brainflow_boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ BrainFlowBoards::BrainFlowBoards()
{"48", json::object()},
{"49", json::object()},
{"50", json::object()},
{"51", json::object()}
{"51", json::object()},
{"52", json::object()}
}
}};

Expand Down Expand Up @@ -977,6 +978,18 @@ BrainFlowBoards::BrainFlowBoards()
{"emg_channels", {25, 26, 27, 28}},
{"other_channels", {29}}
};
brainflow_boards_json["boards"]["52"]["default"] =
{
{"name", "FreeEEG128"},
{"sampling_rate", 256},
{"timestamp_channel", 129},
{"marker_channel", 130},
{"package_num_channel", 0},
{"num_rows", 131},
{"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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128}},
{"emg_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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128}},
{"ecg_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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128}}
};
}

BrainFlowBoards boards_struct;
BrainFlowBoards boards_struct;
4 changes: 2 additions & 2 deletions src/board_controller/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ SET (BOARD_CONTROLLER_SRC
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/mentalab/explore.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/oymotion/gforce_pro.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/oymotion/gforce_dual.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/freeeeg32/freeeeg32.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/freeeeg/freeeeg.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/neuromd/brainbit_bled.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/muse/muse_bled.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/ant_neuro/ant_neuro.cpp
Expand Down Expand Up @@ -129,7 +129,7 @@ target_include_directories (
${CMAKE_CURRENT_SOURCE_DIR}/third_party/neurosdk/inc/types
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/neurosity/inc
${CMAKE_CURRENT_SOURCE_DIR}/third_party/gForceSDKCXX/src/inc
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/freeeeg32/inc
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/freeeeg/inc
${CMAKE_CURRENT_SOURCE_DIR}/third_party/ant_neuro
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/ant_neuro/inc
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/enophone/inc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,40 @@
#include <vector>

#include "custom_cast.h"
#include "freeeeg32.h"
#include "freeeeg.h"
#include "serial.h"
#include "timestamp.h"


constexpr int FreeEEG32::start_byte;
constexpr int FreeEEG32::end_byte;
constexpr double FreeEEG32::ads_gain;
constexpr double FreeEEG32::ads_vref;
constexpr int FreeEEG::start_byte;
constexpr int FreeEEG::end_byte;
constexpr double FreeEEG::ads_gain;
constexpr double FreeEEG::ads_vref;


FreeEEG32::FreeEEG32 (struct BrainFlowInputParams params)
: Board ((int)BoardIds::FREEEEG32_BOARD, params)
FreeEEG::FreeEEG (int board_id, struct BrainFlowInputParams params) : Board (board_id, params)
{
serial = NULL;
is_streaming = false;
keep_alive = false;
initialized = false;
if (board_id == (int)BoardIds::FREEEEG32_BOARD)
{
min_package_size = 1 + 32 * 3;
}
if (board_id == (int)BoardIds::FREEEEG128_BOARD)
{
min_package_size = 1 + 128 * 3;
}
}

FreeEEG32::~FreeEEG32 ()
FreeEEG::~FreeEEG ()
{
skip_logs = true;
release_session ();
}

int FreeEEG32::prepare_session ()
int FreeEEG::prepare_session ()
{
if (initialized)
{
Expand Down Expand Up @@ -62,7 +69,7 @@ int FreeEEG32::prepare_session ()
return (int)BrainFlowExitCodes::STATUS_OK;
}

int FreeEEG32::start_stream (int buffer_size, const char *streamer_params)
int FreeEEG::start_stream (int buffer_size, const char *streamer_params)
{
if (is_streaming)
{
Expand All @@ -83,7 +90,7 @@ int FreeEEG32::start_stream (int buffer_size, const char *streamer_params)
return (int)BrainFlowExitCodes::STATUS_OK;
}

int FreeEEG32::stop_stream ()
int FreeEEG::stop_stream ()
{
if (is_streaming)
{
Expand All @@ -101,7 +108,7 @@ int FreeEEG32::stop_stream ()
}
}

int FreeEEG32::release_session ()
int FreeEEG::release_session ()
{
if (initialized)
{
Expand All @@ -121,16 +128,12 @@ int FreeEEG32::release_session ()
return (int)BrainFlowExitCodes::STATUS_OK;
}

void FreeEEG32::read_thread ()
void FreeEEG::read_thread ()
{
int res;
constexpr int max_size = 200; // random value bigger than package size which is unknown
constexpr int max_size = 1000; // random value bigger than package size which is unknown
unsigned char b[max_size] = {0};
// dont know exact package size and it can be changed with new firmware versions, its >=
// min_package_size and we can check start\stop bytes
constexpr int min_package_size = 1 + 32 * 3;
float eeg_scale =
FreeEEG32::ads_vref / float ((pow (2, 23) - 1)) / FreeEEG32::ads_gain * 1000000.;
float eeg_scale = FreeEEG::ads_vref / float ((pow (2, 23) - 1)) / FreeEEG::ads_gain * 1000000.;
int num_rows = board_descr["default"]["num_rows"];
double *package = new double[num_rows];
for (int i = 0; i < num_rows; i++)
Expand All @@ -149,7 +152,7 @@ void FreeEEG32::read_thread ()
{
res = serial->read_from_serial_port (b + pos, 1);
int prev_id = (pos <= 0) ? 0 : pos - 1;
if ((b[pos] == FreeEEG32::start_byte) && (b[prev_id] == FreeEEG32::end_byte) &&
if ((b[pos] == FreeEEG::start_byte) && (b[prev_id] == FreeEEG::end_byte) &&
(pos >= min_package_size))
{
complete_package = true;
Expand Down Expand Up @@ -182,7 +185,7 @@ void FreeEEG32::read_thread ()
delete[] package;
}

int FreeEEG32::open_port ()
int FreeEEG::open_port ()
{
if (serial->is_port_open ())
{
Expand All @@ -200,7 +203,7 @@ int FreeEEG32::open_port ()
return (int)BrainFlowExitCodes::STATUS_OK;
}

int FreeEEG32::set_port_settings ()
int FreeEEG::set_port_settings ()
{
int res = serial->set_serial_port_settings (1000, false);
if (res < 0)
Expand All @@ -225,8 +228,8 @@ int FreeEEG32::set_port_settings ()
return (int)BrainFlowExitCodes::STATUS_OK;
}

int FreeEEG32::config_board (std::string config, std::string &response)
int FreeEEG::config_board (std::string config, std::string &response)
{
safe_logger (spdlog::level::err, "FreeEEG32 doesn't support board configuration.");
safe_logger (spdlog::level::err, "FreeEEG doesn't support board configuration.");
return (int)BrainFlowExitCodes::UNSUPPORTED_BOARD_ERROR;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "serial.h"


class FreeEEG32 : public Board
class FreeEEG : public Board
{

protected:
Expand All @@ -16,14 +16,17 @@ class FreeEEG32 : public Board
bool is_streaming;
std::thread streaming_thread;
Serial *serial;
// dont know exact package size and it can be changed with new firmware versions, its >=
// min_package_size and we can check start\stop bytes, and it depends on exact board
int min_package_size;

int open_port ();
int set_port_settings ();
void read_thread ();

public:
FreeEEG32 (struct BrainFlowInputParams params);
~FreeEEG32 ();
FreeEEG (int board_id, struct BrainFlowInputParams params);
~FreeEEG ();

int prepare_session ();
int start_stream (int buffer_size, const char *streamer_params);
Expand Down
5 changes: 3 additions & 2 deletions src/utils/inc/brainflow_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ enum class BoardIds : int
GALEA_SERIAL_BOARD_V4 = 49,
NTL_WIFI_BOARD = 50,
ANT_NEURO_EE_511_BOARD = 51,
FREEEEG128_BOARD = 52,
// use it to iterate
FIRST = PLAYBACK_FILE_BOARD,
LAST = ANT_NEURO_EE_511_BOARD
LAST = FREEEEG128_BOARD
};

enum class IpProtocolTypes : int
Expand Down Expand Up @@ -240,4 +241,4 @@ enum class WaveletTypes : int
// to iterate and check sizes
FIRST_WAVELET = HAAR,
LAST_WAVELET = SYM10
};
};
Loading