User API¶
BrainFlow User API has three main modules:
BoardShim to read data from a board, it calls methods from underlying BoardController library
DataFilter to perform signal processing, it calls methods from underlying DataHandler library
MLModel to calculate derivative metrics, it calls methods from underlying MLModule library
These classes are independent, so if you want, you can use BrainFlow API only for data streaming and perform signal processing by yourself and vice versa.
BrainFlow data acqusition API is board agnostic, so to select a specific board you need to pass BrainFlow’s board id to BoardShim’s constructor and an instance of BrainFlowInputParams structure which should hold information for your specific board, check Supported Boards. for details. This abstraction allows you to switch boards without any changes in code.
In BoardShim, all board data is returned as a 2d array. Rows in this array may contain timestamps, EEG and EMG data and so on. To see instructions how to query specific kind of data check Data Format Description and Code Samples.
Python API Reference¶
brainflow.board_shim¶
-
class
brainflow.board_shim.
BoardIds
(value) Bases:
enum.IntEnum
Enum to store all supported Board Ids
-
PLAYBACK_FILE_BOARD
= -3
-
STREAMING_BOARD
= -2
-
SYNTHETIC_BOARD
= -1
-
CYTON_BOARD
= 0
-
GANGLION_BOARD
= 1
-
CYTON_DAISY_BOARD
= 2
-
GALEA_BOARD
= 3
-
GANGLION_WIFI_BOARD
= 4
-
CYTON_WIFI_BOARD
= 5
-
CYTON_DAISY_WIFI_BOARD
= 6
-
BRAINBIT_BOARD
= 7
-
UNICORN_BOARD
= 8
-
CALLIBRI_EEG_BOARD
= 9
-
CALLIBRI_EMG_BOARD
= 10
-
CALLIBRI_ECG_BOARD
= 11
-
NOTION_1_BOARD
= 13
-
NOTION_2_BOARD
= 14
-
GFORCE_PRO_BOARD
= 16
-
FREEEEG32_BOARD
= 17
-
BRAINBIT_BLED_BOARD
= 18
-
GFORCE_DUAL_BOARD
= 19
-
GALEA_SERIAL_BOARD
= 20
-
MUSE_S_BLED_BOARD
= 21
-
MUSE_2_BLED_BOARD
= 22
-
CROWN_BOARD
= 23
-
ANT_NEURO_EE_410_BOARD
= 24
-
ANT_NEURO_EE_411_BOARD
= 25
-
ANT_NEURO_EE_430_BOARD
= 26
-
ANT_NEURO_EE_211_BOARD
= 27
-
ANT_NEURO_EE_212_BOARD
= 28
-
ANT_NEURO_EE_213_BOARD
= 29
-
ANT_NEURO_EE_214_BOARD
= 30
-
ANT_NEURO_EE_215_BOARD
= 31
-
ANT_NEURO_EE_221_BOARD
= 32
-
ANT_NEURO_EE_222_BOARD
= 33
-
ANT_NEURO_EE_223_BOARD
= 34
-
ANT_NEURO_EE_224_BOARD
= 35
-
ANT_NEURO_EE_225_BOARD
= 36
-
ENOPHONE_BOARD
= 37
-
MUSE_2_BOARD
= 38
-
MUSE_S_BOARD
= 39
-
MUSE_2016_BOARD
= 41
-
MUSE_2016_BLED_BOARD
= 42
-
EXPLORE_4_CHAN_BOARD
= 44
-
EXPLORE_8_CHAN_BOARD
= 45
-
GANGLION_NATIVE_BOARD
= 46
-
EMOTIBIT_BOARD
= 47
-
-
class
brainflow.board_shim.
IpProtocolTypes
(value) Bases:
enum.IntEnum
Enum to store Ip Protocol types
-
NO_IP_PROTOCOL
= 0
-
UDP
= 1
-
TCP
= 2
-
-
class
brainflow.board_shim.
BrainFlowPresets
(value) Bases:
enum.IntEnum
Enum to store presets
-
DEFAULT_PRESET
= 0
-
AUXILIARY_PRESET
= 1
-
ANCILLARY_PRESET
= 2
-
-
class
brainflow.board_shim.
BrainFlowInputParams
Bases:
object
inputs parameters for prepare_session method
- Parameters
serial_port (str) – serial port name is used for boards which reads data from serial port
mac_address (str) – mac address for example its used for bluetooth based boards
ip_address (str) – ip address is used for boards which reads data from socket connection
ip_address_aux (str) – ip address is used for boards which reads data from socket connection
ip_address_anc (str) – ip address is used for boards which reads data from socket connection
ip_port (int) – ip port for socket connection, for some boards where we know it in front you dont need this parameter
ip_port_aux (int) – ip port for socket connection, for some boards where we know it in front you dont need this parameter
ip_port_anc (int) – ip port for socket connection, for some boards where we know it in front you dont need this parameter
ip_protocol (int) – ip protocol type from IpProtocolTypes enum
other_info (str) – other info
serial_number (str) – serial number
file (str) – file
file_aux (str) – file
file_anc (str) – file
-
class
brainflow.board_shim.
BoardShim
(board_id: int, input_params: brainflow.board_shim.BrainFlowInputParams) Bases:
object
BoardShim class is a primary interface to all boards
- Parameters
board_id (int) – Id of your board
input_params (BrainFlowInputParams) – board specific structure to pass required arguments
-
classmethod
set_log_level
(log_level: int) → None set BrainFlow log level, use it only if you want to write your own messages to BrainFlow logger, otherwise use enable_board_logger, enable_dev_board_logger or disable_board_logger
- Parameters
log_level (int) – log level, to specify it you should use values from LogLevels enum
-
classmethod
enable_board_logger
() → None enable BrainFlow Logger with level INFO, uses stderr for log messages by default
-
classmethod
disable_board_logger
() → None disable BrainFlow Logger
-
classmethod
enable_dev_board_logger
() → None enable BrainFlow Logger with level TRACE, uses stderr for log messages by default
-
classmethod
log_message
(log_level: int, message: str) → None write your own log message to BrainFlow logger, use it if you wanna have single logger for your own code and BrainFlow’s code
- Parameters
log_level – log level
message (str) – message
-
classmethod
set_log_file
(log_file: str) → None redirect logger from stderr to file, can be called any time
- Parameters
log_file (str) – log file name
-
classmethod
get_sampling_rate
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → int get sampling rate for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
sampling rate for this board id
- Return type
int
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_package_num_channel
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → int get package num channel for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
number of package num channel
- Return type
int
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_battery_channel
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → int get battery channel for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
number of batter channel
- Return type
int
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_num_rows
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → int get number of rows in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
number of rows in returned numpy array
- Return type
int
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_timestamp_channel
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → int get timestamp channel in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
number of timestamp channel in returned numpy array
- Return type
int
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_marker_channel
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → int get marker channel in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
number of marker channel in returned numpy array
- Return type
int
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_eeg_names
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[str] get names of EEG channels in 10-20 system if their location is fixed
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
EEG channels names
- Return type
List[str]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_board_presets
(board_id: int) → List[str] get available presets for this board id
- Parameters
board_id (int) – Board Id
- Returns
presets for this board id
- Return type
List[str]
:raises BrainFlowError
-
classmethod
get_version
() → str get version of brainflow libraries
- Returns
version
- Return type
str
:raises BrainFlowError
-
classmethod
get_board_descr
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) get board description as json
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
info about board
- Return type
json
- Raises
BrainFlowError – If there is no such board id exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_device_name
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → str get device name
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
Device Name
- Return type
str
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_eeg_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of eeg channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of eeg channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_exg_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of exg channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of eeg channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_emg_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of emg channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of eeg channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_ecg_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of ecg channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of ecg channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_eog_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of eog channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of eog channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_eda_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of eda channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of eda channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_ppg_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of ppg channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of ppg channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_accel_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of accel channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of accel channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_analog_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of analog channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of analog channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_gyro_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of gyro channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of gyro channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_other_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of other channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of other channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_temperature_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of temperature channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of temperature channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_resistance_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of resistance channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of resistance channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
get_magnetometer_channels
(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int] get list of magnetometer channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of magnetometer channels in returned numpy array
- Return type
List[int]
- Raises
BrainFlowError – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
classmethod
release_all_sessions
() → None release all prepared sessions
-
prepare_session
() → None prepare streaming sesssion, init resources, you need to call it before any other BoardShim object methods
-
add_streamer
(streamer_params: str, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → None Add streamer
- Parameters
preset (int) – preset
parameter to stream data from brainflow, supported vals (streamer_params) – “file://%file_name%:w”, “file://%file_name%:a”, “streaming_board://%multicast_group_ip%:%port%”. Range for multicast addresses is from “224.0.0.0” to “239.255.255.255”
-
delete_streamer
(streamer_params: str, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → None Delete streamer
- Parameters
preset (int) – preset
parameter to stream data from brainflow, supported vals (streamer_params) – “file://%file_name%:w”, “file://%file_name%:a”, “streaming_board://%multicast_group_ip%:%port%”. Range for multicast addresses is from “224.0.0.0” to “239.255.255.255”
-
start_stream
(num_samples: int = 450000, streamer_params: str = None) → None Start streaming data, this methods stores data in ringbuffer
- Parameters
num_samples (int) – size of ring buffer to keep data
parameter to stream data from brainflow, supported vals (streamer_params) – “file://%file_name%:w”, “file://%file_name%:a”, “streaming_board://%multicast_group_ip%:%port%”. Range for multicast addresses is from “224.0.0.0” to “239.255.255.255”
-
stop_stream
() → None Stop streaming data
-
release_session
() → None release all resources
-
get_current_board_data
() Get specified amount of data or less if there is not enough data, doesnt remove data from ringbuffer
- Parameters
num_samples (int) – max number of samples
preset (int) – preset
- Returns
latest data from a board
- Return type
NDArray[Float64]
-
get_board_data_count
(preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → int Get num of elements in ringbuffer
- Parameters
preset (int) – preset
- Returns
number of elements in ring buffer
- Return type
int
-
get_board_id
() → int Get’s the actual board id, can be different than provided
- Returns
board id
- Return type
int
-
insert_marker
(value: float, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → None Insert Marker to Data Stream
- Parameters
value (float) – value to insert
preset (int) – preset
- Returns
board id
- Return type
int
-
is_prepared
() → bool Check if session is ready or not
- Returns
session status
- Return type
bool
-
get_board_data
() Get board data and remove data from ringbuffer
- Parameters
num_samples (int) – number of packages to get
preset (int) – preset
- Returns
all data from a board if num_samples is None, num_samples packages or less if not None
- Return type
NDArray[Float64]
-
config_board
(config) → None Use this method carefully and only if you understand what you are doing, do NOT use it to start or stop streaming
- Parameters
config (str) – string to send to a board
- Returns
response string if any
- Return type
str
brainflow.exit_codes¶
-
exception
brainflow.exit_codes.
BrainFlowError
(message: str, exit_code: int) Bases:
Exception
This exception is raised if non-zero exit code is returned from C code
- Parameters
message (str) – exception message
exit_code (int) – exit code flow low level API
-
class
brainflow.exit_codes.
BrainFlowExitCodes
(value) Bases:
enum.IntEnum
Enum to store all possible exit codes
-
STATUS_OK
= 0
-
PORT_ALREADY_OPEN_ERROR
= 1
-
UNABLE_TO_OPEN_PORT_ERROR
= 2
-
SER_PORT_ERROR
= 3
-
BOARD_WRITE_ERROR
= 4
-
INCOMMING_MSG_ERROR
= 5
-
INITIAL_MSG_ERROR
= 6
-
BOARD_NOT_READY_ERROR
= 7
-
STREAM_ALREADY_RUN_ERROR
= 8
-
INVALID_BUFFER_SIZE_ERROR
= 9
-
STREAM_THREAD_ERROR
= 10
-
STREAM_THREAD_IS_NOT_RUNNING
= 11
-
EMPTY_BUFFER_ERROR
= 12
-
INVALID_ARGUMENTS_ERROR
= 13
-
UNSUPPORTED_BOARD_ERROR
= 14
-
BOARD_NOT_CREATED_ERROR
= 15
-
ANOTHER_BOARD_IS_CREATED_ERROR
= 16
-
GENERAL_ERROR
= 17
-
SYNC_TIMEOUT_ERROR
= 18
-
JSON_NOT_FOUND_ERROR
= 19
-
NO_SUCH_DATA_IN_JSON_ERROR
= 20
-
CLASSIFIER_IS_NOT_PREPARED_ERROR
= 21
-
ANOTHER_CLASSIFIER_IS_PREPARED_ERROR
= 22
-
UNSUPPORTED_CLASSIFIER_AND_METRIC_COMBINATION_ERROR
= 23
-
brainflow.data_filter¶
-
class
brainflow.data_filter.
FilterTypes
(value) Bases:
enum.IntEnum
Enum to store all supported Filter Types
-
BUTTERWORTH
= 0
-
CHEBYSHEV_TYPE_1
= 1
-
BESSEL
= 2
-
-
class
brainflow.data_filter.
AggOperations
(value) Bases:
enum.IntEnum
Enum to store all supported aggregation operations
-
MEAN
= 0
-
MEDIAN
= 1
-
EACH
= 2
-
-
class
brainflow.data_filter.
WindowOperations
(value) Bases:
enum.IntEnum
Enum to store all supported window functions
-
NO_WINDOW
= 0
-
HANNING
= 1
-
HAMMING
= 2
-
BLACKMAN_HARRIS
= 3
-
-
class
brainflow.data_filter.
DetrendOperations
(value) Bases:
enum.IntEnum
Enum to store all supported detrend options
-
NO_DETREND
= 0
-
CONSTANT
= 1
-
LINEAR
= 2
-
-
class
brainflow.data_filter.
NoiseTypes
(value) Bases:
enum.IntEnum
Enum to store noise types
-
FIFTY
= 0
-
SIXTY
= 1
-
FIFTY_AND_SIXTY
= 2
-
-
class
brainflow.data_filter.
WaveletDenoisingTypes
(value) Bases:
enum.IntEnum
Enum to store all supported wavelet denoising methods
-
VISUSHRINK
= 0
-
SURESHRINK
= 1
-
-
class
brainflow.data_filter.
ThresholdTypes
(value) Bases:
enum.IntEnum
Enum to store all supported thresholding types
-
SOFT
= 0
-
HARD
= 1
-
-
class
brainflow.data_filter.
WaveletExtensionTypes
(value) Bases:
enum.IntEnum
Enum to store all supported wavelet extension types
-
SYMMETRIC
= 0
-
PERIODIC
= 1
-
-
class
brainflow.data_filter.
NoiseEstimationLevelTypes
(value) Bases:
enum.IntEnum
Enum to store all supported values for noise estemation levels in wavelet denoising
-
FIRST_LEVEL
= 0
-
ALL_LEVELS
= 1
-
-
class
brainflow.data_filter.
WaveletTypes
(value) Bases:
enum.IntEnum
Enum to store all supported wavelets
-
HAAR
= 0
-
DB1
= 1
-
DB2
= 2
-
DB3
= 3
-
DB4
= 4
-
DB5
= 5
-
DB6
= 6
-
DB7
= 7
-
DB8
= 8
-
DB9
= 9
-
DB10
= 10
-
DB11
= 11
-
DB12
= 12
-
DB13
= 13
-
DB14
= 14
-
DB15
= 15
-
BIOR1_1
= 16
-
BIOR1_3
= 17
-
BIOR1_5
= 18
-
BIOR2_2
= 19
-
BIOR2_4
= 20
-
BIOR2_6
= 21
-
BIOR2_8
= 22
-
BIOR3_1
= 23
-
BIOR3_3
= 24
-
BIOR3_5
= 25
-
BIOR3_7
= 26
-
BIOR3_9
= 27
-
BIOR4_4
= 28
-
BIOR5_5
= 29
-
BIOR6_8
= 30
-
COIF1
= 31
-
COIF2
= 32
-
COIF3
= 33
-
COIF4
= 34
-
COIF5
= 35
-
SYM2
= 36
-
SYM3
= 37
-
SYM4
= 38
-
SYM5
= 39
-
SYM6
= 40
-
SYM7
= 41
-
SYM8
= 42
-
SYM9
= 43
-
SYM10
= 44
-
-
class
brainflow.data_filter.
DataFilter
Bases:
object
DataFilter class contains methods for signal processig
-
classmethod
set_log_level
(log_level: int) → None set BrainFlow log level, use it only if you want to write your own messages to BrainFlow logger, otherwise use enable_data_logger, enable_dev_data_logger or disable_data_logger
- Parameters
log_level (int) – log level, to specify it you should use values from LogLevels enum
-
classmethod
enable_data_logger
() → None enable Data Logger with level INFO, uses stderr for log messages by default
-
classmethod
disable_data_logger
() → None disable Data Logger
-
classmethod
enable_dev_data_logger
() → None enable Data Logger with level TRACE, uses stderr for log messages by default
-
classmethod
set_log_file
(log_file: str) → None redirect logger from stderr to file, can be called any time
- Parameters
log_file (str) – log file name
-
classmethod
perform_lowpass
() apply low pass filter to provided data
- Parameters
data (NDArray[Float64]) – data to filter, filter works in-place
sampling_rate (int) – board’s sampling rate
cutoff (float) – cutoff frequency
order (int) – filter order
filter_type (int) – filter type from special enum
ripple (float) – ripple value for Chebyshev filter
-
classmethod
perform_highpass
() apply high pass filter to provided data
- Parameters
data (NDArray[Float64]) – data to filter, filter works in-place
sampling_rate (int) – board’s sampling rate
cutoff (float) – cutoff frequency
order (int) – filter order
filter_type (int) – filter type from special enum
ripple (float) – ripple value for Chebyshev filter
-
classmethod
perform_bandpass
() apply band pass filter to provided data
- Parameters
data (NDArray[Float64]) – data to filter, filter works in-place
sampling_rate (int) – board’s sampling rate
start_freq (float) – start frequency
stop_freq (float) – stop frequency
order (int) – filter order
filter_type (int) – filter type from special enum
ripple (float) – ripple value for Chebyshev filter
-
classmethod
perform_bandstop
() apply band stop filter to provided data
- Parameters
data (NDArray[Float64]) – data to filter, filter works in-place
sampling_rate (int) – board’s sampling rate
start_freq (float) – start frequency
stop_freq (float) – stop frequency
order (int) – filter order
filter_type (int) – filter type from special enum
ripple (float) – ripple value for Chebyshev filter
-
classmethod
remove_environmental_noise
() remove env noise using notch filter
- Parameters
data (NDArray[Float64]) – data to filter, filter works in-place
sampling_rate (int) – board’s sampling rate
noise_type (int) – noise type
-
classmethod
perform_rolling_filter
() smooth data using moving average or median
- Parameters
data (NDArray[Float64]) – data to smooth, it works in-place
period (int) – window size
operation (int) – int value from AggOperation enum
-
classmethod
calc_stddev
() calc stddev
- Parameters
data (NDArray[Float64]) – input array
- Returns
stddev
- Return type
float
-
classmethod
get_railed_percentage
() get railed percentage
- Parameters
data (NDArray[Float64]) – input array
gain (int) – gain
- Returns
railed percentage
- Return type
float
-
classmethod
get_oxygen_level
() get oxygen level from ppg
- Parameters
ppg_ir (NDArray[Float64]) – input array
ppg_red (NDArray[Float64]) – input array
sampling_rate (int) – sampling rate
- Returns
oxygen level
- Return type
float
-
classmethod
get_heart_rate
() get heart rate
- Parameters
ppg_ir (NDArray[Float64]) – input array
ppg_red (NDArray[Float64]) – input array
sampling_rate (int) – sampling rate
fft_size (int) – recommended 8192
- Returns
heart rate
- Return type
float
-
classmethod
perform_downsampling
() perform data downsampling, it doesnt apply lowpass filter for you, it just aggregates several data points
- Parameters
data (NDArray[Float64]) – initial data
period (int) – downsampling period
operation (int) – int value from AggOperation enum
- Returns
downsampled data
- Return type
NDArray[Float64]
-
classmethod
perform_wavelet_transform
() perform wavelet transform
- Parameters
data (NDArray[Float64]) – initial data
wavelet (int) – use WaveletTypes enum
decomposition_level (int) – level of decomposition
extension_type – extension type, use WaveletExtensionTypes
- Returns
tuple of wavelet coeffs in format [A(J) D(J) D(J-1) ….. D(1)] where J is decomposition level, A - app coeffs, D - detailed coeffs, and array with lengths for each block
- Return type
tuple
-
classmethod
restore_data_from_wavelet_detailed_coeffs
() restore data from a single wavelet coeff
- Parameters
data (NDArray[Float64]) – initial data
wavelet (int) – use WaveletTypes enum
decomposition_level (int) – level of decomposition
level_to_restore (int) – level of coeffs
- Returns
- Return type
NDArray[Float64]
-
classmethod
detect_peaks_z_score
() z score algorithm for peak detection
- Parameters
data (NDArray[Float64]) – initial data
lag (int) – window size for averaging
threshold (float) – in stddev units
influence (float) – contribution of peaks to mean value, between 0 and 1
- Returns
- Return type
NDArray[Float64]
-
classmethod
perform_inverse_wavelet_transform
() perform wavelet transform
- Parameters
wavelet_output – tuple of wavelet_coeffs and array with lengths
original_data_len (int) – len of signal before wavelet transform
wavelet (int) – use WaveletTypes enum
decomposition_level (int) – level of decomposition
extension_type – extension type, use WaveletExtensionTypes
- Returns
restored data
- Return type
NDArray[Float64]
-
classmethod
perform_wavelet_denoising
() perform wavelet denoising
- Parameters
data (NDArray[Float64]) – data to denoise
wavelet (int) – use WaveletTypes enum
decomposition_level (int) – decomposition level
wavelet_denoising (int) – use WaveletDenoisingTypes enum
threshold (int) – use ThresholdTypes enum
extension_type (int) – use WaveletExtensionTypes enum
noise_level (int) – use NoiseEstimationLevelTypes enum
-
classmethod
get_csp
() calculate filters and the corresponding eigenvalues using the Common Spatial Patterns
- Parameters
data (NDArray[Float64]) – [epochs x channels x times]-shaped 3D array of data for two classes
labels (NDArray[Int64]) – n_epochs-length 1D array of zeros and ones that assigns class labels for each epoch. Zero corresponds to the first class
- Returns
[channels x channels]-shaped 2D array of filters and [channels]-length 1D array of the corresponding eigenvalues
- Return type
Tuple
-
classmethod
get_window
() perform data windowing
- Parameters
window_function – window function
window_len – len of the window function
- Returns
numpy array, len of the array is the same as data
- Return type
NDArray[Float64]
-
classmethod
perform_fft
() perform direct fft
- Parameters
data (NDArray[Float64]) – data for fft, len of data must be even
window (int) – window function
- Returns
numpy array of complex values, len of this array is N / 2 + 1
- Return type
NDArray[Complex128]
-
classmethod
get_psd
() calculate PSD
- Parameters
data (NDArray[Float64]) – data to calc psd, len of data must be even
sampling_rate (int) – sampling rate
window (int) – window function
- Returns
amplitude and frequency arrays of len N / 2 + 1
- Return type
tuple
-
classmethod
get_psd_welch
() calculate PSD using Welch method
- Parameters
data (NDArray[Float64]) – data to calc psd
nfft (int) – FFT Window size, must be even
overlap (int) – overlap of FFT Windows, must be between 0 and nfft
sampling_rate (int) – sampling rate
window (int) – window function
- Returns
amplitude and frequency arrays of len N / 2 + 1
- Return type
tuple
-
classmethod
detrend
() detrend data
- Parameters
data (NDArray[Float64]) – data to calc psd
detrend_operation (int) – Type of detrend operation
-
classmethod
get_band_power
(psd: Tuple, freq_start: float, freq_end: float) → float calculate band power
- Parameters
psd (tuple) – psd from get_psd
freq_start (int) – start freq
freq_end (int) – end freq
- Returns
band power
- Return type
float
-
classmethod
get_avg_band_powers
(data: nptyping.types._ndarray.NDArray, channels: List, sampling_rate: int, apply_filter: bool) → Tuple calculate avg and stddev of BandPowers across all channels, bands are 1-4,4-8,8-13,13-30,30-50
- Parameters
data (NDArray) – 2d array for calculation
channels (List) – channels - rows of data array which should be used for calculation
sampling_rate (int) – sampling rate
apply_filter (bool) – apply bandpass and bandstop filtrers or not
- Returns
avg and stddev arrays for bandpowers
- Return type
tuple
-
classmethod
get_custom_band_powers
(data: nptyping.types._ndarray.NDArray, bands: List, channels: List, sampling_rate: int, apply_filter: bool) → Tuple calculate avg and stddev of BandPowers across selected channels
- Parameters
data (NDArray) – 2d array for calculation
bands (List) – List of typles with bands to use. E.g [(1.5, 4.0), (4.0, 8.0), (8.0, 13.0), (13.0, 30.0), (30.0, 45.0)]
channels (List) – channels - rows of data array which should be used for calculation
sampling_rate (int) – sampling rate
apply_filter (bool) – apply bandpass and bandstop filtrers or not
- Returns
avg and stddev arrays for bandpowers
- Return type
tuple
-
classmethod
perform_ica
(data: nptyping.types._ndarray.NDArray, num_components: int, channels=None) → Tuple perform ICA
- Parameters
data (NDArray) – 2d array for calculation
num_components (int) – number of components
channels (List) – channels - rows of data array which should be used for calculation, if None use all
- Returns
w, k, a, s matrixes as a tuple
- Return type
tuple
-
classmethod
perform_ifft
() perform inverse fft
- Parameters
data (NDArray[Complex128]) – data from fft
- Returns
restored data
- Return type
NDArray[Float64]
-
classmethod
get_nearest_power_of_two
(value: int) → int calc nearest power of two
- Parameters
value (int) – input value
- Returns
nearest power of two
- Return type
int
-
classmethod
write_file
(data, file_name: str, file_mode: str) → None write data to file, in file data will be transposed
- Parameters
data (2d numpy array) – data to store in a file
file_name (str) – file name to store data
file_mode (str) – ‘w’ to rewrite file or ‘a’ to append data to file
-
classmethod
read_file
(file_name: str) read data from file
- Parameters
file_name (str) – file name to read
- Returns
2d numpy array with data from this file, data will be transposed to original dimensions
- Return type
2d numpy array
-
classmethod
get_version
() → str get version of brainflow libraries
- Returns
version
- Return type
str
:raises BrainFlowError
-
classmethod
log_message
(log_level: int, message: str) → None write your own log message to BrainFlow logger, use it if you wanna have single logger for your own code and BrainFlow’s code
- Parameters
log_level – log level
message (str) – message
-
classmethod
brainflow.ml_model¶
-
class
brainflow.ml_model.
BrainFlowMetrics
(value) Bases:
enum.IntEnum
Enum to store all supported metrics
-
MINDFULNESS
= 0
-
RESTFULNESS
= 1
-
USER_DEFINED
= 2
-
-
class
brainflow.ml_model.
BrainFlowClassifiers
(value) Bases:
enum.IntEnum
Enum to store all supported classifiers
-
DEFAULT_CLASSIFIER
= 0
-
DYN_LIB_CLASSIFIER
= 1
-
ONNX_CLASSIFIER
= 2
-
-
class
brainflow.ml_model.
BrainFlowModelParams
(metric, classifier) Bases:
object
inputs parameters for prepare_session method
- Parameters
metric (int) – metric to calculate
classifier (int) – classifier to use
file (str) – file to load model
other_info (str) – additional information
output_name (str) – output node name
max_array_size (int) – max array size to preallocate
-
class
brainflow.ml_model.
MLModel
(model_params: brainflow.ml_model.BrainFlowModelParams) Bases:
object
MLModel class used to calc derivative metrics from raw data
- Parameters
model_params (BrainFlowModelParams) – Model Params
-
classmethod
set_log_level
(log_level: int) → None set BrainFlow log level, use it only if you want to write your own messages to BrainFlow logger, otherwise use enable_ml_logger, enable_dev_ml_logger or disable_ml_logger
- Parameters
log_level (int) – log level, to specify it you should use values from LogLevels enum
-
classmethod
enable_ml_logger
() → None enable ML Logger with level INFO, uses stderr for log messages by default
-
classmethod
disable_ml_logger
() → None disable BrainFlow Logger
-
classmethod
enable_dev_ml_logger
() → None enable ML Logger with level TRACE, uses stderr for log messages by default
-
classmethod
set_log_file
(log_file: str) → None redirect logger from stderr to file, can be called any time
- Parameters
log_file (str) – log file name
-
classmethod
log_message
(log_level: int, message: str) → None write your own log message to BrainFlow logger, use it if you wanna have single logger for your own code and BrainFlow’s code
- Parameters
log_level – log level
message (str) – message
-
classmethod
release_all
() → None release all classifiers
-
classmethod
get_version
() → str get version of brainflow libraries
- Returns
version
- Return type
str
:raises BrainFlowError
-
prepare
() → None prepare classifier
-
release
() → None release classifier
-
predict
(data: nptyping.types._ndarray.NDArray) → List calculate metric from data
- Parameters
data (NDArray) – input array
- Returns
metric value
- Return type
List
C++ API Reference¶
BoardShim class¶
-
class
BoardShim
¶ BoardShim class to communicate with a board.
Public Functions
-
BoardShim
(int board_id, struct BrainFlowInputParams params)¶
-
~BoardShim
()¶
-
void
prepare_session
()¶ prepare BrainFlow’s streaming session, should be called first
-
void
start_stream
(int buffer_size = 450000, std::string streamer_params = "")¶ start streaming thread and store data in ringbuffer
- Parameters
buffer_size
: size of internal ring buffer
-
void
add_streamer
(std::string streamer_params, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ add streamer
- Parameters
streamer_params
:use it to pass data packages further or store them directly during streaming, supported values: “file://%file_name%:w”, “file://%file_name%:a”, “streaming_board://%multicast_group_ip%:%port%””. Range for multicast addresses is from
”224.0.0.0” to “239.255.255.255”
-
void
delete_streamer
(std::string streamer_params, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ delete streamer
- Parameters
streamer_params
:use it to pass data packages further or store them directly during streaming, supported values: “file://%file_name%:w”, “file://%file_name%:a”, “streaming_board://%multicast_group_ip%:%port%””. Range for multicast addresses is from
”224.0.0.0” to “239.255.255.255”
-
bool
is_prepared
()¶ check if session is ready or not
-
void
stop_stream
()¶ stop streaming thread, doesnt release other resources
-
void
release_session
()¶ release streaming session
-
BrainFlowArray<double, 2>
get_current_board_data
(int num_samples, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get latest collected data, doesnt remove it from ringbuffer
-
int
get_board_id
()¶ Get board id, for some boards can be different than provided (playback, streaming)
-
int
get_board_data_count
(int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get number of packages in ringbuffer
-
BrainFlowArray<double, 2>
get_board_data
(int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get all collected data and flush it from internal buffer
-
BrainFlowArray<double, 2>
get_board_data
(int num_datapoints, int preset)¶ get required amount of datapoints or less and flush it from internal buffer
-
std::string
config_board
(std::string config)¶ send string to a board, use it carefully and only if you understand what you are doing
-
void
insert_marker
(double value, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ insert marker in data stream
Public Members
-
int
board_id
¶
Public Static Functions
-
void
disable_board_logger
()¶ disable BrainFlow loggers
-
void
enable_board_logger
()¶ enable BrainFlow logger with LEVEL_INFO
-
void
enable_dev_board_logger
()¶ enable BrainFlow logger with LEVEL_TRACE
-
void
set_log_file
(std::string log_file)¶ redirect BrainFlow logger from stderr to file
-
void
set_log_level
(int log_level)¶ use set_log_level only if you want to write your own log messages to BrainFlow logger
-
void
log_message
(int log_level, const char *format, ...)¶ write user defined string to BrainFlow logger
-
json
get_board_descr
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get board description as json
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If board id is not valid exit code is UNSUPPORTED_BOARD_ERROR
-
int
get_sampling_rate
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get sampling rate for this board
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int
get_package_num_channel
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row index which holds package nums
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int
get_timestamp_channel
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row index which holds timestamps
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int
get_marker_channel
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row index which holds markers
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int
get_battery_channel
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row index which holds battery level info
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int
get_num_rows
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get number of rows in returned from get_board_data() 2d array
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::string
get_device_name
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get device name
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<std::string>
get_eeg_names
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get eeg channel names in 10-20 system for devices with fixed electrode locations
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_eeg_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold EEG data, for some board we can not split EEG…
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_emg_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold EMG data, for some board we can not split EEG…
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_ecg_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold ECG data, for some board we can not split EEG…
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_eog_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold EOG data, for some board we can not split EEG…
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_exg_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold EXG data
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_ppg_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold PPG data
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_eda_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold EDA data
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_accel_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold accel data
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_analog_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold analog data
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_gyro_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold gyro data
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_other_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold other information
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_temperature_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold temperature data
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_resistance_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold resistance data
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
std::vector<int>
get_magnetometer_channels
(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶ get row indices which hold magnetometer data
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
void
release_all_sessions
()¶ release all currently prepared session
-
std::string
get_version
()¶ get brainflow version
-
std::vector<int>
get_board_presets
(int board_id)¶ get available presets for this board
- Parameters
board_id
: board id of your device
- Exceptions
BrainFlowException
:
-
DataFilter class¶
-
class
DataFilter
¶ DataFilter class to perform signal processing.
Public Static Functions
-
void
enable_data_logger
()¶ enable Data logger with LEVEL_INFO
-
void
disable_data_logger
()¶ disable Data loggers
-
void
enable_dev_data_logger
()¶ enable Data logger with LEVEL_TRACE
-
void
set_log_level
(int log_level)¶ set log level
-
void
set_log_file
(std::string log_file)¶ set log file
-
void
log_message
(int log_level, const char *format, ...)¶ write user defined string to BrainFlow logger
-
void
perform_lowpass
(double *data, int data_len, int sampling_rate, double cutoff, int order, int filter_type, double ripple)¶ perform low pass filter in-place
-
void
perform_highpass
(double *data, int data_len, int sampling_rate, double cutoff, int order, int filter_type, double ripple)¶ perform high pass filter in-place
-
void
perform_bandpass
(double *data, int data_len, int sampling_rate, double start_freq, double stop_freq, int order, int filter_type, double ripple)¶ perform bandpass filter in-place
-
void
perform_bandstop
(double *data, int data_len, int sampling_rate, double start_freq, double stop_freq, int order, int filter_type, double ripple)¶ perform bandstop filter in-place
-
void
remove_environmental_noise
(double *data, int data_len, int sampling_rate, int noise_type)¶ apply notch filter to remove env noise
-
void
perform_rolling_filter
(double *data, int data_len, int period, int agg_operation)¶ perform moving average or moving median filter in-place
-
double *
perform_downsampling
(double *data, int data_len, int period, int agg_operation, int *filtered_size)¶ perform data downsampling, it just aggregates several data points
-
std::pair<double*, int*>
perform_wavelet_transform
(double *data, int data_len, int wavelet, int decomposition_level, int extension_type = (int)WaveletExtensionTypes::SYMMETRIC)¶ perform wavelet transform
- Return
std::pair of wavelet coeffs array in format [A(J) D(J) D(J-1) ….. D(1)] where J is decomposition level A - app coeffs, D - detailed coeffs, and array of lengths for each block in wavelet coeffs array, length of this array is decomposition_level + 1
- Parameters
data
: input array, any sizedata_len
: length of input arraywavelet
: use WaveletTypes enumdecomposition_level
: level of decomposition in wavelet transformextension
: use WaveletExtensionTypes enum
-
double *
perform_inverse_wavelet_transform
(std::pair<double*, int*> wavelet_output, int original_data_len, int wavelet, int decomposition_level, int extension_type = (int)WaveletExtensionTypes::SYMMETRIC)¶ performs inverse wavelet transform
-
void
perform_wavelet_denoising
(double *data, int data_len, int wavelet, int decomposition_level, int wavelet_denoising = (int)WaveletDenoisingTypes::SURESHRINK, int threshold = (int)ThresholdTypes::HARD, int extenstion_type = (int)WaveletExtensionTypes::SYMMETRIC, int noise_level = (int)NoiseEstimationLevelTypes::FIRST_LEVEL)¶ perform wavelet denoising
- Parameters
data
: input array, any sizedata_len
: length of input arraywavelet
: use WaveletTypes enumdecomposition_level
: level of decomposition in wavelet transformwavelet_denoising
: use WaveletDenoisingTypes enumthreshold
: use ThresholdTypes enumextension
: use WaveletExtensionTypes enumnoise_level
: use NoiseEstimationLevelTypes enum
-
void
restore_data_from_wavelet_detailed_coeffs
(double *data, int data_len, int wavelet, int decomposition_level, int level_to_restore, double *output)¶ restore data from selected detailed coeffs
-
void
detect_peaks_z_score
(double *data, int data_len, int lag, double threshold, double influence, double *output)¶ z score peak detection, more info https://stackoverflow.com/a/22640362
-
std::pair<BrainFlowArray<double, 2>, BrainFlowArray<double, 1>>
get_csp
(const BrainFlowArray<double, 3> &data, const BrainFlowArray<double, 1> &labels)¶ calculate filters and the corresponding eigenvalues using the Common Spatial Patterns
- Return
pair of two arrays. The first [n_channel x n_channel]-shaped 2D array represents filters. The second n-channel length 1D array represents eigenvalues
- Parameters
data
: [n_epochs x n_channels x n_times]-shaped 3D array of data for two classeslabels
: n_epochs-length 1D array of zeros and ones that assigns class labels for each epoch. Zero corresponds to the first classn_epochs
: the total number of epochsn_channels
: the number of EEG channelsn_times
: the number of samples (observations) for a single epoch for a single channel
-
double *
get_window
(int window_function, int window_len)¶ perform data windowing
-
std::complex<double> *
perform_fft
(double *data, int data_len, int window, int *fft_len)¶ perform direct fft
- Return
complex array with size data_len / 2 + 1, it holds only positive im values
- Parameters
data
: input arraydata_len
: must be evenwindow
: window functionfft_len
: output fft len(data_len / 2 + 1)
-
double *
perform_ifft
(std::complex<double> *fft_data, int fft_len, int *data_len)¶ perform inverse fft
- Return
restored data
- Parameters
fft_data
: complex array from perform_fftfft_len
: len of original array, must be evendata_len
: output array len
-
int
get_nearest_power_of_two
(int value)¶ calculate nearest power of 2
- Return
nearest power of 2
- Parameters
value
: input value
-
std::pair<double*, double*>
get_psd
(double *data, int data_len, int sampling_rate, int window, int *psd_len)¶ calculate PSD
- Return
pair of amplitude and freq arrays of size data_len / 2 + 1
- Parameters
data
: input arraydata_len
: must be evensampling_rate
: sampling ratewindow
: window functionpsd_len
: output len (data_len / 2 + 1)
-
void
detrend
(double *data, int data_len, int detrend_operation)¶ subtract trend from data
- Parameters
data
: input arraydata_len
:psd_len
: output len (data_len / 2 + 1)detrend_operation
: use DetrendOperations enum
-
std::pair<double*, double*>
get_psd_welch
(double *data, int data_len, int nfft, int overlap, int sampling_rate, int window, int *psd_len)¶
-
double
get_band_power
(std::pair<double*, double*> psd, int data_len, double freq_start, double freq_end)¶ calculate band power
- Return
band power
- Parameters
psd
: psd calculated using get_psddata_len
: len of ampl and freq arrays: N / 2 + 1 where N is FFT sizefreq_start
: lowest frequencyfreq_end
: highest frequency
-
std::pair<double*, double*>
get_avg_band_powers
(const BrainFlowArray<double, 2> &data, std::vector<int> channels, int sampling_rate, bool apply_filters)¶ calculate avg and stddev of BandPowers across all channels
- Return
pair of double arrays of size 5, first of them - avg band powers, second stddev
- Parameters
data
: input 2d arraycols
: number of cols in 2d array - number of datapointschannels
: vector of rows - eeg channels which should be usedsampling_rate
: sampling rateapply_filters
: set to true to apply filters before band power calculations
-
std::pair<double*, double*>
get_custom_band_powers
(const BrainFlowArray<double, 2> &data, std::vector<std::pair<double, double>> bands, std::vector<int> channels, int sampling_rate, bool apply_filters)¶ calculate avg and stddev of BandPowers across all channels
- Return
pair of float arrays with the same size as bands argument
- Parameters
data
: input 2d arraybands
: input bandscols
: number of cols in 2d array - number of datapointschannels
: vector of rows - eeg channels which should be usedsampling_rate
: sampling rateapply_filters
: set to true to apply filters before band power calculations
-
double
get_oxygen_level
(double *ppg_ir, double *ppg_red, int data_len, int sampling_rate, double coef1 = 0.0, double coef2 = -37.663, double coef3 = 114.91)¶ calculate oxygen level
- Return
oxygen level
- Parameters
ppg_ir
: input 1d arrayppg_red
: input 1d arraydata_len
: size of arraysampling_rate
: sampling rate
-
double
get_heart_rate
(double *ppg_ir, double *ppg_red, int data_len, int sampling_rate, int fft_size)¶ calculate heart rate
- Return
heart rate
- Parameters
ppg_ir
: input 1d arrayppg_red
: input 1d arraydata_len
: size of arraysampling_rate
: sampling ratefft_size
: recommended 8192
-
void
write_file
(const BrainFlowArray<double, 2> &data, std::string file_name, std::string file_mode)¶ write file, in file data will be transposed
-
BrainFlowArray<double, 2>
read_file
(std::string file_name)¶ read data from file, data will be transposed to original format
-
double
calc_stddev
(double *data, int start_pos, int end_pos)¶ calc stddev
-
double
get_railed_percentage
(double *data, int data_len, int gain)¶ calc railed percentage
-
std::tuple<BrainFlowArray<double, 2>, BrainFlowArray<double, 2>, BrainFlowArray<double, 2>, BrainFlowArray<double, 2>>
perform_ica
(const BrainFlowArray<double, 2> &data, int num_components, std::vector<int> channels)¶ calculate ICA
- Return
unmixed signal
- Parameters
data
: input 2d array, rows are samplesnum_components
: number of components to findchannels
: rows to use
-
std::tuple<BrainFlowArray<double, 2>, BrainFlowArray<double, 2>, BrainFlowArray<double, 2>, BrainFlowArray<double, 2>>
perform_ica
(const BrainFlowArray<double, 2> &data, int num_components)¶ calculate ICA
- Return
unmixed signal
- Parameters
data
: input 2d array, rows are samplesnum_components
: number of components to find
-
std::string
get_version
()¶ get brainflow version
-
void
MLModel class¶
-
class
MLModel
¶ Calculates different metrics from raw data.
Public Functions
-
MLModel
(struct BrainFlowModelParams params)¶
-
~MLModel
()¶
-
void
prepare
()¶ initialize classifier, should be called first
-
std::vector<double>
predict
(double *data, int data_len)¶ calculate metric from data
-
void
release
()¶ release classifier
Public Static Functions
-
void
set_log_file
(std::string log_file)¶ redirect logger to a file
-
void
enable_ml_logger
()¶ enable ML logger with LEVEL_INFO
-
void
disable_ml_logger
()¶ disable ML loggers
-
void
enable_dev_ml_logger
()¶ enable ML logger with LEVEL_TRACE
-
void
set_log_level
(int log_level)¶ set log level
-
void
log_message
(int log_level, const char *format, ...)¶ write user defined string to BrainFlow logger
-
void
release_all
()¶ release all currently prepared classifiers
-
std::string
get_version
()¶ get brainflow version
-
BrainFlow constants¶
#pragma once
enum class BrainFlowExitCodes : int
{
STATUS_OK = 0,
PORT_ALREADY_OPEN_ERROR = 1,
UNABLE_TO_OPEN_PORT_ERROR = 2,
SET_PORT_ERROR = 3,
BOARD_WRITE_ERROR = 4,
INCOMMING_MSG_ERROR = 5,
INITIAL_MSG_ERROR = 6,
BOARD_NOT_READY_ERROR = 7,
STREAM_ALREADY_RUN_ERROR = 8,
INVALID_BUFFER_SIZE_ERROR = 9,
STREAM_THREAD_ERROR = 10,
STREAM_THREAD_IS_NOT_RUNNING = 11,
EMPTY_BUFFER_ERROR = 12,
INVALID_ARGUMENTS_ERROR = 13,
UNSUPPORTED_BOARD_ERROR = 14,
BOARD_NOT_CREATED_ERROR = 15,
ANOTHER_BOARD_IS_CREATED_ERROR = 16,
GENERAL_ERROR = 17,
SYNC_TIMEOUT_ERROR = 18,
JSON_NOT_FOUND_ERROR = 19,
NO_SUCH_DATA_IN_JSON_ERROR = 20,
CLASSIFIER_IS_NOT_PREPARED_ERROR = 21,
ANOTHER_CLASSIFIER_IS_PREPARED_ERROR = 22,
UNSUPPORTED_CLASSIFIER_AND_METRIC_COMBINATION_ERROR = 23
};
enum class BoardIds : int
{
NO_BOARD = -100, // only for internal usage
PLAYBACK_FILE_BOARD = -3,
STREAMING_BOARD = -2,
SYNTHETIC_BOARD = -1,
CYTON_BOARD = 0,
GANGLION_BOARD = 1,
CYTON_DAISY_BOARD = 2,
GALEA_BOARD = 3,
GANGLION_WIFI_BOARD = 4,
CYTON_WIFI_BOARD = 5,
CYTON_DAISY_WIFI_BOARD = 6,
BRAINBIT_BOARD = 7,
UNICORN_BOARD = 8,
CALLIBRI_EEG_BOARD = 9,
CALLIBRI_EMG_BOARD = 10,
CALLIBRI_ECG_BOARD = 11,
NOTION_1_BOARD = 13,
NOTION_2_BOARD = 14,
GFORCE_PRO_BOARD = 16,
FREEEEG32_BOARD = 17,
BRAINBIT_BLED_BOARD = 18,
GFORCE_DUAL_BOARD = 19,
GALEA_SERIAL_BOARD = 20,
MUSE_S_BLED_BOARD = 21,
MUSE_2_BLED_BOARD = 22,
CROWN_BOARD = 23,
ANT_NEURO_EE_410_BOARD = 24,
ANT_NEURO_EE_411_BOARD = 25,
ANT_NEURO_EE_430_BOARD = 26,
ANT_NEURO_EE_211_BOARD = 27,
ANT_NEURO_EE_212_BOARD = 28,
ANT_NEURO_EE_213_BOARD = 29,
ANT_NEURO_EE_214_BOARD = 30,
ANT_NEURO_EE_215_BOARD = 31,
ANT_NEURO_EE_221_BOARD = 32,
ANT_NEURO_EE_222_BOARD = 33,
ANT_NEURO_EE_223_BOARD = 34,
ANT_NEURO_EE_224_BOARD = 35,
ANT_NEURO_EE_225_BOARD = 36,
ENOPHONE_BOARD = 37,
MUSE_2_BOARD = 38,
MUSE_S_BOARD = 39,
BRAINALIVE_BOARD = 40,
MUSE_2016_BOARD = 41,
MUSE_2016_BLED_BOARD = 42,
EXPLORE_4_CHAN_BOARD = 44,
EXPLORE_8_CHAN_BOARD = 45,
GANGLION_NATIVE_BOARD = 46,
EMOTIBIT_BOARD = 47,
// use it to iterate
FIRST = PLAYBACK_FILE_BOARD,
LAST = EMOTIBIT_BOARD
};
enum class IpProtocolTypes : int
{
NO_IP_PROTOCOL = 0,
UDP = 1,
TCP = 2
};
enum class FilterTypes : int
{
BUTTERWORTH = 0,
CHEBYSHEV_TYPE_1 = 1,
BESSEL = 2
};
enum class AggOperations : int
{
MEAN = 0,
MEDIAN = 1,
EACH = 2
};
enum class WindowOperations : int
{
NO_WINDOW = 0,
HANNING = 1,
HAMMING = 2,
BLACKMAN_HARRIS = 3
};
enum class DetrendOperations : int
{
NO_DETREND = 0,
CONSTANT = 1,
LINEAR = 2
};
enum class BrainFlowMetrics : int
{
MINDFULNESS = 0,
RESTFULNESS = 1,
USER_DEFINED = 2
};
enum class BrainFlowClassifiers : int
{
DEFAULT_CLASSIFIER = 0,
DYN_LIB_CLASSIFIER = 1,
ONNX_CLASSIFIER = 2
};
enum class BrainFlowPresets : int
{
DEFAULT_PRESET = 0,
AUXILIARY_PRESET = 1,
ANCILLARY_PRESET = 2
};
enum class LogLevels : int
{
LEVEL_TRACE = 0,
LEVEL_DEBUG = 1,
LEVEL_INFO = 2,
LEVEL_WARN = 3,
LEVEL_ERROR = 4,
LEVEL_CRITICAL = 5,
LEVEL_OFF = 6
};
enum class NoiseTypes : int
{
FIFTY = 0,
SIXTY = 1,
FIFTY_AND_SIXTY = 2
};
enum class WaveletDenoisingTypes : int
{
VISUSHRINK = 0,
SURESHRINK = 1
};
enum class ThresholdTypes : int
{
SOFT = 0,
HARD = 1
};
enum class WaveletExtensionTypes : int
{
SYMMETRIC = 0,
PERIODIC = 1
};
enum class NoiseEstimationLevelTypes : int
{
FIRST_LEVEL = 0,
ALL_LEVELS = 1
};
enum class WaveletTypes : int
{
HAAR = 0,
DB1 = 1,
DB2 = 2,
DB3 = 3,
DB4 = 4,
DB5 = 5,
DB6 = 6,
DB7 = 7,
DB8 = 8,
DB9 = 9,
DB10 = 10,
DB11 = 11,
DB12 = 12,
DB13 = 13,
DB14 = 14,
DB15 = 15,
BIOR1_1 = 16,
BIOR1_3 = 17,
BIOR1_5 = 18,
BIOR2_2 = 19,
BIOR2_4 = 20,
BIOR2_6 = 21,
BIOR2_8 = 22,
BIOR3_1 = 23,
BIOR3_3 = 24,
BIOR3_5 = 25,
BIOR3_7 = 26,
BIOR3_9 = 27,
BIOR4_4 = 28,
BIOR5_5 = 29,
BIOR6_8 = 30,
COIF1 = 31,
COIF2 = 32,
COIF3 = 33,
COIF4 = 34,
COIF5 = 35,
SYM2 = 36,
SYM3 = 37,
SYM4 = 38,
SYM5 = 39,
SYM6 = 40,
SYM7 = 41,
SYM8 = 42,
SYM9 = 43,
SYM10 = 44,
// to iterate and check sizes
FIRST_WAVELET = HAAR,
LAST_WAVELET = SYM10
};
Java API Reference¶
Content of Brainflow Package:
-
enum
AggOperations
¶ enum to store all supported aggregation operations
Public Members
-
brainflow::MEAN =(0)
-
brainflow::MEDIAN =(1)
-
brainflow::EACH =(2)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
AggOperations brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::agg_operation
Private Static Attributes
-
final Map< Integer, AggOperations > brainflow::ao_map = new HashMap<Integer, AggOperations> ()
-
-
class
brainflow::brainflow
::
BoardDescr
¶ Public Functions
-
BoardDescr
()¶
Public Members
-
Integer
sampling_rate
¶
-
List<Integer>
eeg_channels
¶
-
List<Integer>
eog_channels
¶
-
List<Integer>
exg_channels
¶
-
List<Integer>
emg_channels
¶
-
List<Integer>
ppg_channels
¶
-
List<Integer>
eda_channels
¶
-
List<Integer>
accel_channels
¶
-
List<Integer>
gyro_channels
¶
-
List<Integer>
temperature_channels
¶
-
List<Integer>
resistance_channels
¶
-
List<Integer>
other_channels
¶
-
Integer
package_num_channel
¶
-
Integer
batter_channel
¶
-
Integer
timestamp_channel
¶
-
Integer
marker_channel
¶
-
Integer
num_rows
¶
-
String
name
¶
-
String
eeg_names
¶
-
-
enum
BoardIds
¶ enum to store all supported boards
Public Functions
-
int
get_code
()
-
brainflow::BoardIds (final int code)
Public Members
-
brainflow::NO_BOARD =(-100)
-
brainflow::PLAYBACK_FILE_BOARD =(-3)
-
brainflow::STREAMING_BOARD =(-2)
-
brainflow::SYNTHETIC_BOARD =(-1)
-
brainflow::CYTON_BOARD =(0)
-
brainflow::GANGLION_BOARD =(1)
-
brainflow::CYTON_DAISY_BOARD =(2)
-
brainflow::GALEA_BOARD =(3)
-
brainflow::GANGLION_WIFI_BOARD =(4)
-
brainflow::CYTON_WIFI_BOARD =(5)
-
brainflow::CYTON_DAISY_WIFI_BOARD =(6)
-
brainflow::BRAINBIT_BOARD =(7)
-
brainflow::UNICORN_BOARD =(8)
-
brainflow::CALLIBRI_EEG_BOARD =(9)
-
brainflow::CALLIBRI_EMG_BOARD =(10)
-
brainflow::CALLIBRI_ECG_BOARD =(11)
-
brainflow::NOTION_1_BOARD =(13)
-
brainflow::NOTION_2_BOARD =(14)
-
brainflow::GFORCE_PRO_BOARD =(16)
-
brainflow::FREEEEG32_BOARD =(17)
-
brainflow::BRAINBIT_BLED_BOARD =(18)
-
brainflow::GFORCE_DUAL_BOARD =(19)
-
brainflow::GALEA_SERIAL_BOARD =(20)
-
brainflow::MUSE_S_BLED_BOARD =(21)
-
brainflow::MUSE_2_BLED_BOARD =(22)
-
brainflow::CROWN_BOARD =(23)
-
brainflow::ANT_NEURO_EE_410_BOARD =(24)
-
brainflow::ANT_NEURO_EE_411_BOARD =(25)
-
brainflow::ANT_NEURO_EE_430_BOARD =(26)
-
brainflow::ANT_NEURO_EE_211_BOARD =(27)
-
brainflow::ANT_NEURO_EE_212_BOARD =(28)
-
brainflow::ANT_NEURO_EE_213_BOARD =(29)
-
brainflow::ANT_NEURO_EE_214_BOARD =(30)
-
brainflow::ANT_NEURO_EE_215_BOARD =(31)
-
brainflow::ANT_NEURO_EE_221_BOARD =(32)
-
brainflow::ANT_NEURO_EE_222_BOARD =(33)
-
brainflow::ANT_NEURO_EE_223_BOARD =(34)
-
brainflow::ANT_NEURO_EE_224_BOARD =(35)
-
brainflow::ANT_NEURO_EE_225_BOARD =(36)
-
brainflow::ENOPHONE_BOARD =(37)
-
brainflow::MUSE_2_BOARD =(38)
-
brainflow::MUSE_S_BOARD =(39)
-
brainflow::MUSE_2016_BOARD =(41)
-
brainflow::MUSE_2016_BLED_BOARD =(42)
-
brainflow::EXPLORE_4_CHAN_BOARD =(44)
-
brainflow::EXPLORE_8_CHAN_BOARD =(45)
-
brainflow::GANGLION_NATIVE_BOARD =(46)
-
brainflow::EMOTIBIT_BOARD =(47)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
BoardIds brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::board_id
Private Static Attributes
-
final Map< Integer, BoardIds > brainflow::bi_map = new HashMap<Integer, BoardIds> ()
-
int
-
class
brainflow::brainflow
::
BoardShim
¶ BoardShim class to communicate with a board
Public Functions
-
BoardShim
(int board_id, BrainFlowInputParams params)¶ Create BoardShim object
-
BoardShim
(BoardIds board_id, BrainFlowInputParams params)¶ Create BoardShim object
-
void
prepare_session
()¶ prepare steaming session, allocate resources
-
int
get_board_id
()¶ Get Board Id, can be different than provided (playback or streaming board)
-
void
add_streamer
(String streamer, int preset)¶ add streamer
-
void
delete_streamer
(String streamer, int preset)¶ delete streamer
-
void
add_streamer
(String streamer, BrainFlowPresets preset)¶
-
void
add_streamer
(String streamer)¶
-
void
delete_streamer
(String streamer, BrainFlowPresets preset)¶
-
void
delete_streamer
(String streamer)¶
-
String
config_board
(String config)¶ send string to a board, use this method carefully and only if you understand what you are doing
-
void
start_stream
(int buffer_size, String streamer_params)¶ start streaming thread, store data in internal ringbuffer and stream them from brainflow at the same time
- Parameters
buffer_size
: size of internal ringbufferstreamer_params
: supported vals: “file://%file_name%:w”, “file://%file_name%:a”, “streaming_board://%multicast_group_ip%:%port%”. Range for multicast addresses is from “224.0.0.0” to “239.255.255.255”
-
void
start_stream
()¶ start streaming thread, store data in internal ringbuffer
-
void
start_stream
(int buffer_size)¶ start streaming thread, store data in internal ringbuffer
-
void
stop_stream
()¶ stop streaming thread
-
void
release_session
()¶ release all resources
-
int
get_board_data_count
(BrainFlowPresets preset)¶ get number of packages in ringbuffer
-
int
get_board_data_count
()¶ get number of packages in ringbuffer
-
void
insert_marker
(double value, BrainFlowPresets preset)¶ insert marker to data stream
-
void
insert_marker
(double value)¶ insert marker to data stream
-
boolean
is_prepared
()¶ check session status
-
double [][] get_current_board_data (int num_samples, BrainFlowPresets preset)
get latest collected data, can return less than “num_samples”, doesnt flush it from ringbuffer
-
double [][] get_current_board_data (int num_samples)
get latest collected data, can return less than “num_samples”, doesnt flush it from ringbuffer
-
double [][] get_board_data (BrainFlowPresets preset)
get all data from ringbuffer and flush it
-
double [][] get_board_data (int num_datapoints, BrainFlowPresets preset)
-
double [][] get_board_data ()
get all data from ringbuffer and flush it
-
double [][] get_board_data (int num_datapoints)
Public Members
-
int
board_id
¶ BrainFlow’s board id
Public Static Functions
-
void
enable_board_logger
()¶ enable BrainFlow logger with level INFO
-
void
enable_dev_board_logger
()¶ enable BrainFlow logger with level TRACE
-
void
disable_board_logger
()¶ disable BrainFlow logger
-
void
set_log_file
(String log_file)¶ redirect logger from stderr to a file
-
void
release_all_sessions
()¶ release all prepared sessions
-
void
set_log_level
(int log_level)¶ set log level
-
void
log_message
(int log_level, String message)¶ send user defined strings to BrainFlow logger
-
void
log_message
(LogLevels log_level, String message)¶ send user defined strings to BrainFlow logger
-
int
get_sampling_rate
(int board_id, BrainFlowPresets preset)¶ get sampling rate for this board
-
int
get_sampling_rate
(BoardIds board_id, BrainFlowPresets preset)¶ get sampling rate for this board
-
int
get_sampling_rate
(int board_id)¶ get sampling rate for this board
-
int
get_timestamp_channel
(int board_id, BrainFlowPresets preset)¶ get row index in returned by get_board_data() 2d array which contains timestamps
-
int
get_timestamp_channel
(BoardIds board_id, BrainFlowPresets preset)¶ get row index in returned by get_board_data() 2d array which contains timestamps
-
int
get_timestamp_channel
(BoardIds board_id)¶ get row index in returned by get_board_data() 2d array which contains timestamps
-
int
get_timestamp_channel
(int board_id)¶ get row index in returned by get_board_data() 2d array which contains timestamps
-
int
get_marker_channel
(int board_id, BrainFlowPresets preset)¶ get row index in returned by get_board_data() 2d array which contains markers
-
int
get_marker_channel
(BoardIds board_id, BrainFlowPresets preset)¶ get row index in returned by get_board_data() 2d array which contains markers
-
int
get_marker_channel
(BoardIds board_id)¶ get row index in returned by get_board_data() 2d array which contains markers
-
int
get_marker_channel
(int board_id)¶ get row index in returned by get_board_data() 2d array which contains markers
-
int
get_num_rows
(int board_id, BrainFlowPresets preset)¶ get number of rows in returned by get_board_data() 2d array
-
int
get_num_rows
(BoardIds board_id, BrainFlowPresets preset)¶ get number of rows in returned by get_board_data() 2d array
-
int
get_num_rows
(BoardIds board_id)¶ get number of rows in returned by get_board_data() 2d array
-
int
get_num_rows
(int board_id)¶ get number of rows in returned by get_board_data() 2d array
-
int
get_package_num_channel
(int board_id, BrainFlowPresets preset)¶ get row index in returned by get_board_data() 2d array which contains package nums
-
int
get_package_num_channel
(int board_id)¶ get row index in returned by get_board_data() 2d array which contains package nums
-
int
get_package_num_channel
(BoardIds board_id, BrainFlowPresets preset)¶ get row index in returned by get_board_data() 2d array which contains package nums
-
int
get_package_num_channel
(BoardIds board_id)¶ get row index in returned by get_board_data() 2d array which contains package nums
-
int
get_battery_channel
(int board_id, BrainFlowPresets preset)¶ get row index in returned by get_board_data() 2d array which contains battery level
-
int
get_battery_channel
(int board_id)¶ get row index in returned by get_board_data() 2d array which contains battery level
-
int
get_battery_channel
(BoardIds board_id, BrainFlowPresets preset)¶ get row index in returned by get_board_data() 2d array which contains battery level
-
int
get_battery_channel
(BoardIds board_id)¶ get row index in returned by get_board_data() 2d array which contains battery level
-
String [] get_eeg_names (int board_id, BrainFlowPresets preset)
Get names of EEG electrodes in 10-20 system. Only if electrodes have freezed locations
-
BrainFlowPresets [] get_board_presets (int board_id)
Get supported presets for this device
-
String [] get_eeg_names (int board_id)
Get names of EEG electrodes in 10-20 system. Only if electrodes have freezed locations
-
String [] get_eeg_names (BoardIds board_id, BrainFlowPresets preset)
Get names of EEG electrodes in 10-20 system. Only if electrodes have freezed locations
-
String [] get_eeg_names (BoardIds board_id)
Get names of EEG electrodes in 10-20 system. Only if electrodes have freezed locations
-
static< T > T get_board_descr (Class< T > type, int board_id, BrainFlowPresets preset)
Get board description
-
static< T > T get_board_descr (Class< T > type, int board_id)
Get board description
-
static< T > T get_board_descr (Class< T > type, BoardIds board_id, BrainFlowPresets preset)
Get board description
-
static< T > T get_board_descr (Class< T > type, BoardIds board_id)
Get board description
-
String
get_device_name
(int board_id, BrainFlowPresets preset)¶ Get device name
-
String
get_device_name
(int board_id)¶ Get device name
-
String
get_device_name
(BoardIds board_id, BrainFlowPresets preset)¶ Get device name
-
String
get_version
()¶ Get version
-
int [] get_eeg_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EEG data, for some boards we can not split EEG… and return the same array
-
int [] get_eeg_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain EEG data, for some boards we can not split EEG… and return the same array
-
int [] get_eeg_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EEG data, for some boards we can not split EEG… and return the same array
-
int [] get_eeg_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain EEG data, for some boards we can not split EEG… and return the same array
-
int [] get_emg_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EMG data, for some boards we can not split EEG… and return the same array
-
int [] get_emg_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain EMG data, for some boards we can not split EEG… and return the same array
-
int [] get_emg_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EMG data, for some boards we can not split EEG… and return the same array
-
int [] get_emg_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain EMG data, for some boards we can not split EEG… and return the same array
-
int [] get_ecg_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain ECG data, for some boards we can not split EEG… and return the same array
-
int [] get_ecg_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain ECG data, for some boards we can not split EEG… and return the same array
-
int [] get_ecg_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain ECG data, for some boards we can not split EEG… and return the same array
-
int [] get_ecg_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain ECG data, for some boards we can not split EEG… and return the same array
-
int [] get_temperature_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain temperature data
-
int [] get_temperature_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain temperature data
-
int [] get_temperature_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain temperature data
-
int [] get_temperature_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain temperature data
-
int [] get_magnetometer_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain magnetometer data
-
int [] get_magnetometer_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain magnetometer data
-
int [] get_magnetometer_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain magnetometer data
-
int [] get_magnetometer_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain magnetometer data
-
int [] get_resistance_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain resistance data
-
int [] get_resistance_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain resistance data
-
int [] get_resistance_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain resistance data
-
int [] get_resistance_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain resistance data
-
int [] get_eog_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EOG data, for some boards we can not split EEG… and return the same array
-
int [] get_eog_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain EOG data, for some boards we can not split EEG… and return the same array
-
int [] get_eog_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EOG data, for some boards we can not split EEG… and return the same array
-
int [] get_eog_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain EOG data, for some boards we can not split EEG… and return the same array
-
int [] get_exg_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EXG data
-
int [] get_exg_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain EXG data
-
int [] get_exg_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EXG data
-
int [] get_exg_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain EXG data
-
int [] get_eda_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EDA data, for some boards we can not split EEG… and return the same array
-
int [] get_eda_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain EDA data, for some boards we can not split EEG… and return the same array
-
int [] get_eda_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EDA data, for some boards we can not split EEG… and return the same array
-
int [] get_eda_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain EDA data, for some boards we can not split EEG… and return the same array
-
int [] get_ppg_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain PPG data, for some boards we can not split EEG… and return the same array
-
int [] get_ppg_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain PPG data, for some boards we can not split EEG… and return the same array
-
int [] get_ppg_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain PPG data, for some boards we can not split EEG… and return the same array
-
int [] get_ppg_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain PPG data, for some boards we can not split EEG… and return the same array
-
int [] get_accel_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain accel data
-
int [] get_accel_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain accel data
-
int [] get_accel_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain accel data
-
int [] get_accel_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain accel data
-
int [] get_analog_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain analog data
-
int [] get_analog_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain analog data
-
int [] get_analog_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain analog data
-
int [] get_analog_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain analog data
-
int [] get_gyro_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain gyro data
-
int [] get_gyro_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain gyro data
-
int [] get_gyro_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain gyro data
-
int [] get_gyro_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain gyro data
-
int [] get_other_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain other data
-
int [] get_other_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain other data
-
int [] get_other_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain other data
-
int [] get_other_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain other data
-
-
enum
BrainFlowClassifiers
¶ Public Functions
-
int
get_code
()
-
brainflow::BrainFlowClassifiers (final int code)
Public Members
-
brainflow::DEFAULT_CLASSIFIER =(0)
-
brainflow::DYN_LIB_CLASSIFIER =(1)
-
brainflow::ONNX_CLASSIFIER =(2)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
BrainFlowClassifiers brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::protocol
Private Static Attributes
-
final Map< Integer, BrainFlowClassifiers > brainflow::cl_map = new HashMap<Integer, BrainFlowClassifiers> ()
-
int
-
class
brainflow::brainflow
::
BrainFlowError
: public Exception¶ BrainFlowError exception to notify about errors
Public Functions
-
BrainFlowError
(String message, int ec)¶
-
-
enum
BrainFlowExitCode
¶ Public Functions
-
int
get_code
()
-
brainflow::BrainFlowExitCode (final int code)
Public Members
-
brainflow::STATUS_OK =(0)
-
brainflow::PORT_ALREADY_OPEN_ERROR =(1)
-
brainflow::UNABLE_TO_OPEN_PORT_ERROR =(2)
-
brainflow::SET_PORT_ERROR =(3)
-
brainflow::BOARD_WRITE_ERROR =(4)
-
brainflow::INCOMMING_MSG_ERROR =(5)
-
brainflow::INITIAL_MSG_ERROR =(6)
-
brainflow::BOARD_NOT_READY_ERROR =(7)
-
brainflow::STREAM_ALREADY_RUN_ERROR =(8)
-
brainflow::INVALID_BUFFER_SIZE_ERROR =(9)
-
brainflow::STREAM_THREAD_ERROR =(10)
-
brainflow::STREAM_THREAD_IS_NOT_RUNNING =(11)
-
brainflow::EMPTY_BUFFER_ERROR =(12)
-
brainflow::INVALID_ARGUMENTS_ERROR =(13)
-
brainflow::UNSUPPORTED_BOARD_ERROR =(14)
-
brainflow::BOARD_NOT_CREATED_ERROR =(15)
-
brainflow::ANOTHER_BOARD_IS_CREATED_ERROR =(16)
-
brainflow::GENERAL_ERROR =(17)
-
brainflow::SYNC_TIMEOUT_ERROR =(18)
-
brainflow::JSON_NOT_FOUND_ERROR =(19)
-
brainflow::NO_SUCH_DATA_IN_JSON_ERROR =(20)
-
brainflow::CLASSIFIER_IS_NOT_PREPARED_ERROR =(21)
-
brainflow::ANOTHER_CLASSIFIER_IS_PREPARED_ERROR =(22)
-
brainflow::UNSUPPORTED_CLASSIFIER_AND_METRIC_COMBINATION_ERROR =(23)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
BrainFlowExitCode brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::exit_code
Private Static Attributes
-
final Map< Integer, BrainFlowExitCode > brainflow::ec_map = new HashMap<Integer, BrainFlowExitCode> ()
-
int
-
class
brainflow::brainflow
::
BrainFlowInputParams
¶ to get fields which are required for your board check SupportedBoards section
Public Functions
-
BrainFlowInputParams
()¶
-
String
to_json
()¶
-
String
get_ip_address
()¶
-
void
set_ip_address
(String ip_address)¶
-
String
get_ip_address_aux
()¶
-
void
set_ip_address_aux
(String ip_address)¶
-
String
get_ip_address_anc
()¶
-
void
set_ip_address_anc
(String ip_address)¶
-
String
get_mac_address
()¶
-
void
set_mac_address
(String mac_address)¶
-
String
get_serial_port
()¶
-
void
set_serial_port
(String serial_port)¶
-
int
get_ip_port
()¶
-
void
set_ip_port
(int ip_port)¶
-
int
get_ip_port_aux
()¶
-
void
set_ip_port_aux
(int ip_port)¶
-
int
get_ip_port_anc
()¶
-
void
set_ip_port_anc
(int ip_port)¶
-
int
get_ip_protocol
()¶
-
void
set_ip_protocol
(int ip_protocol)¶
-
void
set_ip_protocol
(IpProtocolTypes ip_protocol)¶
-
String
get_other_info
()¶
-
void
set_other_info
(String other_info)¶
-
void
set_timeout
(int timeout)¶
-
int
get_timeout
()¶
-
String
get_serial_number
()¶
-
void
set_serial_number
(String serial_number)¶
-
String
get_file
()¶
-
void
set_file
(String file)¶
-
String
get_file_aux
()¶
-
void
set_file_aux
(String file)¶
-
String
get_file_anc
()¶
-
void
set_file_anc
(String file)¶
-
void
set_master_board
(int board)¶
-
int
get_master_board
()¶
Public Members
-
String
ip_address
¶
-
String
ip_address_aux
¶
-
String
ip_address_anc
¶
-
String
mac_address
¶
-
String
serial_port
¶
-
int
ip_port
¶
-
int
ip_port_aux
¶
-
int
ip_port_anc
¶
-
int
ip_protocol
¶
-
String
other_info
¶
-
int
timeout
¶
-
String
serial_number
¶
-
String
file
¶
-
String
file_aux
¶
-
String
file_anc
¶
-
int
master_board
¶
-
-
enum
BrainFlowMetrics
¶ Public Functions
-
int
get_code
()
-
brainflow::BrainFlowMetrics (final int code)
Public Members
-
brainflow::MINDFULNESS =(0)
-
brainflow::RESTFULNESS =(1)
-
brainflow::USER_DEFINED =(2)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
BrainFlowMetrics brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::protocol
Private Static Attributes
-
final Map< Integer, BrainFlowMetrics > brainflow::metr_map = new HashMap<Integer, BrainFlowMetrics> ()
-
int
-
class
brainflow::brainflow
::
BrainFlowModelParams
¶ describe model parameters
Public Functions
-
BrainFlowModelParams
(int metric, int classifier)¶
-
BrainFlowModelParams
(BrainFlowMetrics metric, BrainFlowClassifiers classifier)¶
-
int
get_metric
()¶
-
void
set_metric
(int metric)¶
-
void
set_metric
(BrainFlowMetrics metric)¶
-
int
get_classifier
()¶
-
void
set_classifier
(BrainFlowClassifiers classifier)¶
-
void
set_classifier
(int classifier)¶
-
String
get_file
()¶
-
void
set_file
(String file)¶
-
String
get_other_info
()¶
-
void
set_other_info
(String other_info)¶
-
String
get_output_name
()¶
-
void
set_output_name
(String output_name)¶
-
int
get_max_array_size
()¶
-
void
set_max_array_size
(int max_array_size)¶
-
String
to_json
()¶
-
-
enum
BrainFlowPresets
¶ enum to store all supported presets
Public Functions
-
int
get_code
()
-
brainflow::BrainFlowPresets (final int code)
Public Members
-
brainflow::DEFAULT_PRESET =(0)
-
brainflow::AUXILIARY_PRESET =(1)
-
brainflow::ANCILLARY_PRESET =(2)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
BrainFlowPresets brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::preset
Private Static Attributes
-
final Map< Integer, BrainFlowPresets > brainflow::my_map = new HashMap<Integer, BrainFlowPresets> ()
-
int
-
class
brainflow::brainflow
::
DataFilter
¶ DataFilter class to perform signal processing
Public Static Functions
-
void
enable_data_logger
()¶ enable Data logger with level INFO
-
String
get_version
()¶ Get version
-
void
enable_dev_data_logger
()¶ enable Data logger with level TRACE
-
void
disable_data_logger
()¶ disable Data logger
-
void
set_log_file
(String log_file)¶ redirect logger from stderr to a file
-
double calc_stddev (double[] data, int start_pos, int end_pos)
calc stddev
-
double get_oxygen_level (double[] ppg_ir, double[] ppg_red, int sampling_rate, double coef1, double coef2, double coef3)
get oxygen level
-
double get_oxygen_level (double[] ppg_ir, double[] ppg_red, int sampling_rate)
get oxygen level
-
double get_heart_rate (double[] ppg_ir, double[] ppg_red, int sampling_rate, int fft_size)
get heart rate
-
double get_railed_percentage (double[] data, int len, int gain)
get railed percentage
-
void
log_message
(int log_level, String message)¶ send user defined strings to BrainFlow logger
-
void
set_log_level
(int log_level)¶ set log level
-
void perform_lowpass (double[] data, int sampling_rate, double cutoff, int order, int filter_type, double ripple)
perform lowpass filter in-place
-
void perform_lowpass (double[] data, int sampling_rate, double cutoff, int order, FilterTypes filter_type, double ripple)
perform lowpass filter in-place
-
void perform_highpass (double[] data, int sampling_rate, double cutoff, int order, int filter_type, double ripple)
perform highpass filter in-place
-
void perform_highpass (double[] data, int sampling_rate, double cutoff, int order, FilterTypes filter_type, double ripple)
perform highpass filter in-place
-
void perform_bandpass (double[] data, int sampling_rate, double start_freq, double stop_freq, int order, int filter_type, double ripple)
perform bandpass filter in-place
-
void perform_bandpass (double[] data, int sampling_rate, double start_freq, double stop_freq, int order, FilterTypes filter_type, double ripple)
perform bandpass filter in-place
-
void perform_bandstop (double[] data, int sampling_rate, double start_freq, double stop_freq, int order, int filter_type, double ripple)
perform bandstop filter in-place
-
void perform_bandstop (double[] data, int sampling_rate, double start_freq, double stop_freq, int order, FilterTypes filter_type, double ripple)
perform bandstop filter in-place
-
void perform_rolling_filter (double[] data, int period, int operation)
perform moving average or moving median filter in-place
-
void perform_rolling_filter (double[] data, int period, AggOperations operation)
perform moving average or moving median filter in-place
-
void detrend (double[] data, int operation)
subtract trend from data in-place
-
void detrend (double[] data, DetrendOperations operation)
subtract trend from data in-place
-
double [] perform_downsampling (double[] data, int period, int operation)
perform data downsampling, it doesnt apply lowpass filter for you, it just aggregates several data points
-
double [] restore_data_from_wavelet_detailed_coeffs (double[] data, int wavelet, int decomposition_level, int level_to_restore)
restore data from a single wavelet coeff
-
double [] restore_data_from_wavelet_detailed_coeffs (double[] data, WaveletTypes wavelet, int decomposition_level, int level_to_restore)
restore data from a single wavelet coeff
-
double [] detect_peaks_z_score (double[] data, int lag, double threshold, double influence)
peak detection using z score algorithm
-
double [] perform_downsampling (double[] data, int period, AggOperations operation)
perform data downsampling, it doesnt apply lowpass filter for you, it just aggregates several data points
-
void remove_environmental_noise (double[] data, int sampling_rate, int noise_type)
removes noise using notch filter
-
void remove_environmental_noise (double[] data, int sampling_rate, NoiseTypes noise_type)
removes noise using notch filter
-
void perform_wavelet_denoising (double[] data, int wavelet, int decomposition_level, int wavelet_denoising, int threshold, int extenstion_type, int noise_level)
perform wavelet based denoising in-place
-
void perform_wavelet_denoising (double[] data, WaveletTypes wavelet, int decomposition_level, WaveletDenoisingTypes wavelet_denoising, ThresholdTypes threshold, WaveletExtensionTypes extenstion_type, NoiseEstimationLevelTypes noise_level)
perform wavelet based denoising in-place
-
Pair< double[], int[]> perform_wavelet_transform (double[] data, int wavelet, int decomposition_level, int extension)
perform wavelet transform
-
Pair< double[], int[]> perform_wavelet_transform (double[] data, WaveletTypes wavelet, int decomposition_level, WaveletExtensionTypes extension)
perform wavelet transform
-
double [] perform_inverse_wavelet_transform (Pair< double[], int[]> wavelet_output, int original_data_len, int wavelet, int decomposition_level, int extension)
perform inverse wavelet transform
-
double [] perform_inverse_wavelet_transform (Pair< double[], int[]> wavelet_output, int original_data_len, WaveletTypes wavelet, int decomposition_level, WaveletExtensionTypes extension)
perform inverse wavelet transform
-
Pair< double[][], double[]> get_csp (double[][][] data, double[] labels)
get common spatial filters
-
double [] get_window (int window, int window_len)
perform data windowing
- Return
array of the size specified in window_len
- Parameters
window
: window functionwindow_len
: lenght of the window function
-
double [] get_window (WindowOperations window, int window_len)
perform data windowing
- Return
array of the size specified in window_len
- Parameters
window
: window functionwindow_len
: lenght of the window function
-
Complex [] perform_fft (double[] data, int start_pos, int end_pos, int window)
perform direct fft
- Return
array of complex values with size N / 2 + 1
- Parameters
data
: data for fft transformstart_pos
: starting position to calc fftend_pos
: end position to calc fft, total_len must be evenwindow
: window function
-
Complex [] perform_fft (double[] data, int start_pos, int end_pos, WindowOperations window)
perform direct fft
- Return
array of complex values with size N / 2 + 1
- Parameters
data
: data for fft transformstart_pos
: starting position to calc fftend_pos
: end position to calc fft, total_len must be evenwindow
: window function
-
double [] perform_ifft (Complex[] data)
perform inverse fft
- Return
restored data
- Parameters
data
: data from fft transform(array of complex values)
-
Pair< double[], double[]> get_avg_band_powers (double[][] data, int[] channels, int sampling_rate, boolean apply_filters)
calc average and stddev of band powers across all channels
- Return
pair of avgs and stddevs for bandpowers
- Parameters
data
: data to processchannels
: rows of data arrays which should be used in calculationsampling_rate
: sampling rateapply_filters
: apply bandpass and bandstop filters before calculation
-
Pair< double[], double[]> get_custom_band_powers (double[][] data, List< Pair< Double, Double >> bands, int[] channels, int sampling_rate, boolean apply_filters)
calc average and stddev of band powers across all channels
- Return
pair of avgs and stddevs for bandpowers
- Parameters
data
: data to processbands
: bands to calculatechannels
: rows of data arrays which should be used in calculationsampling_rate
: sampling rateapply_filters
: apply bandpass and bandstop filters before calculation
-
List< double[][]> perform_ica (double[][] data, int num_components)
Calculates ICA
- Return
- Parameters
data
:num_components
:
- Exceptions
BrainFlowError
:
-
List< double[][]> perform_ica (double[][] data, int num_components, int[] channels)
calculates ICA
- Return
- Parameters
data
:num_components
:channels
:
- Exceptions
BrainFlowError
:
-
Pair< double[], double[]> get_psd (double[] data, int start_pos, int end_pos, int sampling_rate, int window)
get PSD
- Return
pair of ampl and freq arrays with len N / 2 + 1
- Parameters
data
: data to processstart_pos
: starting position to calc PSDend_pos
: end position to calc PSD, total_len must be evensampling_rate
: sampling ratewindow
: window function
-
Pair< double[], double[]> get_psd (double[] data, int start_pos, int end_pos, int sampling_rate, WindowOperations window)
get PSD
- Return
pair of ampl and freq arrays with len N / 2 + 1
- Parameters
data
: data to processstart_pos
: starting position to calc PSDend_pos
: end position to calc PSD, total_len must be evensampling_rate
: sampling ratewindow
: window function
-
Pair< double[], double[]> get_psd_welch (double[] data, int nfft, int overlap, int sampling_rate, int window)
get PSD using Welch Method
- Return
pair of ampl and freq arrays
- Parameters
data
: data to processnfft
: size of FFT, must be evenoverlap
: overlap between FFT Windows, must be between 0 and nfftsampling_rate
: sampling ratewindow
: window function
-
Pair< double[], double[]> get_psd_welch (double[] data, int nfft, int overlap, int sampling_rate, WindowOperations window)
get PSD using Welch Method
- Return
pair of ampl and freq arrays
- Parameters
data
: data to processnfft
: size of FFT, must be evenoverlap
: overlap between FFT Windows, must be between 0 and nfftsampling_rate
: sampling ratewindow
: window function
-
double
get_band_power
(Pair<double[], double[]> psd, double freq_start, double freq_end)¶ get band power
- Return
band power
- Parameters
psd
: PSD from get_psd or get_log_psdfreq_start
: lowest frequency of bandfreq_end
: highest frequency of band
-
int
get_nearest_power_of_two
(int value)¶ calculate nearest power of two
-
void write_file (double[][] data, String file_name, String file_mode)
write data to tsv file, in file data will be transposed
-
double [][] read_file (String file_name)
read data from file, transpose it back to original format
-
double [] reshape_data_to_1d (int num_rows, int num_cols, double[][] buf)
-
double [][] reshape_data_to_2d (int num_rows, int num_cols, double[] linear_buffer)
-
void
-
enum
DetrendOperations
¶ enum to store all supported detrend operations
Public Functions
-
int
get_code
()
-
brainflow::DetrendOperations (final int code)
Public Members
-
brainflow::NO_DETREND =(0)
-
brainflow::CONSTANT =(1)
-
brainflow::LINEAR =(2)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
DetrendOperations brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::detrend_operation
Private Static Attributes
-
final Map< Integer, DetrendOperations > brainflow::dt_map = new HashMap<Integer, DetrendOperations> ()
-
int
-
enum
FilterTypes
¶ enum to store all possible filter types
Public Functions
-
int
get_code
()
-
brainflow::FilterTypes (final int code)
Public Members
-
brainflow::BUTTERWORTH =(0)
-
brainflow::CHEBYSHEV_TYPE_1 =(1)
-
brainflow::BESSEL =(2)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
FilterTypes brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::filter_type
Private Static Attributes
-
final Map< Integer, FilterTypes > brainflow::ft_map = new HashMap<Integer, FilterTypes> ()
-
int
-
enum
IpProtocolTypes
¶ Public Functions
-
int
get_code
()
-
brainflow::IpProtocolTypes (final int code)
Public Members
-
brainflow::NO_IP_PROTOCOL =(0)
-
brainflow::UDP =(1)
-
brainflow::TCP =(2)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
IpProtocolTypes brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::protocol
Private Static Attributes
-
final Map< Integer, IpProtocolTypes > brainflow::ip_map = new HashMap<Integer, IpProtocolTypes> ()
-
int
-
enum
LogLevels
¶ Public Functions
-
int
get_code
()
-
brainflow::LogLevels (final int code)
Public Members
-
brainflow::LEVEL_TRACE =(0)
-
brainflow::LEVEL_DEBUG =(1)
-
brainflow::LEVEL_INFO =(2)
-
brainflow::LEVEL_WARN =(3)
-
brainflow::LEVEL_ERROR =(4)
-
brainflow::LEVEL_CRITICAL =(5)
-
brainflow::LEVEL_OFF =(6)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
LogLevels brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::log_level
Private Static Attributes
-
final Map< Integer, LogLevels > brainflow::ll_map = new HashMap<Integer, LogLevels> ()
-
int
-
class
brainflow::brainflow
::
MLModel
¶ Public Functions
-
MLModel
(BrainFlowModelParams params)¶ Create MLModel object
-
void
prepare
()¶ Prepare classifier
- Exceptions
BrainFlowError
:
-
void
release
()¶ Release classifier
- Exceptions
BrainFlowError
:
-
double [] predict (double[] data)
Get score of classifier
- Exceptions
BrainFlowError
:
Public Static Functions
-
void
enable_ml_logger
()¶ enable ML logger with level INFO
-
void
enable_dev_ml_logger
()¶ enable ML logger with level TRACE
-
void
disable_ml_logger
()¶ disable BrainFlow logger
-
void
set_log_file
(String log_file)¶ redirect logger from stderr to a file
-
String
get_version
()¶ Get version
-
void
release_all
()¶ release all classifiers
-
void
log_message
(int log_level, String message)¶ send user defined strings to BrainFlow logger
-
void
set_log_level
(int log_level)¶ set log level
-
-
enum
NoiseEstimationLevelTypes
¶ enum to store all possible Noise Level Types
Public Functions
-
int
get_code
()
-
brainflow::NoiseEstimationLevelTypes (final int code)
Public Members
-
brainflow::FIRST_LEVEL =(0)
-
brainflow::ALL_LEVELS =(1)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
NoiseEstimationLevelTypes brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::value
Private Static Attributes
-
final Map< Integer, NoiseEstimationLevelTypes > brainflow::map = new HashMap<Integer, NoiseEstimationLevelTypes> ()
-
int
-
enum
NoiseTypes
¶ enum to store all supported noise types
Public Functions
-
int
get_code
()
-
brainflow::NoiseTypes (final int code)
Public Members
-
brainflow::FIFTY =(0)
-
brainflow::SIXTY =(1)
-
brainflow::FIFTY_AND_SIXTY =(2)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
NoiseTypes brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::noise_type
Private Static Attributes
-
final Map< Integer, NoiseTypes > brainflow::nt_map = new HashMap<Integer, NoiseTypes> ()
-
int
-
enum
ThresholdTypes
¶ enum to store all possible Threshold Types
Public Functions
-
int
get_code
()
-
brainflow::ThresholdTypes (final int code)
Public Members
-
brainflow::SOFT =(0)
-
brainflow::HARD =(1)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
ThresholdTypes brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::value
Private Static Attributes
-
final Map< Integer, ThresholdTypes > brainflow::map = new HashMap<Integer, ThresholdTypes> ()
-
int
-
enum
WaveletDenoisingTypes
¶ enum to store all possible Wavelet Denoising Types
Public Functions
-
int
get_code
()
-
brainflow::WaveletDenoisingTypes (final int code)
Public Members
-
brainflow::VISUSHRINK =(0)
-
brainflow::SURESHRINK =(1)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
WaveletDenoisingTypes brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::value
Private Static Attributes
-
final Map< Integer, WaveletDenoisingTypes > brainflow::map = new HashMap<Integer, WaveletDenoisingTypes> ()
-
int
-
enum
WaveletExtensionTypes
¶ enum to store all possible Wavelet Extenstion Types
Public Functions
-
int
get_code
()
-
brainflow::WaveletExtensionTypes (final int code)
Public Members
-
brainflow::SYMMETRIC =(0)
-
brainflow::PERIODIC =(1)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
WaveletExtensionTypes brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::value
Private Static Attributes
-
final Map< Integer, WaveletExtensionTypes > brainflow::map = new HashMap<Integer, WaveletExtensionTypes> ()
-
int
-
enum
WaveletTypes
¶ enum to store all possible Wavelet Types
Public Functions
-
int
get_code
()
-
brainflow::WaveletTypes (final int code)
Public Members
-
brainflow::HAAR =(0)
-
brainflow::DB1 =(1)
-
brainflow::DB2 =(2)
-
brainflow::DB3 =(3)
-
brainflow::DB4 =(4)
-
brainflow::DB5 =(5)
-
brainflow::DB6 =(6)
-
brainflow::DB7 =(7)
-
brainflow::DB8 =(8)
-
brainflow::DB9 =(9)
-
brainflow::DB10 =(10)
-
brainflow::DB11 =(11)
-
brainflow::DB12 =(12)
-
brainflow::DB13 =(13)
-
brainflow::DB14 =(14)
-
brainflow::DB15 =(15)
-
brainflow::BIOR1_1 =(16)
-
brainflow::BIOR1_3 =(17)
-
brainflow::BIOR1_5 =(18)
-
brainflow::BIOR2_2 =(19)
-
brainflow::BIOR2_4 =(20)
-
brainflow::BIOR2_6 =(21)
-
brainflow::BIOR2_8 =(22)
-
brainflow::BIOR3_1 =(23)
-
brainflow::BIOR3_3 =(24)
-
brainflow::BIOR3_5 =(25)
-
brainflow::BIOR3_7 =(26)
-
brainflow::BIOR3_9 =(27)
-
brainflow::BIOR4_4 =(28)
-
brainflow::BIOR5_5 =(29)
-
brainflow::BIOR6_8 =(30)
-
brainflow::COIF1 =(31)
-
brainflow::COIF2 =(32)
-
brainflow::COIF3 =(33)
-
brainflow::COIF4 =(34)
-
brainflow::COIF5 =(35)
-
brainflow::SYM2 =(36)
-
brainflow::SYM3 =(37)
-
brainflow::SYM4 =(38)
-
brainflow::SYM5 =(39)
-
brainflow::SYM6 =(40)
-
brainflow::SYM7 =(41)
-
brainflow::SYM8 =(42)
-
brainflow::SYM9 =(43)
-
brainflow::SYM10 =(44)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
WaveletTypes brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::value
Private Static Attributes
-
final Map< Integer, WaveletTypes > brainflow::map = new HashMap<Integer, WaveletTypes> ()
-
int
-
enum
WindowOperations
¶ Public Functions
-
int
get_code
()
-
brainflow::WindowOperations (final int code)
Public Members
-
brainflow::NO_WINDOW =(0)
-
brainflow::HANNING =(1)
-
brainflow::HAMMING =(2)
-
brainflow::BLACKMAN_HARRIS =(3)
Public Static Functions
-
String brainflow::string_from_code (final int code)
-
WindowOperations brainflow::from_code (final int code)
-
brainflow::[static initializer]
Private Members
-
final int brainflow::window
Private Static Attributes
-
final Map< Integer, WindowOperations > brainflow::window_map = new HashMap<Integer, WindowOperations> ()
-
int
C# API Reference¶
Content of brainflow namespace:
-
enum
brainflow
::
LogLevels
Values:
-
enumerator
LEVEL_TRACE
= 0¶
-
enumerator
LEVEL_DEBUG
= 1¶
-
enumerator
LEVEL_INFO
= 2¶
-
enumerator
LEVEL_WARN
= 3¶
-
enumerator
LEVEL_ERROR
= 4¶
-
enumerator
LEVEL_CRITICAL
= 5¶
-
enumerator
LEVEL_OFF
= 6¶
-
enumerator
-
enum
brainflow
::
IpProtocolTypes
Values:
-
enumerator
NO_IP_PROTOCOL
= 0¶
-
enumerator
UDP
= 1¶
-
enumerator
TCP
= 2¶
-
enumerator
-
enum
brainflow
::
BrainFlowPresets
Values:
-
enumerator
DEFAULT_PRESET
= 0¶
-
enumerator
AUXILIARY_PRESET
= 1¶
-
enumerator
ANCILLARY_PRESET
= 2¶
-
enumerator
-
enum
brainflow
::
BrainFlowExitCodes
¶ Values:
-
enumerator
STATUS_OK
= 0¶
-
enumerator
PORT_ALREADY_OPEN_ERROR
= 1¶
-
enumerator
UNABLE_TO_OPEN_PORT_ERROR
= 2¶
-
enumerator
SET_PORT_ERROR
= 3¶
-
enumerator
BOARD_WRITE_ERROR
= 4¶
-
enumerator
INCOMMING_MSG_ERROR
= 5¶
-
enumerator
INITIAL_MSG_ERROR
= 6¶
-
enumerator
BOARD_NOT_READY_ERROR
= 7¶
-
enumerator
STREAM_ALREADY_RUN_ERROR
= 8¶
-
enumerator
INVALID_BUFFER_SIZE_ERROR
= 9¶
-
enumerator
STREAM_THREAD_ERROR
= 10¶
-
enumerator
STREAM_THREAD_IS_NOT_RUNNING
= 11¶
-
enumerator
EMPTY_BUFFER_ERROR
= 12¶
-
enumerator
INVALID_ARGUMENTS_ERROR
= 13¶
-
enumerator
UNSUPPORTED_BOARD_ERROR
= 14¶
-
enumerator
BOARD_NOT_CREATED_ERROR
= 15¶
-
enumerator
ANOTHER_BOARD_IS_CREATED_ERROR
= 16¶
-
enumerator
GENERAL_ERROR
= 17¶
-
enumerator
SYNC_TIMEOUT_ERROR
= 18¶
-
enumerator
JSON_NOT_FOUND_ERROR
= 19¶
-
enumerator
NO_SUCH_DATA_IN_JSON_ERROR
= 20¶
-
enumerator
CLASSIFIER_IS_NOT_PREPARED_ERROR
= 21¶
-
enumerator
ANOTHER_CLASSIFIER_IS_PREPARED_ERROR
= 22¶
-
enumerator
UNSUPPORTED_CLASSIFIER_AND_METRIC_COMBINATION_ERROR
= 23¶
-
enumerator
-
enum
brainflow
::
BoardIds
Values:
-
enumerator
NO_BOARD
= -100¶
-
enumerator
PLAYBACK_FILE_BOARD
= -3¶
-
enumerator
STREAMING_BOARD
= -2¶
-
enumerator
SYNTHETIC_BOARD
= -1¶
-
enumerator
CYTON_BOARD
= 0¶
-
enumerator
GANGLION_BOARD
= 1¶
-
enumerator
CYTON_DAISY_BOARD
= 2¶
-
enumerator
GALEA_BOARD
= 3¶
-
enumerator
GANGLION_WIFI_BOARD
= 4¶
-
enumerator
CYTON_WIFI_BOARD
= 5¶
-
enumerator
CYTON_DAISY_WIFI_BOARD
= 6¶
-
enumerator
BRAINBIT_BOARD
= 7¶
-
enumerator
UNICORN_BOARD
= 8¶
-
enumerator
CALLIBRI_EEG_BOARD
= 9¶
-
enumerator
CALLIBRI_EMG_BOARD
= 10¶
-
enumerator
CALLIBRI_ECG_BOARD
= 11¶
-
enumerator
NOTION_1_BOARD
= 13¶
-
enumerator
NOTION_2_BOARD
= 14¶
-
enumerator
GFORCE_PRO_BOARD
= 16¶
-
enumerator
FREEEEG32_BOARD
= 17¶
-
enumerator
BRAINBIT_BLED_BOARD
= 18¶
-
enumerator
GFORCE_DUAL_BOARD
= 19¶
-
enumerator
GALEA_SERIAL_BOARD
= 20¶
-
enumerator
MUSE_S_BLED_BOARD
= 21¶
-
enumerator
MUSE_2_BLED_BOARD
= 22¶
-
enumerator
CROWN_BOARD
= 23¶
-
enumerator
ANT_NEURO_EE_410_BOARD
= 24¶
-
enumerator
ANT_NEURO_EE_411_BOARD
= 25¶
-
enumerator
ANT_NEURO_EE_430_BOARD
= 26¶
-
enumerator
ANT_NEURO_EE_211_BOARD
= 27¶
-
enumerator
ANT_NEURO_EE_212_BOARD
= 28¶
-
enumerator
ANT_NEURO_EE_213_BOARD
= 29¶
-
enumerator
ANT_NEURO_EE_214_BOARD
= 30¶
-
enumerator
ANT_NEURO_EE_215_BOARD
= 31¶
-
enumerator
ANT_NEURO_EE_221_BOARD
= 32¶
-
enumerator
ANT_NEURO_EE_222_BOARD
= 33¶
-
enumerator
ANT_NEURO_EE_223_BOARD
= 34¶
-
enumerator
ANT_NEURO_EE_224_BOARD
= 35¶
-
enumerator
ANT_NEURO_EE_225_BOARD
= 36¶
-
enumerator
ENOPHONE_BOARD
= 37¶
-
enumerator
MUSE_2_BOARD
= 38¶
-
enumerator
MUSE_S_BOARD
= 39¶
-
enumerator
MUSE_2016_BOARD
= 41¶
-
enumerator
MUSE_2016_BLED_BOARD
= 42¶
-
enumerator
EXPLORE_4_CHAN_BOARD
= 44¶
-
enumerator
EXPLORE_8_CHAN_BOARD
= 45¶
-
enumerator
GANGLION_NATIVE_BOARD
= 46¶
-
enumerator
EMOTIBIT_BOARD
= 47¶
-
enumerator
-
enum
brainflow
::
FilterTypes
Values:
-
enumerator
BUTTERWORTH
= 0¶
-
enumerator
CHEBYSHEV_TYPE_1
= 1¶
-
enumerator
BESSEL
= 2¶
-
enumerator
-
enum
brainflow
::
AggOperations
Values:
-
enumerator
MEAN
= 0¶
-
enumerator
MEDIAN
= 1¶
-
enumerator
EACH
= 2¶
-
enumerator
-
enum
brainflow
::
WindowOperations
Values:
-
enumerator
NO_WINDOW
= 0¶
-
enumerator
HANNING
= 1¶
-
enumerator
HAMMING
= 2¶
-
enumerator
BLACKMAN_HARRIS
= 3¶
-
enumerator
-
enum
brainflow
::
DetrendOperations
Values:
-
enumerator
NO_DETREND
= 0¶
-
enumerator
CONSTANT
= 1¶
-
enumerator
LINEAR
= 2¶
-
enumerator
-
enum
brainflow
::
NoiseTypes
Values:
-
enumerator
FIFTY
= 0¶
-
enumerator
SIXTY
= 1¶
-
enumerator
FIFTY_AND_SIXTY
= 2¶
-
enumerator
-
enum
brainflow
::
NoiseEstimationLevelTypes
Values:
-
enumerator
FIRST_LEVEL
= 0¶
-
enumerator
ALL_LEVELS
= 1¶
-
enumerator
-
enum
brainflow
::
WaveletTypes
Values:
-
enumerator
HAAR
= 0¶
-
enumerator
DB1
= 1¶
-
enumerator
DB2
= 2¶
-
enumerator
DB3
= 3¶
-
enumerator
DB4
= 4¶
-
enumerator
DB5
= 5¶
-
enumerator
DB6
= 6¶
-
enumerator
DB7
= 7¶
-
enumerator
DB8
= 8¶
-
enumerator
DB9
= 9¶
-
enumerator
DB10
= 10¶
-
enumerator
DB11
= 11¶
-
enumerator
DB12
= 12¶
-
enumerator
DB13
= 13¶
-
enumerator
DB14
= 14¶
-
enumerator
DB15
= 15¶
-
enumerator
BIOR1_1
= 16¶
-
enumerator
BIOR1_3
= 17¶
-
enumerator
BIOR1_5
= 18¶
-
enumerator
BIOR2_2
= 19¶
-
enumerator
BIOR2_4
= 20¶
-
enumerator
BIOR2_6
= 21¶
-
enumerator
BIOR2_8
= 22¶
-
enumerator
BIOR3_1
= 23¶
-
enumerator
BIOR3_3
= 24¶
-
enumerator
BIOR3_5
= 25¶
-
enumerator
BIOR3_7
= 26¶
-
enumerator
BIOR3_9
= 27¶
-
enumerator
BIOR4_4
= 28¶
-
enumerator
BIOR5_5
= 29¶
-
enumerator
BIOR6_8
= 30¶
-
enumerator
COIF1
= 31¶
-
enumerator
COIF2
= 32¶
-
enumerator
COIF3
= 33¶
-
enumerator
COIF4
= 34¶
-
enumerator
COIF5
= 35¶
-
enumerator
SYM2
= 36¶
-
enumerator
SYM3
= 37¶
-
enumerator
SYM4
= 38¶
-
enumerator
SYM5
= 39¶
-
enumerator
SYM6
= 40¶
-
enumerator
SYM7
= 41¶
-
enumerator
SYM8
= 42¶
-
enumerator
SYM9
= 43¶
-
enumerator
SYM10
= 44¶
-
enumerator
-
enum
brainflow
::
BrainFlowMetrics
Values:
-
enumerator
MINDFULNESS
= 0¶
-
enumerator
RESTFULNESS
= 1¶
-
enumerator
USER_DEFINED
= 2¶
-
enumerator
-
enum
brainflow
::
BrainFlowClassifiers
Values:
-
enumerator
DEFAULT_CLASSIFIER
= 0¶
-
enumerator
DYN_LIB_CLASSIFIER
= 1¶
-
enumerator
ONNX_CLASSIFIER
= 2¶
-
enumerator
-
class
brainflow::brainflow
::
BoardDescr
Public Functions
-
BoardDescr
()
Public Members
-
int
sampling_rate
-
int [] eeg_channels
-
int [] eog_channels
-
int [] exg_channels
-
int [] emg_channels
-
int [] ppg_channels
-
int [] eda_channels
-
int [] accel_channels
-
int [] gyro_channels
-
int [] temperature_channels
-
int [] resistance_channels
-
int [] other_channels
-
int
package_num_channel
-
int
batter_channel
-
int
timestamp_channel
-
int
marker_channel
-
int
num_rows
-
string
name
-
string
eeg_names
-
-
class
brainflow::brainflow
::
BoardShim
BoardShim class to communicate with a board
Public Functions
-
BoardShim
(int board_id, BrainFlowInputParams input_params) Create an instance of BoardShim class
- Parameters
board_id
input_params
-
void
prepare_session
() prepare BrainFlow’s streaming session, allocate required resources
-
string
config_board
(string config)¶ send string to a board, use this method carefully and only if you understand what you are doing
- Parameters
config
-
void
add_streamer
(string streamer_params, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ add streamer
- Parameters
streamer_params
: supoprted formats file://filename:w file://filename:a streaming_board://ip:port
-
void
delete_streamer
(string streamer_params, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ delete streamer
- Parameters
streamer_params
: supoprted formats file://filename:w file://filename:a streaming_board://ip:port
-
void
insert_marker
(double value, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ insert marker to data array
-
void
start_stream
(int buffer_size = 3600 * 250, string streamer_params = "")¶ start streaming thread, store data in internal ringbuffer
- Parameters
buffer_size
: size of internal ringbufferstreamer_params
: supported values: file://%file_name%:w, file://%file_name%:a, streaming_board://multicast_group_ip%:port%
-
void
stop_stream
() stop streaming thread, doesnt release other resources
-
void
release_session
() release BrainFlow’s session
-
bool
is_prepared
() check session status
summary> Get Board Id, for some boards can be different than provided /summary>
- Return
session status
- Return
Master board id
-
int
get_board_id
() summary> Get input params /summary>
- Return
input params
-
BrainFlowInputParams
get_input_params
()¶
-
int
get_board_data_count
(int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ get number of packages in ringbuffer
- Return
number of packages
- Parameters
preset
: preset for device
-
double [,] get_current_board_data (int num_samples, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get latest collected data, doesnt remove it from ringbuffer
- Return
latest collected data, can be less than “num_samples”
- Parameters
num_samples
preset
: preset for device
-
double [,] get_current_board_data (double[,] result, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get latest collected data, doesnt remove it from ringbuffer
- Return
latest collected data, can be less than “num_samples”
- Parameters
preset
: preset for deviceresult
: array to store results, if provided BrainFlow does not allocate new memory
-
double [,] get_board_data ()
get all collected data and remove it from ringbuffer
- Return
collected data
-
double [,] get_board_data (int num_datapoints)
get collected data and remove it from ringbuffer
- Return
collected data
-
double [,] get_board_data (int num_datapoints, int preset)
get collected data and remove it from ringbuffer
- Return
all collected data
- Parameters
num_datapoints
: number of datapoints to getpreset
: preset for device
-
double [,] get_board_data (double[,] data_arr, int preset)
get collected data and remove it from ringbuffer
- Return
all collected data
- Parameters
data_arr
: array to store results, if provided BrainFlow will not allocate memorypreset
: preset for device
Public Static Functions
-
void
release_all_sessions
() release all sessions
-
int
get_sampling_rate
(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ get sampling rate for this board id
- Return
sampling rate
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int
get_package_num_channel
(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ get row index in returned by get_board_data() 2d array which holds package nums
- Return
row num in 2d array
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int
get_timestamp_channel
(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ get row index which holds timestamps
- Return
row num in 2d array
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int
get_marker_channel
(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ get row index which holds marker
- Return
row num in 2d array
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int
get_battery_channel
(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ get row undex which holds battery level
- Return
row num in 2d array
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int
get_num_rows
(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ get number of rows in returned by get_board_data() 2d array
- Return
number of rows in 2d array
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
string [] get_eeg_names (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get names of EEG channels in 10-20 system. Only if electrodes have fixed locations
- Return
array of 10-20 locations
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_board_presets (int board_id)
get presets for selected device
- Return
array of strings
- Parameters
board_id
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
template<>
Tget_board_descr
<T>(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ get board description
- Return
board description
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If board id is not valid exit code is UNSUPPORTED_BOARD_ERROR
-
string
get_device_name
(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ get device name
- Return
device name
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
string
get_version
() get version
- Return
version
- Exceptions
BrainFlowException
-
int [] get_eeg_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices of EEG channels for this board, for some board we can not split EMG.. data and return the same array for all of them
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_emg_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices of EMG channels for this board, for some board we can not split EMG.. data and return the same array for all of them
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_ecg_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices of ECG channels for this board, for some board we can not split EMG.. data and return the same array for all of them
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_eog_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices of EOG channels for this board, for some board we can not split EMG.. data and return the same array for all of them
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_exg_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices of EXG channels for this board
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_eda_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices of EDA channels for this board, for some board we can not split EMG.. data and return the same array for all of them
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_ppg_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indeces which hold ppg data
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_accel_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices which hold accel data
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_analog_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices which hold analog data
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_gyro_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices which hold gyro data
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_other_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get other channels for this board
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_temperature_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get temperature channels for this board
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_resistance_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get resistance channels for this board
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
int [] get_magnetometer_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get magnetometer channels for this board
- Return
array of row nums
- Parameters
board_id
preset
: preset for device
- Exceptions
BrainFlowException
: If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
void
set_log_level
(int log_level) set log level, logger is disabled by default
- Parameters
log_level
-
void
enable_board_logger
() enable BrainFlow’s logger with level INFO
-
void
disable_board_logger
() disable BrainFlow’s logger
-
void
enable_dev_board_logger
() enable BrainFLow’s logger with level TRACE
-
void
set_log_file
(string log_file)¶ redirect BrainFlow’s logger from stderr to file
- Parameters
log_file
-
void
log_message
(int log_level, string message)¶ send your own log message to BrainFlow’s logger
- Parameters
log_level
message
-
-
class
brainflow::brainflow
::
BrainFlowError
: public Exception BrainFlowError class to notify about errors
Public Functions
-
BrainFlowError
(int code)¶
Public Members
-
int
exit_code
exit code returned from low level API
-
-
class
brainflow::brainflow
::
BrainFlowInputParams
Check SuportedBoards to get information about fields which are required for specific board
Public Functions
-
BrainFlowInputParams
()
-
string
to_json
()
Public Members
-
string
serial_port
serial port name
-
string
mac_address
MAC address
-
string
ip_address
IP address
-
string
ip_address_aux
IP address aux
-
string
ip_address_anc
IP address anc
-
int
ip_port
PORT
-
int
ip_port_aux
PORT
-
int
ip_port_anc
PORT
-
int
ip_protocol
IP protocol, use IpProtocolTypes
-
string
other_info
you can provide additional info to low level API using this field
-
int
timeout
timeout for device discovery or connection
-
string
serial_number
serial number
-
string
file
file
-
string
file_aux
file
-
string
file_anc
file
-
int
master_board
Master board, use BoardIds enums
-
-
class
brainflow::brainflow
::
BrainFlowModelParams
Describe model
Public Functions
-
BrainFlowModelParams
(int metric, int classifier)
-
string
to_json
()
Public Members
-
int
metric
metric to caclulate
-
int
classifier
classifier to use
-
string
file
path to model file
-
string
other_info
other info
-
string
output_name
output name
-
int
max_array_size
max array size
-
-
class
brainflow::brainflow
::
DataFilter
DataFilter class to perform signal processing
Public Static Functions
-
void
set_log_level
(int log_level) set log level, logger is disabled by default
- Parameters
log_level
-
void
enable_data_logger
() enable Data logger with level INFO
-
void
log_message
(int log_level, string message)¶ send your own log message to BrainFlow’s logger
- Parameters
log_level
message
-
void
disable_data_logger
() disable Data logger
-
void
enable_dev_data_logger
() enable Data logger with level TRACE
-
void
set_log_file
(string log_file)¶ redirect BrainFlow’s logger from stderr to file
- Parameters
log_file
-
double [] perform_lowpass (double[] data, int sampling_rate, double cutoff, int order, int filter_type, double ripple)
perform lowpass filter, unlike other bindings instead in-place calculation it returns new array
- Return
filtered data
- Parameters
data
sampling_rate
cutoff
order
filter_type
ripple
-
double [] remove_environmental_noise (double[] data, int sampling_rate, int noise_type)
remove env noise using notch filter
- Return
filtered data
- Parameters
data
sampling_rate
noise_type
-
double [] perform_highpass (double[] data, int sampling_rate, double cutoff, int order, int filter_type, double ripple)
perform highpass filter, unlike other bindings instead in-place calculation it returns new array
- Return
filtered data
- Parameters
data
sampling_rate
cutoff
order
filter_type
ripple
-
double [] perform_bandpass (double[] data, int sampling_rate, double start_freq, double stop_freq, int order, int filter_type, double ripple)
perform bandpass filter, unlike other bindings instead in-place calculation it returns new array
- Return
filtered data
- Parameters
data
sampling_rate
start_freq
stop_freq
order
filter_type
ripple
-
double [] perform_bandstop (double[] data, int sampling_rate, double start_freq, double stop_freq, int order, int filter_type, double ripple)
perform bandstop filter, unlike other bindings instead in-place calculation it returns new array
- Return
filtered data
- Parameters
data
sampling_rate
start_freq
stop_freq
order
filter_type
ripple
-
double [] perform_rolling_filter (double[] data, int period, int operation)
perform moving average or moving median filter, unlike other bindings instead in-place calculation it returns new array
- Return
filered data
- Parameters
data
period
operation
-
double [] detrend (double[] data, int operation)
detrend, unlike other bindings instead in-place calculation it returns new array
- Return
data with removed trend
- Parameters
data
operation
-
double [] perform_downsampling (double[] data, int period, int operation)
perform data downsampling, it just aggregates data without applying lowpass filter
- Return
data after downsampling
- Parameters
data
period
operation
-
double [] detect_peaks_z_score (double[] data, int lag, double threshold, double influence)
detect peaks using z score algorithm
-
double calc_stddev (double[] data, int start_pos, int end_pos)
calc stddev
///
- Return
stddev
- Parameters
data
start_pos
- Parameters
end_pos
-
double get_railed_percentage (double[] data, int gain)
get railed percentage
- Return
railed
- Parameters
data
gain
-
double get_oxygen_level (double[] ppg_ir, double[] ppg_red, int sampling_rate, double coef1=0.0, double coef2=-37.663, double coef3=114.91)
calc oxygen level from ppg values
///
- Return
stddev
- Parameters
coef1
: appxorimation coef for power of 2coef2
: approximation coef
- Parameters
coef3
: intercept for approximation
-
double get_heart_rate (double[] ppg_ir, double[] ppg_red, int sampling_rate, int fft_size)
calc heart rate
- Return
stddev
- Parameters
fft_size
: recommended 8192
-
Tuple< double[], int[]> perform_wavelet_transform (double[] data, int wavelet, int decomposition_level, int extension)
perform wavelet transform
- Return
tuple of wavelet coeffs in format [A(J) D(J) D(J-1) ….. D(1)] where J is decomposition level, A - app coeffs, D - detailed coeffs, and array with lengths for each block
- Parameters
data
: data for wavelet transformwavelet
: use WaveletTypes enumextension
: use WaveletExtensionTypes enumdecomposition_level
: decomposition level
-
double [] perform_inverse_wavelet_transform (Tuple< double[], int[]> wavelet_data, int original_data_len, int wavelet, int decomposition_level, int extension)
perform inverse wavelet transorm
- Return
restored data
- Parameters
wavelet_data
: tuple returned by perform_wavelet_transformoriginal_data_len
: size of original data before direct wavelet transformwavelet
: use WaveletTypes enumdecomposition_level
: level of decompositionextension
: use WaveletExtensionTypes enum
-
double [] perform_wavelet_denoising (double[] data, int wavelet, int decomposition_level, int wavelet_denoising=(int) WaveletDenoisingTypes.SURESHRINK, int threshold=(int) ThresholdTypes.HARD, int extenstion_type=(int) WaveletExtensionTypes.SYMMETRIC, int noise_level=(int) NoiseEstimationLevelTypes.FIRST_LEVEL)
perform wavelet based denoising
- Return
denoised data
- Parameters
data
: data for denoisingwavelet
: use WaveletTypes enumdecomposition_level
: level of decomposition in wavelet transformextenstion_type
: use WaveletExtensionTypes enumnoise_level
: use NoiseEstimationLevelTypes enumthreshold
: use ThresholdTypes enumwavelet_denoising
: use WaveletDenoisingTypes enum
-
Tuple< double[,], double[]> get_csp (double[,,] data, double[] labels)
get common spatial patterns
- Return
Tuple of two arrays: [n_channels x n_channels] shaped array of filters and n_channels length array of eigenvalues
- Parameters
data
: data for csplabels
: labels for each class
-
double [] get_window (int window_function, int window_len)
perform windowing
- Return
array of the size specified in window_len
- Parameters
window_function
: window functionwindow_len
: len of the window
-
Complex [] perform_fft (double[] data, int start_pos, int end_pos, int window)
perform direct fft
- Return
complex array of size N / 2 + 1 of fft data
- Parameters
data
: data for fftstart_pos
: start posend_pos
: end pos, end_pos - start_pos must be evenwindow
: window function
-
double [] perform_ifft (Complex[] data)
perform inverse fft
- Return
restored data
- Parameters
data
: data from perform_fft
-
void write_file (double[,] data, string file_name, string file_mode)
write data to tsv file, data will be transposed
- Parameters
data
file_name
file_mode
-
double [,] read_file (string file_name)
read data from file, data will be transposed back to original format
- Return
- Parameters
file_name
-
int
get_nearest_power_of_two
(int value) calculate nearest power of two
- Return
nearest power of two
- Parameters
value
-
Tuple< double[], double[]> get_custom_band_powers (double[,] data, Tuple< double, double >[] bands, int[] channels, int sampling_rate, bool apply_filters)
calculate avg and stddev bandpowers across channels
- Return
Tuple of avgs and stddev arrays
- Parameters
data
: 2d array with valuesbands
: bands to calculatechannels
: rows of data array which should be used for calculationsampling_rate
: sampling rateapply_filters
: apply bandpass and bandstop filters before calculation
-
Tuple< double[,], double[,], double[,], double[,]> perform_ica (double[,] data, int num_components)
Calculate ICA
- Return
- Parameters
data
num_components
-
Tuple< double[,], double[,], double[,], double[,]> perform_ica (double[,] data, int num_components, int[] channels)
Calculate ICA
- Return
- Parameters
data
num_components
channels
-
Tuple< double[], double[]> get_avg_band_powers (double[,] data, int[] channels, int sampling_rate, bool apply_filters)
calculate avg and stddev bandpowers across channels
- Return
Tuple of avgs and stddev arrays
- Parameters
data
: 2d array with valueschannels
: rows of data array which should be used for calculationsampling_rate
: sampling rateapply_filters
: apply bandpass and bandstop filters before calculation
-
Tuple< double[], double[]> get_psd (double[] data, int start_pos, int end_pos, int sampling_rate, int window)
calculate PSD
- Return
Tuple of ampls and freqs arrays of size N / 2 + 1
- Parameters
data
: data for PSDstart_pos
: start posend_pos
: end pos, end_pos - start_pos must be evensampling_rate
: sampling ratewindow
: window function
-
Tuple< double[], double[]> get_psd_welch (double[] data, int nfft, int overlap, int sampling_rate, int window)
calculate PSD using Welch method
- Return
Tuple of ampls and freqs arrays
- Parameters
data
: data for log PSDnfft
: FFT Sizeoverlap
: FFT Window overlap, must be between 0 and nfftsampling_rate
: sampling ratewindow
: window function
-
double
get_band_power
(Tuple<double[], double[]> psd, double start_freq, double stop_freq)¶ calculate band power
- Return
band power
- Parameters
psd
: psd data returned by get_psd or get_psd_welchstart_freq
: lowest frequency of bandstop_freq
: highest frequency of band
-
string
get_version
() get version
- Return
version
- Exceptions
BrainFlowException
-
unsafe void perform_lowpass (double[,] data, int row_num, int sampling_rate, double cutoff, int order, int filter_type, double ripple)
perform lowpass filter for specified row number in-place
- Parameters
data
row_num
sampling_rate
cutoff
order
filter_type
ripple
-
unsafe void remove_environmental_noise (double[,] data, int row_num, int sampling_rate, int noise_type)
remove env noise using notch filter in-place
- Parameters
data
row_num
sampling_rate
noise_type
-
unsafe void perform_highpass (double[,] data, int row_num, int sampling_rate, double cutoff, int order, int filter_type, double ripple)
perform highpass filter in-place
- Parameters
data
sampling_rate
cutoff
order
filter_type
ripple
-
unsafe void perform_bandpass (double[,] data, int row_num, int sampling_rate, double start_freq, double stop_freq, int order, int filter_type, double ripple)
perform bandpass filter in-place
- Parameters
data
row_num
sampling_rate
start_freq
stop_freq
order
filter_type
ripple
-
unsafe void perform_bandstop (double[,] data, int row_num, int sampling_rate, double start_freq, double stop_freq, int order, int filter_type, double ripple)
perform bandstop filter in-place
- Return
filtered data
- Parameters
data
row_num
sampling_rate
start_freq
stop_freq
order
filter_type
ripple
-
unsafe void perform_rolling_filter (double[,] data, int row_num, int period, int operation)
perform moving average or moving median filter, unlike other bindings instead in-place calculation it returns new array
- Return
filered data
- Parameters
data
row_num
period
operation
-
unsafe void detrend (double[,] data, int row_num, int operation)
detrend, unlike other bindings instead in-place calculation it returns new array
- Return
data with removed trend
- Parameters
data
row_num
operation
-
unsafe double [] perform_downsampling (double[,] data, int row_num, int period, int operation)
perform data downsampling, it just aggregates data without applying lowpass filter
- Return
data after downsampling
- Parameters
data
row_num
period
operation
-
unsafe double [] detect_peaks_z_score (double[,] data, int row_num, int lag, double threshold, double influence)
detect peaks using z score algorithm
-
unsafe double calc_stddev (double[,] data, int row_num, int start_pos, int end_pos)
calc stddev
///
- Return
stddev
- Parameters
data
row_num
start_pos
- Parameters
end_pos
-
unsafe double get_railed_percentage (double[,] data, int row_num, int gain)
get railed percentage
- Return
railed
- Parameters
data
row_num
gain
-
unsafe Tuple< double[], int[]> perform_wavelet_transform (double[,] data, int row_num, int wavelet, int decomposition_level, int extension)
perform wavelet transform
- Return
tuple of wavelet coeffs in format [A(J) D(J) D(J-1) ….. D(1)] where J is decomposition level, A - app coeffs, D - detailed coeffs, and array with lengths for each block
- Parameters
data
: data for wavelet transformrow_num
wavelet
: use WaveletTypes enumextension
: use WaveletExtensionTypes enumdecomposition_level
: decomposition level
-
unsafe void perform_wavelet_denoising (double[,] data, int row_num, int wavelet, int decomposition_level, int wavelet_denoising=(int) WaveletDenoisingTypes.SURESHRINK, int threshold=(int) ThresholdTypes.HARD, int extenstion_type=(int) WaveletExtensionTypes.SYMMETRIC, int noise_level=(int) NoiseEstimationLevelTypes.FIRST_LEVEL)
perform wavelet based denoising
- Parameters
data
: data for denoisingrow_num
wavelet
: use WaveletTypes enumdecomposition_level
: level of decomposition in wavelet transformextenstion_type
: use WaveletExtensionTypes enumnoise_level
: use NoiseEstimationLevelTypes enumthreshold
: use ThresholdTypes enumwavelet_denoising
: use WaveletDenoisingTypes enum
-
unsafe Complex [] perform_fft (double[,] data, int row_num, int start_pos, int end_pos, int window)
perform direct fft
- Return
complex array of size N / 2 + 1 of fft data
- Parameters
data
: data for fftrow_num
start_pos
: start posend_pos
: end pos, end_pos - start_pos must be evenwindow
: window function
-
unsafe Tuple< double[], double[]> get_psd (double[,] data, int row_num, int start_pos, int end_pos, int sampling_rate, int window)
calculate PSD
- Return
Tuple of ampls and freqs arrays of size N / 2 + 1
- Parameters
data
: data for PSDrow_num
start_pos
: start posend_pos
: end pos, end_pos - start_pos must be evensampling_rate
: sampling ratewindow
: window function
-
unsafe Tuple< double[], double[]> get_psd_welch (double[,] data, int row_num, int nfft, int overlap, int sampling_rate, int window)
calculate PSD using Welch method
- Return
Tuple of ampls and freqs arrays
- Parameters
data
: data for log PSDrow_num
nfft
: FFT Sizeoverlap
: FFT Window overlap, must be between 0 and nfftsampling_rate
: sampling ratewindow
: window function
-
void
-
class
brainflow::brainflow
::
MLModel
Public Functions
-
MLModel
(BrainFlowModelParams input_params) Create an instance of MLModel class
- Parameters
input_params
-
void
prepare
() Prepare classifier
-
void
release
() Release classifier
-
double [] predict (double[] data)
Get score of classifier
Public Static Functions
-
void
release_all
() release all classifiers
-
void
set_log_level
(int log_level) set log level, logger is disabled by default
- Parameters
log_level
-
void
log_message
(int log_level, string message)¶ send your own log message to BrainFlow’s logger
- Parameters
log_level
message
-
void
enable_ml_logger
() enable ML logger with level INFO
-
void
disable_ml_logger
() disable ML logger
-
void
enable_dev_ml_logger
() enable ML logger with level TRACE
-
void
set_log_file
(string log_file)¶ redirect BrainFlow’s logger from stderr to file
- Parameters
log_file
-
string
get_version
() get version
- Return
version
- Exceptions
BrainFlowException
-
R API Reference¶
R binding is a wrapper on top of Python binding. It is implemented using reticulate.
Check R samples to see how to use it.
Full code for R binding:
#' @import reticulate
NULL
#' @export
brainflow_python <- NULL
#' @export
np <- NULL
#' @export
pandas <- NULL
sys <- NULL
type_map <- NULL
.onLoad <- function(libname, pkgname)
{
brainflow_python <<- import('brainflow', delay_load = TRUE)
np <<- import('numpy', delay_load = TRUE, convert = FALSE)
pandas <<- import('pandas', delay_load = TRUE)
sys <<- import('sys', delay_load = TRUE)
type_map <<- function(type)
{
if (is.character(type))
{
return (list(
'float32' = np$float32,
'float64' = np$float64,
'auto' = NULL
)[[type]])
}
type
}
}
Matlab API Reference¶
Matlab binding calls C/C++ code as any other binding, it’s not compatible with Octave.
A few general rules to keep in mind:
Use char arrays instead strings to work with BrainFlow API, it means
'my_string'
instead"my_string"
, otherwise you will get calllib errorUse int32 values intead enums, it means
int32 (BoardIDs.SYNTHETIC_BOARD)
insteadBoardIDs.SYNTHETIC_BOARD
, the same is true for all enums in BrainFlow API
-
class
brainflow.
AggOperations
¶ Bases:
int32
Store all supported Agg Operations
-
class
brainflow.
BoardIds
¶ Bases:
int32
Store all supported board ids
-
class
brainflow.
BoardShim
(board_id, input_params)¶ BoardShim object to communicate with device
BoardShim constructor
-
board_id
= None¶
-
static
load_lib
()¶
-
static
check_ec
(ec, task_name)¶
-
static
release_all_sessions
()¶ release all sessions
-
static
set_log_level
(log_level)¶ set log level for BoardShim
-
static
set_log_file
(log_file)¶ set log file for BoardShim, logger uses stderr by default
-
static
enable_board_logger
()¶ enable logger with level INFO
-
static
enable_dev_board_logger
()¶ enable logger with level TRACE
-
static
disable_board_logger
()¶ disable logger
-
static
log_message
(log_level, message)¶ write message to BoardShim logger
-
static
get_sampling_rate
(board_id, preset)¶ get sampling rate for provided board id
-
static
get_package_num_channel
(board_id, preset)¶ get package num channel for provided board id
-
static
get_marker_channel
(board_id, preset)¶ get marker channel for provided board id
-
static
get_battery_channel
(board_id, preset)¶ get battery channel for provided board id
-
static
get_num_rows
(board_id, preset)¶ get num rows for provided board id
-
static
get_timestamp_channel
(board_id, preset)¶ get timestamp channel for provided board id
-
static
get_board_descr
(board_id, preset)¶ get board descr for provided board id
-
static
get_eeg_names
(board_id, preset)¶ get eeg names for provided board id
-
static
get_board_presets
(board_id)¶ get supported presets
-
static
get_version
()¶ get version
-
static
get_device_name
(board_id, preset)¶ get device name for provided board id
-
static
get_eeg_channels
(board_id, preset)¶ get eeg channels for provided board id
-
static
get_exg_channels
(board_id, preset)¶ get exg channels for provided board id
-
static
get_emg_channels
(board_id, preset)¶ get emg channels for provided board id
-
static
get_ecg_channels
(board_id, preset)¶ get ecg channels for provided board id
-
static
get_eog_channels
(board_id, preset)¶ get eog channels for provided board id
-
static
get_ppg_channels
(board_id, preset)¶ get ppg channels for provided board id
-
static
get_eda_channels
(board_id, preset)¶ get eda channels for provided board id
-
static
get_accel_channels
(board_id, preset)¶ get accel channels for provided board id
-
static
get_analog_channels
(board_id, preset)¶ get analog channels for provided board id
-
static
get_other_channels
(board_id, preset)¶ get other channels for provided board id
-
static
get_temperature_channels
(board_id, preset)¶ get temperature channels for provided board id
-
static
get_resistance_channels
(board_id, preset)¶ get resistance channels for provided board id
-
static
get_magnetometer_channels
(board_id, preset)¶ get magnetometer channels for provided board id
-
BoardShim
(board_id, input_params)¶ BoardShim constructor
-
prepare_session
()¶ prepare BoardShim session
-
config_board
(config)¶ send string to the board
-
add_streamer
(streamer, preset)¶ add streamer
-
delete_streamer
(streamer, preset)¶ delete streamer
-
start_stream
(buffer_size, streamer_params)¶ start data acqusition
-
stop_stream
()¶ stop acqusition
-
release_session
()¶ release session
-
insert_marker
(value, preset)¶ insert marker
-
get_board_data_count
(preset)¶ get amount of datapoints in internal buffer
-
get_board_data
(num_datapoints, preset)¶ get required amount of data by specifying it and remove it from the buffer
-
get_current_board_data
(num_samples, preset)¶ get latest datapoints, doesnt remove it from internal buffer
-
is_prepared
()¶ check if brainflow session prepared
-
-
class
brainflow.
BrainFlowClassifiers
¶ Bases:
int32
Store supported classifiers
-
class
brainflow.
BrainFlowExitCodes
¶ Bases:
int32
Store all possible exit codes
-
class
brainflow.
BrainFlowInputParams
¶ BrainFlow input params, check docs for params for your device
-
serial_port
= None¶
-
BrainFlowInputParams
()¶
-
to_json
()¶
-
-
class
brainflow.
BrainFlowMetrics
¶ Bases:
int32
Store all supported metrics
-
class
brainflow.
BrainFlowModelParams
(metric, classifier)¶ Store MLModel params
-
metric
= None¶
-
BrainFlowModelParams
(metric, classifier)¶
-
to_json
()¶
-
-
class
brainflow.
BrainFlowPresets
¶ Bases:
int32
Store all supported presets
-
class
brainflow.
DataFilter
¶ DataFilter class for signal processing
-
static
load_lib
()¶
-
static
check_ec
(ec, task_name)¶
-
static
get_version
()¶ get version
-
static
log_message
(log_level, message)¶ write message to Data Filter logger
-
static
set_log_level
(log_level)¶ set log level for DataFilter
-
static
set_log_file
(log_file)¶ set log file for DataFilter
-
static
enable_data_logger
()¶ enable logger with level INFO
-
static
enable_dev_data_logger
()¶ enable logger with level TRACE
-
static
disable_data_logger
()¶ disable logger
-
static
perform_lowpass
(data, sampling_rate, cutoff, order, filter_type, ripple)¶ perform lowpass filtering
-
static
perform_highpass
(data, sampling_rate, cutoff, order, filter_type, ripple)¶ perform highpass filtering
-
static
perform_bandpass
(data, sampling_rate, start_freq, stop_freq, order, filter_type, ripple)¶ perform bandpass filtering
-
static
perform_bandstop
(data, sampling_rate, start_freq, stop_freq, order, filter_type, ripple)¶ perform bandpass filtering
-
static
remove_environmental_noise
(data, sampling_rate, noise_type)¶ perform noth filtering
-
static
perform_rolling_filter
(data, period, operation)¶ apply rolling filter
-
static
detrend
(data, operation)¶ remove trend from data
-
static
perform_downsampling
(data, period, operation)¶ downsample data
-
static
restore_data_from_wavelet_detailed_coeffs
(data, wavelet, decomposition_level, level_to_restore)¶ restore data from a single wavelet level
-
static
detect_peaks_z_score
(data, lag, threshold, influence)¶ peaks detection using z score algorithm
-
static
perform_wavelet_transform
(data, wavelet, decomposition_level, extension)¶ perform wavelet transform
-
static
perform_inverse_wavelet_transform
(wavelet_data, wavelet_sizes, original_data_len, wavelet, decomposition_level, extension)¶ perform inverse wavelet transform
-
static
perform_wavelet_denoising
(data, wavelet, decomposition_level, denoising, threshold, extention, noise_level)¶ perform wavelet denoising
-
static
get_csp
(data, labels)¶ get common spatial patterns
-
static
get_window
(window_function, window_len)¶ get window
-
static
calc_stddev
(data)¶ calc stddev
-
static
get_railed_percentage
(data, gain)¶ calc railed percentage
-
static
get_oxygen_level
(ppg_ir, ppg_red, sampling_rate, coef1, coef2, coef3)¶ calc oxygen level
-
static
get_heart_rate
(ppg_ir, ppg_red, sampling_rate, fft_size)¶ calc heart rate
-
static
perform_fft
(data, window)¶ perform fft
-
static
perform_ifft
(fft_data)¶ perform inverse fft
-
static
get_avg_band_powers
(data, channels, sampling_rate, apply_filters)¶
-
static
get_custom_band_powers
(data, start_freqs, stop_freqs, channels, sampling_rate, apply_filters)¶ calculate average band powers
-
static
perform_ica_select_channels
(data, num_components, channels)¶ calculate ica
-
static
perform_ica
(data, num_components)¶ calculate ica
-
static
get_psd
(data, sampling_rate, window)¶ calculate PSD
-
static
get_psd_welch
(data, nfft, overlap, sampling_rate, window)¶ calculate PSD using welch method
-
static
get_band_power
(ampls, freqs, freq_start, freq_end)¶ calculate band power
-
static
get_nearest_power_of_two
(value)¶ get nearest power of two
-
static
write_file
(data, file_name, file_mode)¶ write data to file, in file data will be transposed
-
static
read_file
(file_name)¶ read data from file
-
static
-
class
brainflow.
DetrendOperations
¶ Bases:
int32
Store possible detrend operations
-
class
brainflow.
FilterTypes
¶ Bases:
int32
Store all possible filters
-
class
brainflow.
IpProtocolTypes
¶ Bases:
int32
Store all possible IP protocols
-
class
brainflow.
LogLevels
¶ Bases:
int32
Store all possible log levels
-
class
brainflow.
MLModel
(params)¶ MLModel for inference
-
input_json
= None¶
-
static
load_lib
()¶
-
static
check_ec
(ec, task_name)¶
-
static
release_all
()¶ release all sessions
-
static
log_message
(log_level, message)¶ write message to ML logger
-
static
set_log_level
(log_level)¶ set log level for MLModel
-
static
set_log_file
(log_file)¶ set log file for MLModel
-
static
enable_ml_logger
()¶ enable logger with level INFO
-
static
enable_dev_ml_logger
()¶ enable logger with level TRACE
-
static
disable_ml_logger
()¶ disable logger
-
static
get_version
()¶ get version
-
MLModel
(params)¶
-
prepare
()¶ prepare model
-
release
()¶ release model
-
predict
(input_data)¶ perform inference for input data
-
-
class
brainflow.
NoiseEstimationLevelTypes
¶ Bases:
int32
Store all possible noise estimation levels
-
class
brainflow.
NoiseTypes
¶ Bases:
int32
Store noise types
-
class
brainflow.
ThresholdTypes
¶ Bases:
int32
Store all possible threshold types
-
class
brainflow.
WaveletDenoisingTypes
¶ Bases:
int32
Store all possible denoising methods for wavelets
-
class
brainflow.
WaveletExtensionTypes
¶ Bases:
int32
Store all possible extensions
-
class
brainflow.
WaveletTypes
¶ Bases:
int32
Store all possible Wavelet Types
-
class
brainflow.
WindowOperations
¶ Bases:
int32
Store window functions
Julia API Reference¶
Julia binding calls C/C++ code as any other binding. Use Julia examples and API reference for other languaes as a starting point.
Since Julia is not Object-Oriented language, there is no DataFilter class. BoardShim class exists but all BoardShim class methods were moved to BrainFlow package and you need to pass BoardShim object to them.
Example:
using BrainFlow
# specify logging library to use
BrainFlow.enable_dev_logger(BrainFlow.BOARD_CONTROLLER)
params = BrainFlowInputParams()
board_shim = BrainFlow.BoardShim(BrainFlow.SYNTHETIC_BOARD, params)
BrainFlow.prepare_session(board_shim)
BrainFlow.add_streamer("file://data_default.csv:w", board_shim)
BrainFlow.start_stream(board_shim)
sleep(5)
BrainFlow.stop_stream(board_shim)
data = BrainFlow.get_current_board_data(32, board_shim)
BrainFlow.release_session(board_shim)
BrainFlow.write_file(data, "test.csv", "w")
restored_data = BrainFlow.read_file("test.csv")
println("Original Data")
println(data)
println("Restored Data")
println(restored_data)
Rust API Reference¶
Rust binding calls C/C++ code as any other binding. Use Rust examples and API reference for other languaes as a starting point.
Example:
use std::{thread, time::Duration};
use brainflow::{board_shim, brainflow_input_params::BrainFlowInputParamsBuilder, BoardIds, BrainFlowPresets,};
fn main() {
brainflow::board_shim::enable_dev_board_logger().unwrap();
let params = BrainFlowInputParamsBuilder::default().build();
let board = board_shim::BoardShim::new(BoardIds::SyntheticBoard, params).unwrap();
board.prepare_session().unwrap();
board.start_stream(45000, "").unwrap();
thread::sleep(Duration::from_secs(5));
board.stop_stream().unwrap();
let data = board.get_board_data(Some(10), BrainFlowPresets::DefaultPreset).unwrap();
board.release_session().unwrap();
println!("{}", data.len());
println!("{:?}", data);
}