explorepy¶
Main API¶
Bluetooth API¶
Parser¶
This module contains all packet classes of 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
-
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
-
__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
-
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
-
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
-
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
-
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
-
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
-
static
-
class
packet.
Environment
(timestamp, payload)[source]¶ Bases:
packet.Packet
Environment data packet
-
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
-
static
-
class
packet.
TimeStamp
(timestamp, payload)[source]¶ Bases:
packet.Packet
Time stamp data packet
-
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
-
static
-
class
packet.
EventMarker
(timestamp, payload)[source]¶ Bases:
packet.Packet
Marker packet
-
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
-
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
-
static
-
class
packet.
DeviceInfo
(timestamp, payload)[source]¶ Bases:
packet.Packet
Device information packet
-
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
-
static
-
class
packet.
CommandRCV
(timestamp, payload)[source]¶ Bases:
packet.Packet
Command Status packet
-
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
-
static
-
class
packet.
CommandStatus
(timestamp, payload)[source]¶ Bases:
packet.Packet
Command Status packet
-
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
-
static
-
class
packet.
CalibrationInfo
(timestamp, payload)[source]¶ Bases:
packet.Packet
Calibration Info packet
-
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
-
static
Dashboard¶
Additional tools¶
Some useful tools such as file recorder, heart rate estimation, etc. used in explorepy
-
tools.
bt_scan
()[source]¶ “Scan for bluetooth devices Scans for available explore devices. Prints out MAC address and name of each found device
Args:
Returns:
-
class
tools.
HeartRateEstimator
(fs=250, smoothing_win=20)[source]¶ Bases:
object
Real-time heart Rate Estimator class This class provides the tools for heart rate estimation. It basically detects R-peaks in ECG signal using the method explained in Hamilton 2002 [2].
Parameters: - fs (int) – Sampling frequency
- smoothing_win (int) – Length of smoothing window
References
[1] Hamilton, P. S. (2002). Open source ECG analysis software documentation. Computers in cardiology, 2002.
[2] Hamilton, P. S., & Tompkins, W. J. (1986). Quantitative investigation of QRS detection rules using the MIT/BIH arrhythmia database. IEEE transactions on biomedical engineering.
-
average_noise_peak
¶
-
average_qrs_peak
¶
-
decision_threshold
¶
-
average_rr_interval
¶
-
heart_rate
¶
-
class
tools.
FileRecorder
(filename, ch_label, fs, ch_unit, ch_min=None, ch_max=None, device_name='Explore', file_type='edf', do_overwrite=False)[source]¶ Bases:
object
Explorepy file recorder class.
This class can write ExG, orientation and environment data into (separated) EDF+ files. It can write data while streaming from Explore device. The incoming data will be stored in a buffer and after it reached fs samples, it writes the buffer in EDF file.
Attributes:
Parameters: - filename (str) – File name
- ch_label (list) – List of channel labels.
- fs (int) – Sampling rate (must be identical for all channels)
- ch_unit (list) – List of channels unit (e.g. ‘uV’, ‘mG’, ‘s’, etc.)
- ch_min (list) – List of minimum value of each channel. Only needed in edf mode (can be None in csv mode)
- ch_max (list) – List of maximum value of each channel. Only needed in edf mode (can be None in csv mode)
- device_name (str) – Recording device name
- file_type (str) – File type. current options: ‘edf’ and ‘csv’.
- do_overwrite (bool) – Overwrite file if a file with the same name exists already.
-
fs
¶ Sampling frequency
-
write_data
(packet)[source]¶ writes data to the file
Notes
If file type is set to EDF, this function writes each 1 seconds of data. If the input is less than 1 second, it will be buffered in the memory and it will be written in the file when enough data is in the buffer.
Parameters: packet (explorepy.packet.Packet) – ExG or Orientation packet
-
class
tools.
LslServer
(device_info)[source]¶ Bases:
object
Class for LabStreamingLayer integration
-
push_exg
(packet)[source]¶ Push data to ExG outlet
Parameters: packet (explorepy.packet.EEG) – ExG packet
-
-
class
tools.
ImpedanceMeasurement
(device_info, calib_param, notch_freq)[source]¶ Bases:
object
Impedance measurement class
Parameters: - device_info (dict) – Device information dictionary
- calib_param (dict) – Calibration parameters dictionary
- notch_freq (int) – Line frequency (for notch filter)