explorepy

Main API

Bluetooth API

A module for bluetooth connection

class bt_client.BtClient(device_name=None, mac_address=None)[source]

Bases: object

Responsible for Connecting and reconnecting explore devices via bluetooth

Initialize Bluetooth connection

Parameters:
  • device_name (str) – Name of the device (either device_name or device address should be given)
  • mac_address (str) – Devices MAC address
connect()[source]

Connect to the device and return the socket

Returns:socket (bluetooth.socket)
reconnect()[source]

Reconnect to the last used bluetooth socket.

This function reconnects to the the last bluetooth socket. If after 1 minute the connection doesn’t succeed, program will end.

disconnect()[source]

Disconnect from the device

_find_mac_address()[source]
_find_service()[source]
read(n_bytes)[source]

Read n_bytes from the socket

Parameters:n_bytes (int) – number of bytes to be read
Returns:list of bytes
send(data)[source]

Send data to the device

Parameters:data (bytearray) – Data to be sent
static _check_mac_address(device_name, mac_address)[source]

Parser

This module contains all packet classes of Mentalab Explore device

class packet.PACKET_ID[source]

Bases: enum.IntEnum

Packet ID enum

ORN = 13
ENV = 19
TS = 27
DISCONNECT = 111
INFO = 99
EEG94 = 144
EEG98 = 146
EEG99S = 30
EEG99 = 62
EEG94R = 208
EEG98R = 210
CMDRCV = 192
CMDSTAT = 193
MARKER = 194
CALIBINFO = 195
class packet.Packet(timestamp, payload)[source]

Bases: object

An abstract base class for Explore packet

Gets the timestamp and payload and initializes the packet object

Parameters:payload (bytearray) – a byte array including binary data and fletcher
_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

__str__()[source]

Print the data/info

static int24to32(bin_data)[source]

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.EEG(timestamp, payload)[source]

Bases: packet.Packet

EEG packet class

Gets the timestamp and payload and initializes the packet object

Parameters:payload (bytearray) – a byte array including binary data and fletcher
calculate_impedance(imp_calib_info)[source]

calculate impedance with the help of impedance calibration info

Parameters:imp_calib_info (dict) – dictionary of impedance calibration info including slope, offset and noise level
get_data(exg_fs=None)[source]

get time vector and data

If exg_fs is given, it returns time vector and data. If exg_fs is not given, it returns the timestamp of the packet alongside with the data

get_impedances()[source]

get electrode impedances

get_ptp()[source]

Get peak to peak value

__str__()

Print the data/info

_check_fletcher(fletcher)

Checks if the fletcher is valid

_convert(bin_data)

Read the binary data and convert it to real values

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.EEG94(timestamp, payload)[source]

Bases: packet.EEG

EEG packet for 4 channel device

_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

calculate_impedance(imp_calib_info)

calculate impedance with the help of impedance calibration info

Parameters:imp_calib_info (dict) – dictionary of impedance calibration info including slope, offset and noise level
get_data(exg_fs=None)

get time vector and data

If exg_fs is given, it returns time vector and data. If exg_fs is not given, it returns the timestamp of the packet alongside with the data

get_impedances()

get electrode impedances

get_ptp()

Get peak to peak value

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.EEG98(timestamp, payload)[source]

Bases: packet.EEG

EEG packet for 8 channel device

_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

calculate_impedance(imp_calib_info)

calculate impedance with the help of impedance calibration info

Parameters:imp_calib_info (dict) – dictionary of impedance calibration info including slope, offset and noise level
get_data(exg_fs=None)

get time vector and data

If exg_fs is given, it returns time vector and data. If exg_fs is not given, it returns the timestamp of the packet alongside with the data

get_impedances()

get electrode impedances

get_ptp()

Get peak to peak value

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.EEG99s(timestamp, payload)[source]

Bases: packet.EEG

EEG packet for 8 channel device

_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

calculate_impedance(imp_calib_info)

calculate impedance with the help of impedance calibration info

Parameters:imp_calib_info (dict) – dictionary of impedance calibration info including slope, offset and noise level
get_data(exg_fs=None)

get time vector and data

If exg_fs is given, it returns time vector and data. If exg_fs is not given, it returns the timestamp of the packet alongside with the data

get_impedances()

get electrode impedances

get_ptp()

Get peak to peak value

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.EEG99(timestamp, payload)[source]

Bases: packet.EEG

EEG packet for 8 channel device

_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

calculate_impedance(imp_calib_info)

calculate impedance with the help of impedance calibration info

Parameters:imp_calib_info (dict) – dictionary of impedance calibration info including slope, offset and noise level
get_data(exg_fs=None)

get time vector and data

If exg_fs is given, it returns time vector and data. If exg_fs is not given, it returns the timestamp of the packet alongside with the data

get_impedances()

get electrode impedances

get_ptp()

Get peak to peak value

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.Orientation(timestamp, payload)[source]

Bases: packet.Packet

Orientation data packet

_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

get_data(srate=None)[source]

Get orientation timestamp and data

compute_angle(matrix=None)[source]

Compute physical angle

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.Environment(timestamp, payload)[source]

Bases: packet.Packet

Environment data packet

_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

get_data()[source]

Get environment data

static _volt_to_percent(voltage)[source]
static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.TimeStamp(timestamp, payload)[source]

Bases: packet.Packet

Time stamp data packet

_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.EventMarker(timestamp, payload)[source]

Bases: packet.Packet

Marker packet

_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

get_data(srate=None)[source]

Get marker data :Parameters: srate – NOT USED. Only for compatibility purpose

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.Disconnect(timestamp, payload)[source]

Bases: packet.Packet

Disconnect packet

_convert(bin_data)[source]

Disconnect packet has no data

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.DeviceInfo(timestamp, payload)[source]

Bases: packet.Packet

Device information packet

_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

get_info()[source]

Get device information as a dictionary

get_data()[source]

Get firmware version

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.CommandRCV(timestamp, payload)[source]

Bases: packet.Packet

Command Status packet

_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.CommandStatus(timestamp, payload)[source]

Bases: packet.Packet

Command Status packet

_convert(bin_data)[source]

Read the binary data and convert it to real values

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values
class packet.CalibrationInfo(timestamp, payload)[source]

Bases: packet.Packet

Calibration Info packet

_convert(bin_data)[source]

Read the binary data and convert it to real values

get_info()[source]

Get calibration info

_check_fletcher(fletcher)[source]

Checks if the fletcher is valid

static int24to32(bin_data)

Converts binary data to int32

Parameters:bin_data (list) – list of bytes with the structure of int24
Returns:np.ndarray of int values

Dashboard

Additional tools