Skip to content

Commit

Permalink
add support for mentalab devices (#542)
Browse files Browse the repository at this point in the history
* initial commit for mentalab devices

Signed-off-by: Andrey Parfenov <[email protected]>
  • Loading branch information
Andrey1994 authored Sep 19, 2022
1 parent 0914f98 commit 491f0ce
Show file tree
Hide file tree
Showing 24 changed files with 904 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ public enum BoardIds
BRAINALIVE_BOARD = 40,
MUSE_2016_BOARD = 41,
MUSE_2016_BLED_BOARD = 42,
PIEEG_BOARD = 43
PIEEG_BOARD = 43,
EXPLORE_4_CHAN_BOARD = 44,
EXPLORE_8_CHAN_BOARD = 45
};


Expand Down
110 changes: 110 additions & 0 deletions docs/SupportedBoards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Supported platforms:
- Windows >= 8.1
- Linux
- MacOS
- Devices like Raspberry Pi

By default it generates new timestamps and stops at the end of the file. You can override it using commands:

Expand Down Expand Up @@ -79,6 +80,8 @@ Supported platforms:
- Windows >= 8.1
- Linux
- MacOS
- Devices like Raspberry Pi
- Android

In methods like:

Expand Down Expand Up @@ -110,6 +113,7 @@ Supported platforms:
- Windows >= 8.1
- Linux
- MacOS
- Devices like Raspberry Pi
- Android

OpenBCI
Expand Down Expand Up @@ -144,6 +148,7 @@ Supported platforms:
- Windows >= 8.1
- Linux
- MacOS
- Devices like Raspberry Pi

**On MacOS there are two serial ports for each device: /dev/tty..... and /dev/cu..... You HAVE to specify /dev/cu.....**

Expand Down Expand Up @@ -179,6 +184,7 @@ Supported platforms:
- Windows >= 8.1
- Linux
- MacOS
- Devices like Raspberry Pi

**On MacOS there are two serial ports for each device: /dev/tty..... and /dev/cu..... You HAVE to specify /dev/cu.....**

Expand All @@ -201,6 +207,7 @@ Supported platforms:
- Windows >= 8.1
- Linux
- MacOS
- Devices like Raspberry Pi

**On MacOS there are two serial ports for each device: /dev/tty..... and /dev/cu..... You HAVE to specify /dev/cu.....**

Expand Down Expand Up @@ -254,6 +261,7 @@ Supported platforms:
- Windows >= 8.1
- Linux
- MacOS
- Devices like Raspberry Pi
- Android

CytonDaisy with WIFI Shield
Expand All @@ -279,6 +287,7 @@ Supported platforms:
- Windows >= 8.1
- Linux
- MacOS
- Devices like Raspberry Pi
- Android

NeuroMD
Expand Down Expand Up @@ -430,6 +439,7 @@ Supported platforms:
- Windows
- Linux
- MacOS
- Devices like Raspberry Pi

*Note: On Windows you may need to disable firewall to allow broadcast messages.*

Expand All @@ -455,6 +465,7 @@ Supported platforms:
- Windows
- Linux
- MacOS
- Devices like Raspberry Pi

*Note: On Windows you may need to disable firewall to allow broadcast messages.*

Expand All @@ -479,6 +490,7 @@ Supported platforms:
- Windows
- Linux
- MacOS
- Devices like Raspberry Pi

*Note: On Windows you may need to disable firewall to allow broadcast messages.*

Expand Down Expand Up @@ -554,6 +566,7 @@ Supported platforms:
- Windows
- Linux
- MacOS
- Devices like Raspberry Pi

Muse
------
Expand Down Expand Up @@ -822,6 +835,10 @@ Supported platforms:
- Windows
- Linux

Available commands:

- Set sampling rate: :code:`board.config_board("sampling_rate:500")`, for available values check docs from Ant Neuro.

For more information about Ant Neuro boards please refer to their User Manual.


Expand Down Expand Up @@ -852,6 +869,7 @@ Supported platforms:
- Windows
- Linux
- MacOS
- Devices like Raspberry Pi

Steps to find MAC address:

Expand Down Expand Up @@ -898,3 +916,95 @@ Supported platforms:
- MacOS 10.15+
- Linux, compilation from source code probably will be needed
- Devices like Raspberry Pi


Mentalab
---------

.. csv-table:: Required inputs
:header: "Board", "Board Id", "serial_port", "mac_address", "ip_address", "ip_port", "ip_protocol", "other_info", "timeout", "serial_number", "file", "preset", "master_board"

"Explore4Channels", "BoardIds.EXPLORE_4_CHAN_BOARD (44)", "-", "Optional: MAC adress", "-", "-", "-", "-", "-", "-", "-", "-", "-"
"Explore8Channels", "BoardIds.EXPLORE_8_CHAN_BOARD (45)", "-", "Optional: MAC adress", "-", "-", "-", "-", "-", "-", "-", "-", "-"

Explore 4 Channels Board
~~~~~~~~~~~~~~~~~~~~~~~~~

.. image:: https://live.staticflickr.com/65535/52349031632_51bc8ea56c.jpg"
:width: 500px
:height: 334px

`Mentalab website <https://mentalab.com/>`_

To choose this board in BoardShim constructor please specify:

- board_id: 44
- Optional: mac address field of BrainFlowInputParams structure

Supported platforms:

- Windows
- Linux
- MacOS
- Devices like Raspberry Pi

**On Linux in order to compile and use it you may need to install :code:`libbluetooth-dev` for Debian like systems and :code:`bluez-libs-devel` for Fedora like.**

Available :ref:`presets-label`:

- *BrainFlowPresets.DEFAULT_PRESET* contains EEG data
- *BrainFlowPresets.AUXILIARY_PRESET* contains Gyro and Accel data
- *BrainFlowPresets.ANCILLARY_PRESET* contains battery and temperature data

Steps to find MAC address:

- On Windows: open device manager, navigate to explore device, click properties and select Bluetooth Address
- On Linux: install bluez-utils and run :code:`bluetoothctl paired-devices`
- On MacOS: run :code:`system_profiler SPBluetoothDataType`

Steps to connect:

- Enable device and Pair it with your laptop using bluetooth settings
- Ensure that blue LED is blinking before calling :code:`board.prepare_session()`
- If you see green LED probably you need to reboot a devce

Explore 8 Channels Board
~~~~~~~~~~~~~~~~~~~~~~~~~

.. image:: https://live.staticflickr.com/65535/52349031632_51bc8ea56c.jpg"
:width: 500px
:height: 334px

`Mentalab website <https://mentalab.com/>`_

To choose this board in BoardShim constructor please specify:

- board_id: 44
- Optional: mac address field of BrainFlowInputParams structure

Supported platforms:

- Windows
- Linux
- MacOS
- Devices like Raspberry Pi

**On Linux in order to compile and use it you may need to install :code:`libbluetooth-dev` for Debian like systems and :code:`bluez-libs-devel` for Fedora like.**

Available :ref:`presets-label`:

- *BrainFlowPresets.DEFAULT_PRESET* contains EEG data
- *BrainFlowPresets.AUXILIARY_PRESET* contains Gyro and Accel data
- *BrainFlowPresets.ANCILLARY_PRESET* contains battery and temperature data

Steps to find MAC address:

- On Windows: open device manager, navigate to explore device, click properties and select Bluetooth Address
- On Linux: install bluez-utils and run :code:`bluetoothctl paired-devices`
- On MacOS: run :code:`system_profiler SPBluetoothDataType`

Steps to connect:

- Enable device and Pair it with your laptop using bluetooth settings
- Ensure that blue LED is blinking before calling :code:`board.prepare_session()`
- If you see green LED probably you need to reboot a devce
4 changes: 3 additions & 1 deletion java_package/brainflow/src/main/java/brainflow/BoardIds.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public enum BoardIds
BRAINALIVE_BOARD (40),
MUSE_2016_BOARD (41),
MUSE_2016_BLED_BOARD (42),
PIEEG_BOARD (43);
PIEEG_BOARD (43),
EXPLORE_4_CHAN_BOARD (44),
EXPLORE_8_CHAN_BOARD (45);

private final int board_id;
private static final Map<Integer, BoardIds> bi_map = new HashMap<Integer, BoardIds> ();
Expand Down
2 changes: 2 additions & 0 deletions julia_package/brainflow/src/board_shim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export BrainFlowInputParams
MUSE_2016_BOARD = 41
MUSE_2016_BLED_BOARD = 42
PIEEG_BOARD = 43
EXPLORE_4_CHAN_BOARD = 44
EXPLORE_8_CHAN_BOARD = 45

end

Expand Down
2 changes: 2 additions & 0 deletions matlab_package/brainflow/BoardIds.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@
MUSE_2016_BOARD (41)
MUSE_2016_BLED_BOARD (42)
PIEEG_BOARD (43)
EXPLORE_4_CHAN_BOARD (44)
EXPLORE_8_CHAN_BOARD (45)
end
end
2 changes: 2 additions & 0 deletions python_package/brainflow/board_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class BoardIds(enum.IntEnum):
MUSE_2016_BOARD = 41 #:
MUSE_2016_BLED_BOARD = 42 #:
PIEEG_BOARD = 43 #:
EXPLORE_4_CHAN_BOARD = 44 #:
EXPLORE_8_CHAN_BOARD = 45 #:


class IpProtocolTypes(enum.IntEnum):
Expand Down
38 changes: 38 additions & 0 deletions python_package/examples/tests/explore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import argparse
import time

from brainflow.board_shim import BoardShim, BrainFlowInputParams, BrainFlowPresets, BoardIds
from brainflow.data_filter import DataFilter


def main():
BoardShim.enable_dev_board_logger()
parser = argparse.ArgumentParser()
parser.add_argument('--mac-address', type=str, help='mac address', required=False, default='')
args = parser.parse_args()

params = BrainFlowInputParams()
params.mac_address = args.mac_address
board = BoardShim(BoardIds.EXPLORE_4_CHAN_BOARD, params)
board.prepare_session()
board.start_stream()
# important: for explore device config board has to be after start stream
# board.config_board('sampling_rate:500')
# board.config_board('test_signal:1') # 1 is a bitmask represented as int not channel num
time.sleep(20)
data_eeg = board.get_board_data(preset=BrainFlowPresets.DEFAULT_PRESET)
data_orn = board.get_board_data(preset=BrainFlowPresets.AUXILIARY_PRESET)
data_env = board.get_board_data(preset=BrainFlowPresets.ANCILLARY_PRESET)
board.stop_stream()
board.release_session()

print(data_eeg)
print(data_orn)
print(data_env)
DataFilter.write_file(data_eeg, 'data_eeg.csv', 'w')
DataFilter.write_file(data_orn, 'data_orn.csv', 'w')
DataFilter.write_file(data_env, 'data_env.csv', 'w')


if __name__ == "__main__":
main()
4 changes: 3 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::PieegBoard;
pub const LAST: BoardIds = BoardIds::Explore8ChanBoard;
}
#[repr(i32)]
#[derive(FromPrimitive, ToPrimitive, Debug, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down Expand Up @@ -84,6 +84,8 @@ pub enum BoardIds {
Muse2016Board = 41,
Muse2016BledBoard = 42,
PieegBoard = 43,
Explore4ChanBoard = 44,
Explore8ChanBoard = 45,
}
#[repr(i32)]
#[derive(FromPrimitive, ToPrimitive, Debug, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down
7 changes: 7 additions & 0 deletions src/board_controller/board_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "cyton_daisy_wifi.h"
#include "cyton_wifi.h"
#include "enophone.h"
#include "explore.h"
#include "freeeeg32.h"
#include "galea.h"
#include "galea_serial.h"
Expand Down Expand Up @@ -241,6 +242,12 @@ int prepare_session (int board_id, const char *json_brainflow_input_params)
case BoardIds::PIEEG_BOARD:
board = std::shared_ptr<Board> (new PiEEG (params));
break;
case BoardIds::EXPLORE_4_CHAN_BOARD:
board = std::shared_ptr<Board> (new Explore (board_id, params));
break;
case BoardIds::EXPLORE_8_CHAN_BOARD:
board = std::shared_ptr<Board> (new Explore (board_id, params));
break;
default:
return (int)BrainFlowExitCodes::UNSUPPORTED_BOARD_ERROR;
}
Expand Down
Loading

0 comments on commit 491f0ce

Please sign in to comment.