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
- 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
- GALEA_BOARD_V4 = 48
- GALEA_SERIAL_BOARD_V4 = 49
- NTL_WIFI_BOARD = 50
- ANT_NEURO_EE_511_BOARD = 51
- FREEEEG128_BOARD = 52
- AAVAA_V3_BOARD = 53
- EXPLORE_PLUS_8_CHAN_BOARD = 54
- EXPLORE_PLUS_32_CHAN_BOARD = 55
- 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_rotation_channels(board_id: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → List[int]
get list of rotation channels in resulting data table for a board
- Parameters
board_id (int) – Board Id
preset (int) – preset
- Returns
list of rotation 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: Optional[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(num_samples: int, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float]
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(num_samples=None, preset: int = <BrainFlowPresets.DEFAULT_PRESET: 0>) → nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float]
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) → str
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
- config_board_with_bytes(bytes_to_send) → None
Use this method carefully and only if you understand what you are doing
- Parameters
bytes_to_send – bytes to send
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
- BUTTERWORTH_ZERO_PHASE = 3
- CHEBYSHEV_TYPE_1_ZERO_PHASE = 4
- BESSEL_ZERO_PHASE = 5
- 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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], sampling_rate: int, cutoff: float, order: int, filter_type: int, ripple: float) → None
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], sampling_rate: int, cutoff: float, order: int, filter_type: int, ripple: float) → None
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], sampling_rate: int, start_freq: float, stop_freq: float, order: int, filter_type: int, ripple: float) → None
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], sampling_rate: int, start_freq: float, stop_freq: float, order: int, filter_type: int, ripple: float) → None
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], sampling_rate: int, noise_type: float) → None
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], period: int, operation: int) → None
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float])
calc stddev
- Parameters
data (NDArray[Float64]) – input array
- Returns
stddev
- Return type
float
- classmethod get_railed_percentage(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], gain: int)
get railed percentage
- Parameters
data (NDArray[Float64]) – input array
gain (int) – gain
- Returns
railed percentage
- Return type
float
- classmethod get_oxygen_level(ppg_ir: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], ppg_red: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], sampling_rate: int, coef1=1.5958422, coef2=- 34.6596622, coef3=112.6898759)
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(ppg_ir: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], ppg_red: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], sampling_rate: int, fft_size: int)
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], period: int, operation: int) → nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float]
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], wavelet: int, decomposition_level: int, extension_type=<WaveletExtensionTypes.SYMMETRIC: 0>) → Tuple
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], wavelet, decomposition_level, level_to_restore)
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], lag=5, threshold=3.5, influence=0.1)
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(wavelet_output: Tuple, original_data_len: int, wavelet: int, decomposition_level: int, extension_type=<WaveletExtensionTypes.SYMMETRIC: 0>) → nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float]
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], wavelet: int, decomposition_level: int, wavelet_denoising=<WaveletDenoisingTypes.SURESHRINK: 1>, threshold=<ThresholdTypes.HARD: 1>, extension_type=<WaveletExtensionTypes.SYMMETRIC: 0>, noise_level=<NoiseEstimationLevelTypes.FIRST_LEVEL: 0>) → None
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], labels: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float]) → Tuple
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(window_function: int, window_len: int) → nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float]
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], window: int) → nptyping.types._ndarray.NDArray[None, nptyping.types._complex.Complex128]
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], sampling_rate: int, window: int) → Tuple
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], nfft: int, overlap: int, sampling_rate: int, window: int) → Tuple
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float], detrend_operation: int) → None
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(data: nptyping.types._ndarray.NDArray[None, nptyping.types._complex.Complex128]) → nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float]
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
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
-
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 config_board_with_bytes(const char *bytes, int len)¶
send raw bytes to a board, not implemented for majority of devices, not recommended to use
-
void insert_marker(double value, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶
insert marker in data stream
Public Static Functions
-
static void disable_board_logger()¶
disable BrainFlow loggers
-
static void enable_board_logger()¶
enable BrainFlow logger with LEVEL_INFO
-
static void enable_dev_board_logger()¶
enable BrainFlow logger with LEVEL_TRACE
-
static void set_log_file(std::string log_file)¶
redirect BrainFlow logger from stderr to file
-
static void set_log_level(int log_level)¶
use set_log_level only if you want to write your own log messages to BrainFlow logger
-
static void log_message(int log_level, const char *format, ...)¶
write user defined string to BrainFlow logger
-
static 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
- Throws
BrainFlowException – If board id is not valid exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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\EMG…
- Parameters
board_id – board id of your device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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\EMG…
- Parameters
board_id – board id of your device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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\EMG…
- Parameters
board_id – board id of your device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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\EMG…
- Parameters
board_id – board id of your device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static std::vector<int> get_rotation_channels(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶
get row indices which hold rotation data
- Parameters
board_id – board id of your device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static std::vector<int> get_analog_channels(int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET)¶
get row indices which hold rotation calib data
- Parameters
board_id – board id of your device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static 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
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static void release_all_sessions()¶
release all currently prepared session
-
static std::string get_version()¶
get brainflow version
-
static std::vector<int> get_board_presets(int board_id)¶
get available presets for this board
- Parameters
board_id – board id of your device
- Throws
BrainFlowException –
-
void prepare_session()¶
DataFilter class¶
-
class DataFilter¶
DataFilter class to perform signal processing.
Public Static Functions
-
static void enable_data_logger()¶
enable Data logger with LEVEL_INFO
-
static void disable_data_logger()¶
disable Data loggers
-
static void enable_dev_data_logger()¶
enable Data logger with LEVEL_TRACE
-
static void set_log_level(int log_level)¶
set log level
-
static void set_log_file(std::string log_file)¶
set log file
-
static void log_message(int log_level, const char *format, ...)¶
write user defined string to BrainFlow logger
-
static 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
-
static 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
-
static 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
-
static 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
-
static void remove_environmental_noise(double *data, int data_len, int sampling_rate, int noise_type)¶
apply notch filter to remove env noise
-
static void perform_rolling_filter(double *data, int data_len, int period, int agg_operation)¶
perform moving average or moving median filter in-place
-
static 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
-
static 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
- Parameters
data – input array, any size
data_len – length of input array
wavelet – use WaveletTypes enum
decomposition_level – level of decomposition in wavelet transform
extension – use WaveletExtensionTypes enum
- Returns
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
-
static 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
-
static 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 size
data_len – length of input array
wavelet – use WaveletTypes enum
decomposition_level – level of decomposition in wavelet transform
wavelet_denoising – use WaveletDenoisingTypes enum
threshold – use ThresholdTypes enum
extension – use WaveletExtensionTypes enum
noise_level – use NoiseEstimationLevelTypes enum
-
static 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
-
static 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
-
static 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
- Parameters
data – [n_epochs x n_channels x n_times]-shaped 3D array of data for two classes
labels – n_epochs-length 1D array of zeros and ones that assigns class labels for each epoch. Zero corresponds to the first class
n_epochs – the total number of epochs
n_channels – the number of EEG channels
n_times – the number of samples (observations) for a single epoch for a single channel
- Returns
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
-
static double *get_window(int window_function, int window_len)¶
perform data windowing
-
static std::complex<double> *perform_fft(double *data, int data_len, int window, int *fft_len)¶
perform direct fft
- Parameters
data – input array
data_len – must be even
window – window function
fft_len – output fft len(data_len / 2 + 1)
- Returns
complex array with size data_len / 2 + 1, it holds only positive im values
-
static double *perform_ifft(std::complex<double> *fft_data, int fft_len, int *data_len)¶
perform inverse fft
- Parameters
fft_data – complex array from perform_fft
fft_len – len of original array, must be even
data_len – output array len
- Returns
restored data
-
static int get_nearest_power_of_two(int value)¶
calculate nearest power of 2
- Parameters
value – input value
- Returns
nearest power of 2
-
static std::pair<double*, double*> get_psd(double *data, int data_len, int sampling_rate, int window, int *psd_len)¶
calculate PSD
- Parameters
data – input array
data_len – must be even
sampling_rate – sampling rate
window – window function
psd_len – output len (data_len / 2 + 1)
- Returns
pair of amplitude and freq arrays of size data_len / 2 + 1
-
static void detrend(double *data, int data_len, int detrend_operation)¶
subtract trend from data
- Parameters
data – input array
data_len –
psd_len – output len (data_len / 2 + 1)
detrend_operation – use DetrendOperations enum
-
static double get_band_power(std::pair<double*, double*> psd, int data_len, double freq_start, double freq_end)¶
calculate band power
- Parameters
psd – psd calculated using get_psd
data_len – len of ampl and freq arrays: N / 2 + 1 where N is FFT size
freq_start – lowest frequency
freq_end – highest frequency
- Returns
band power
-
static 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
- Parameters
data – input 2d array
cols – number of cols in 2d array - number of datapoints
channels – vector of rows - eeg channels which should be used
sampling_rate – sampling rate
apply_filters – set to true to apply filters before band power calculations
- Returns
pair of double arrays of size 5, first of them - avg band powers, second stddev
-
static 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
- Parameters
data – input 2d array
bands – input bands
cols – number of cols in 2d array - number of datapoints
channels – vector of rows - eeg channels which should be used
sampling_rate – sampling rate
apply_filters – set to true to apply filters before band power calculations
- Returns
pair of float arrays with the same size as bands argument
-
static double get_oxygen_level(double *ppg_ir, double *ppg_red, int data_len, int sampling_rate, double coef1 = 1.5958422, double coef2 = -34.6596622, double coef3 = 112.6898759)¶
calculate oxygen level
- Parameters
ppg_ir – input 1d array
ppg_red – input 1d array
data_len – size of array
sampling_rate – sampling rate
- Returns
oxygen level
-
static double get_heart_rate(double *ppg_ir, double *ppg_red, int data_len, int sampling_rate, int fft_size)¶
calculate heart rate
- Parameters
ppg_ir – input 1d array
ppg_red – input 1d array
data_len – size of array
sampling_rate – sampling rate
fft_size – recommended 8192
- Returns
heart rate
-
static void write_file(const BrainFlowArray<double, 2> &data, std::string file_name, std::string file_mode)¶
write file, in file data will be transposed
-
static BrainFlowArray<double, 2> read_file(std::string file_name)¶
read data from file, data will be transposed to original format
-
static double calc_stddev(double *data, int start_pos, int end_pos)¶
calc stddev
-
static double get_railed_percentage(double *data, int data_len, int gain)¶
calc railed percentage
-
static 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
- Parameters
data – input 2d array, rows are samples
num_components – number of components to find
channels – rows to use
- Returns
unmixed signal
-
static 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
- Parameters
data – input 2d array, rows are samples
num_components – number of components to find
- Returns
unmixed signal
-
static std::string get_version()¶
get brainflow version
-
static void enable_data_logger()¶
MLModel class¶
-
class MLModel¶
Calculates different metrics from raw data.
Public Functions
-
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
-
static void set_log_file(std::string log_file)¶
redirect logger to a file
-
static void enable_ml_logger()¶
enable ML logger with LEVEL_INFO
-
static void disable_ml_logger()¶
disable ML loggers
-
static void enable_dev_ml_logger()¶
enable ML logger with LEVEL_TRACE
-
static void set_log_level(int log_level)¶
set log level
-
static void log_message(int log_level, const char *format, ...)¶
write user defined string to BrainFlow logger
-
static void release_all()¶
release all currently prepared classifiers
-
static std::string get_version()¶
get brainflow version
-
void prepare()¶
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,
GALEA_BOARD_V4 = 48,
GALEA_SERIAL_BOARD_V4 = 49,
NTL_WIFI_BOARD = 50,
ANT_NEURO_EE_511_BOARD = 51,
FREEEEG128_BOARD = 52,
AAVAA_V3_BOARD = 53,
EXPLORE_PLUS_8_CHAN_BOARD = 54,
EXPLORE_PLUS_32_CHAN_BOARD = 55,
// use it to iterate
FIRST = PLAYBACK_FILE_BOARD,
LAST = EXPLORE_PLUS_32_CHAN_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,
BUTTERWORTH_ZERO_PHASE = 3,
CHEBYSHEV_TYPE_1_ZERO_PHASE = 4,
BESSEL_ZERO_PHASE = 5
};
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
- static inline String brainflow::string_from_code (final int code)
- static inline AggOperations brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::agg_operation
Private Static Attributes
- static final Map< Integer, AggOperations > brainflow::ao_map = new HashMap<Integer, AggOperations> ()
-
class BoardDescr¶
-
enum BoardIds¶
enum to store all supported boards
Public Functions
-
inline int get_code()
- inline 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::BRAINALIVE_BOARD =(40)
- 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)
- brainflow::GALEA_BOARD_V4 =(48)
- brainflow::GALEA_SERIAL_BOARD_V4 =(49)
- brainflow::NTL_WIFI_BOARD =(50)
- brainflow::ANT_NEURO_EE_511_BOARD =(51)
- brainflow::FREEEEG128_BOARD =(52)
- brainflow::AAVAA_V3_BOARD =(53)
- brainflow::EXPLORE_PLUS_8_CHAN_BOARD =(54)
- brainflow::EXPLORE_PLUS_32_CHAN_BOARD =(55)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline BoardIds brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::board_id
Private Static Attributes
- static final Map< Integer, BoardIds > brainflow::bi_map = new HashMap<Integer, BoardIds> ()
-
inline int get_code()
-
class brainflow::brainflow::BoardShim¶
BoardShim class to communicate with a board
Public Functions
-
inline BoardShim(int board_id, BrainFlowInputParams params)¶
Create BoardShim object
-
inline BoardShim(BoardIds board_id, BrainFlowInputParams params)¶
Create BoardShim object
-
inline void prepare_session()¶
prepare steaming session, allocate resources
-
inline int get_board_id()¶
Get Board Id, can be different than provided (playback or streaming board)
-
inline void add_streamer(String streamer, int preset)¶
add streamer
-
inline void delete_streamer(String streamer, int preset)¶
delete streamer
-
inline String config_board(String config)¶
send string to a board, use this method carefully and only if you understand what you are doing
- inline void config_board_with_bytes (byte[] bytes)
send string to a board, dont use it
-
inline 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 ringbuffer
streamer_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”
-
inline void start_stream()¶
start streaming thread, store data in internal ringbuffer
-
inline void start_stream(int buffer_size)¶
start streaming thread, store data in internal ringbuffer
-
inline void stop_stream()¶
stop streaming thread
-
inline void release_session()¶
release all resources
-
inline int get_board_data_count(BrainFlowPresets preset)¶
get number of packages in ringbuffer
-
inline int get_board_data_count()¶
get number of packages in ringbuffer
-
inline void insert_marker(double value, BrainFlowPresets preset)¶
insert marker to data stream
-
inline void insert_marker(double value)¶
insert marker to data stream
-
inline boolean is_prepared()¶
check session status
- inline 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
- inline double[][] get_current_board_data (int num_samples)
get latest collected data, can return less than “num_samples”, doesnt flush it from ringbuffer
- inline double[][] get_board_data (BrainFlowPresets preset)
get all data from ringbuffer and flush it
- inline double[][] get_board_data ()
get all data from ringbuffer and flush it
Public Members
-
int board_id¶
BrainFlow’s board id
Public Static Functions
-
static inline void enable_board_logger()¶
enable BrainFlow logger with level INFO
-
static inline void enable_dev_board_logger()¶
enable BrainFlow logger with level TRACE
-
static inline void disable_board_logger()¶
disable BrainFlow logger
-
static inline void set_log_file(String log_file)¶
redirect logger from stderr to a file
-
static inline void release_all_sessions()¶
release all prepared sessions
-
static inline void set_log_level(int log_level)¶
set log level
-
static inline void log_message(int log_level, String message)¶
send user defined strings to BrainFlow logger
-
static inline void log_message(LogLevels log_level, String message)¶
send user defined strings to BrainFlow logger
-
static inline int get_sampling_rate(int board_id, BrainFlowPresets preset)¶
get sampling rate for this board
-
static inline int get_sampling_rate(BoardIds board_id, BrainFlowPresets preset)¶
get sampling rate for this board
-
static inline int get_sampling_rate(int board_id)¶
get sampling rate for this board
-
static inline int get_timestamp_channel(int board_id, BrainFlowPresets preset)¶
get row index in returned by get_board_data() 2d array which contains timestamps
-
static inline int get_timestamp_channel(BoardIds board_id, BrainFlowPresets preset)¶
get row index in returned by get_board_data() 2d array which contains timestamps
-
static inline int get_timestamp_channel(BoardIds board_id)¶
get row index in returned by get_board_data() 2d array which contains timestamps
-
static inline int get_timestamp_channel(int board_id)¶
get row index in returned by get_board_data() 2d array which contains timestamps
-
static inline int get_marker_channel(int board_id, BrainFlowPresets preset)¶
get row index in returned by get_board_data() 2d array which contains markers
-
static inline int get_marker_channel(BoardIds board_id, BrainFlowPresets preset)¶
get row index in returned by get_board_data() 2d array which contains markers
-
static inline int get_marker_channel(BoardIds board_id)¶
get row index in returned by get_board_data() 2d array which contains markers
-
static inline int get_marker_channel(int board_id)¶
get row index in returned by get_board_data() 2d array which contains markers
-
static inline int get_num_rows(int board_id, BrainFlowPresets preset)¶
get number of rows in returned by get_board_data() 2d array
-
static inline int get_num_rows(BoardIds board_id, BrainFlowPresets preset)¶
get number of rows in returned by get_board_data() 2d array
-
static inline int get_num_rows(BoardIds board_id)¶
get number of rows in returned by get_board_data() 2d array
-
static inline int get_num_rows(int board_id)¶
get number of rows in returned by get_board_data() 2d array
-
static inline 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
-
static inline int get_package_num_channel(int board_id)¶
get row index in returned by get_board_data() 2d array which contains package nums
-
static inline 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
-
static inline int get_package_num_channel(BoardIds board_id)¶
get row index in returned by get_board_data() 2d array which contains package nums
-
static inline int get_battery_channel(int board_id, BrainFlowPresets preset)¶
get row index in returned by get_board_data() 2d array which contains battery level
-
static inline int get_battery_channel(int board_id)¶
get row index in returned by get_board_data() 2d array which contains battery level
-
static inline int get_battery_channel(BoardIds board_id, BrainFlowPresets preset)¶
get row index in returned by get_board_data() 2d array which contains battery level
-
static inline int get_battery_channel(BoardIds board_id)¶
get row index in returned by get_board_data() 2d array which contains battery level
- static inline String[] get_eeg_names (int board_id, BrainFlowPresets preset)
Get names of EEG electrodes in 10-20 system. Only if electrodes have freezed locations
- static inline BrainFlowPresets[] get_board_presets (int board_id)
Get supported presets for this device
- static inline String[] get_eeg_names (int board_id)
Get names of EEG electrodes in 10-20 system. Only if electrodes have freezed locations
- static inline String[] get_eeg_names (BoardIds board_id, BrainFlowPresets preset)
Get names of EEG electrodes in 10-20 system. Only if electrodes have freezed locations
- static inline String[] get_eeg_names (BoardIds board_id)
Get names of EEG electrodes in 10-20 system. Only if electrodes have freezed locations
- static inline static< T > T get_board_descr (Class< T > type, int board_id, BrainFlowPresets preset)
Get board description
- static inline static< T > T get_board_descr (Class< T > type, int board_id)
Get board description
- static inline static< T > T get_board_descr (Class< T > type, BoardIds board_id, BrainFlowPresets preset)
Get board description
- static inline static< T > T get_board_descr (Class< T > type, BoardIds board_id)
Get board description
-
static inline String get_device_name(int board_id, BrainFlowPresets preset)¶
Get device name
-
static inline String get_device_name(int board_id)¶
Get device name
-
static inline String get_device_name(BoardIds board_id, BrainFlowPresets preset)¶
Get device name
-
static inline String get_version()¶
Get version
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline int[] get_temperature_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain temperature data
- static inline int[] get_temperature_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain temperature data
- static inline int[] get_temperature_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain temperature data
- static inline int[] get_temperature_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain temperature data
- static inline int[] get_magnetometer_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain magnetometer data
- static inline int[] get_magnetometer_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain magnetometer data
- static inline int[] get_magnetometer_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain magnetometer data
- static inline int[] get_magnetometer_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain magnetometer data
- static inline int[] get_resistance_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain resistance data
- static inline int[] get_resistance_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain resistance data
- static inline int[] get_resistance_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain resistance data
- static inline int[] get_resistance_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain resistance data
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline int[] get_exg_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EXG data
- static inline int[] get_exg_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain EXG data
- static inline int[] get_exg_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain EXG data
- static inline int[] get_exg_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain EXG data
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline 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\EMG… and return the same array
- static inline int[] get_accel_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain accel data
- static inline int[] get_accel_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain accel data
- static inline int[] get_accel_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain accel data
- static inline int[] get_accel_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain accel data
- static inline int[] get_analog_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain analog data
- static inline int[] get_analog_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain analog data
- static inline int[] get_analog_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain analog data
- static inline int[] get_analog_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain analog data
- static inline int[] get_gyro_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain gyro data
- static inline int[] get_gyro_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain gyro data
- static inline int[] get_gyro_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain gyro data
- static inline int[] get_gyro_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain gyro data
- static inline int[] get_other_channels (int board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain other data
- static inline int[] get_other_channels (int board_id)
get row indices in returned by get_board_data() 2d array which contain other data
- static inline int[] get_other_channels (BoardIds board_id, BrainFlowPresets preset)
get row indices in returned by get_board_data() 2d array which contain other data
- static inline int[] get_other_channels (BoardIds board_id)
get row indices in returned by get_board_data() 2d array which contain other data
-
inline BoardShim(int board_id, BrainFlowInputParams params)¶
-
enum BrainFlowClassifiers¶
Public Functions
-
inline int get_code()
- inline brainflow::BrainFlowClassifiers (final int code)
Public Members
- brainflow::DEFAULT_CLASSIFIER =(0)
- brainflow::DYN_LIB_CLASSIFIER =(1)
- brainflow::ONNX_CLASSIFIER =(2)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline BrainFlowClassifiers brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::protocol
Private Static Attributes
- static final Map< Integer, BrainFlowClassifiers > brainflow::cl_map = new HashMap<Integer, BrainFlowClassifiers> ()
-
inline int get_code()
-
class brainflow::brainflow::BrainFlowError : public Exception¶
BrainFlowError exception to notify about errors
Public Members
-
int exit_code¶
exit code returned from low level API
-
int exit_code¶
-
enum BrainFlowExitCode¶
Public Functions
-
inline int get_code()
- inline 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
- static inline String brainflow::string_from_code (final int code)
- static inline BrainFlowExitCode brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::exit_code
Private Static Attributes
- static final Map< Integer, BrainFlowExitCode > brainflow::ec_map = new HashMap<Integer, BrainFlowExitCode> ()
-
inline int get_code()
-
class BrainFlowInputParams¶
to get fields which are required for your board check SupportedBoards section
-
enum BrainFlowMetrics¶
Public Functions
-
inline int get_code()
- inline brainflow::BrainFlowMetrics (final int code)
Public Members
- brainflow::MINDFULNESS =(0)
- brainflow::RESTFULNESS =(1)
- brainflow::USER_DEFINED =(2)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline BrainFlowMetrics brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::protocol
Private Static Attributes
- static final Map< Integer, BrainFlowMetrics > brainflow::metr_map = new HashMap<Integer, BrainFlowMetrics> ()
-
inline int get_code()
-
class BrainFlowModelParams¶
describe model parameters
-
enum BrainFlowPresets¶
enum to store all supported presets
Public Functions
-
inline int get_code()
- inline brainflow::BrainFlowPresets (final int code)
Public Members
- brainflow::DEFAULT_PRESET =(0)
- brainflow::AUXILIARY_PRESET =(1)
- brainflow::ANCILLARY_PRESET =(2)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline BrainFlowPresets brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::preset
Private Static Attributes
- static final Map< Integer, BrainFlowPresets > brainflow::my_map = new HashMap<Integer, BrainFlowPresets> ()
-
inline int get_code()
-
class brainflow::brainflow::DataFilter¶
DataFilter class to perform signal processing
Public Static Functions
-
static inline void enable_data_logger()¶
enable Data logger with level INFO
-
static inline String get_version()¶
Get version
-
static inline void enable_dev_data_logger()¶
enable Data logger with level TRACE
-
static inline void disable_data_logger()¶
disable Data logger
-
static inline void set_log_file(String log_file)¶
redirect logger from stderr to a file
- static inline double calc_stddev (double[] data, int start_pos, int end_pos)
calc stddev
- static inline double get_oxygen_level (double[] ppg_ir, double[] ppg_red, int sampling_rate, double coef1, double coef2, double coef3)
get oxygen level
- static inline double get_oxygen_level (double[] ppg_ir, double[] ppg_red, int sampling_rate)
get oxygen level
- static inline double get_heart_rate (double[] ppg_ir, double[] ppg_red, int sampling_rate, int fft_size)
get heart rate
- static inline double get_railed_percentage (double[] data, int len, int gain)
get railed percentage
-
static inline void log_message(int log_level, String message)¶
send user defined strings to BrainFlow logger
-
static inline void set_log_level(int log_level)¶
set log level
- static inline void perform_lowpass (double[] data, int sampling_rate, double cutoff, int order, int filter_type, double ripple)
perform lowpass filter in-place
- static inline void perform_lowpass (double[] data, int sampling_rate, double cutoff, int order, FilterTypes filter_type, double ripple)
perform lowpass filter in-place
- static inline void perform_highpass (double[] data, int sampling_rate, double cutoff, int order, int filter_type, double ripple)
perform highpass filter in-place
- static inline void perform_highpass (double[] data, int sampling_rate, double cutoff, int order, FilterTypes filter_type, double ripple)
perform highpass filter in-place
- static inline 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
- static inline 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
- static inline 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
- static inline 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
- static inline void perform_rolling_filter (double[] data, int period, int operation)
perform moving average or moving median filter in-place
- static inline void perform_rolling_filter (double[] data, int period, AggOperations operation)
perform moving average or moving median filter in-place
- static inline void detrend (double[] data, int operation)
subtract trend from data in-place
- static inline void detrend (double[] data, DetrendOperations operation)
subtract trend from data in-place
- static inline 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
- static inline 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
- static inline 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
- static inline double[] detect_peaks_z_score (double[] data, int lag, double threshold, double influence)
peak detection using z score algorithm
- static inline 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
- static inline void remove_environmental_noise (double[] data, int sampling_rate, int noise_type)
removes noise using notch filter
- static inline void remove_environmental_noise (double[] data, int sampling_rate, NoiseTypes noise_type)
removes noise using notch filter
- static inline 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
- static inline 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
- static inline Pair< double[], int[]> perform_wavelet_transform (double[] data, int wavelet, int decomposition_level, int extension)
perform wavelet transform
- static inline Pair< double[], int[]> perform_wavelet_transform (double[] data, WaveletTypes wavelet, int decomposition_level, WaveletExtensionTypes extension)
perform wavelet transform
- static inline 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
- static inline 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
- static inline Pair< double[][], double[]> get_csp (double[][][] data, double[] labels)
get common spatial filters
- static inline double[] get_window (int window, int window_len)
perform data windowing
- Parameters
window – window function
window_len – lenght of the window function
- Returns
array of the size specified in window_len
- static inline double[] get_window (WindowOperations window, int window_len)
perform data windowing
- Parameters
window – window function
window_len – lenght of the window function
- Returns
array of the size specified in window_len
- static inline Complex[] perform_fft (double[] data, int start_pos, int end_pos, int window)
perform direct fft
- Parameters
data – data for fft transform
start_pos – starting position to calc fft
end_pos – end position to calc fft, total_len must be even
window – window function
- Returns
array of complex values with size N / 2 + 1
- static inline Complex[] perform_fft (double[] data, int start_pos, int end_pos, WindowOperations window)
perform direct fft
- Parameters
data – data for fft transform
start_pos – starting position to calc fft
end_pos – end position to calc fft, total_len must be even
window – window function
- Returns
array of complex values with size N / 2 + 1
- static inline double[] perform_ifft (Complex[] data)
perform inverse fft
- Parameters
data – data from fft transform(array of complex values)
- Returns
restored data
- static inline 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
- Parameters
data – data to process
channels – rows of data arrays which should be used in calculation
sampling_rate – sampling rate
apply_filters – apply bandpass and bandstop filters before calculation
- Returns
pair of avgs and stddevs for bandpowers
- static inline 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
- Parameters
data – data to process
bands – bands to calculate
channels – rows of data arrays which should be used in calculation
sampling_rate – sampling rate
apply_filters – apply bandpass and bandstop filters before calculation
- Returns
pair of avgs and stddevs for bandpowers
- static inline List< double[][]> perform_ica (double[][] data, int num_components)
Calculates ICA
- Parameters
data –
num_components –
- Throws
- Returns
- static inline List< double[][]> perform_ica (double[][] data, int num_components, int[] channels)
calculates ICA
- Parameters
data –
num_components –
channels –
- Throws
- Returns
- static inline Pair< double[], double[]> get_psd (double[] data, int start_pos, int end_pos, int sampling_rate, int window)
get PSD
- Parameters
data – data to process
start_pos – starting position to calc PSD
end_pos – end position to calc PSD, total_len must be even
sampling_rate – sampling rate
window – window function
- Returns
pair of ampl and freq arrays with len N / 2 + 1
- static inline Pair< double[], double[]> get_psd (double[] data, int start_pos, int end_pos, int sampling_rate, WindowOperations window)
get PSD
- Parameters
data – data to process
start_pos – starting position to calc PSD
end_pos – end position to calc PSD, total_len must be even
sampling_rate – sampling rate
window – window function
- Returns
pair of ampl and freq arrays with len N / 2 + 1
- static inline Pair< double[], double[]> get_psd_welch (double[] data, int nfft, int overlap, int sampling_rate, int window)
get PSD using Welch Method
- Parameters
data – data to process
nfft – size of FFT, must be even
overlap – overlap between FFT Windows, must be between 0 and nfft
sampling_rate – sampling rate
window – window function
- Returns
pair of ampl and freq arrays
- static inline Pair< double[], double[]> get_psd_welch (double[] data, int nfft, int overlap, int sampling_rate, WindowOperations window)
get PSD using Welch Method
- Parameters
data – data to process
nfft – size of FFT, must be even
overlap – overlap between FFT Windows, must be between 0 and nfft
sampling_rate – sampling rate
window – window function
- Returns
pair of ampl and freq arrays
-
static inline double get_band_power(Pair<double[], double[]> psd, double freq_start, double freq_end)¶
get band power
- Parameters
psd – PSD from get_psd or get_log_psd
freq_start – lowest frequency of band
freq_end – highest frequency of band
- Returns
band power
-
static inline int get_nearest_power_of_two(int value)¶
calculate nearest power of two
- static inline void write_file (double[][] data, String file_name, String file_mode)
write data to tsv file, in file data will be transposed
- static inline double[][] read_file (String file_name)
read data from file, transpose it back to original format
-
static inline void enable_data_logger()¶
-
enum DetrendOperations¶
enum to store all supported detrend operations
Public Functions
-
inline int get_code()
- inline brainflow::DetrendOperations (final int code)
Public Members
- brainflow::NO_DETREND =(0)
- brainflow::CONSTANT =(1)
- brainflow::LINEAR =(2)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline DetrendOperations brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::detrend_operation
Private Static Attributes
- static final Map< Integer, DetrendOperations > brainflow::dt_map = new HashMap<Integer, DetrendOperations> ()
-
inline int get_code()
-
enum FilterTypes¶
enum to store all possible filter types
Public Functions
-
inline int get_code()
- inline brainflow::FilterTypes (final int code)
Public Members
- brainflow::BUTTERWORTH =(0)
- brainflow::CHEBYSHEV_TYPE_1 =(1)
- brainflow::BESSEL =(2)
- brainflow::BUTTERWORTH_ZERO_PHASE =(3)
- brainflow::CHEBYSHEV_TYPE_1_ZERO_PHASE =(4)
- brainflow::BESSEL_ZERO_PHASE =(5)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline FilterTypes brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::filter_type
Private Static Attributes
- static final Map< Integer, FilterTypes > brainflow::ft_map = new HashMap<Integer, FilterTypes> ()
-
inline int get_code()
-
enum IpProtocolTypes¶
Public Functions
-
inline int get_code()
- inline brainflow::IpProtocolTypes (final int code)
Public Members
- brainflow::NO_IP_PROTOCOL =(0)
- brainflow::UDP =(1)
- brainflow::TCP =(2)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline IpProtocolTypes brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::protocol
Private Static Attributes
- static final Map< Integer, IpProtocolTypes > brainflow::ip_map = new HashMap<Integer, IpProtocolTypes> ()
-
inline int get_code()
-
class JarHelper¶
-
enum LogLevels¶
Public Functions
-
inline int get_code()
- inline 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
- static inline String brainflow::string_from_code (final int code)
- static inline LogLevels brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::log_level
Private Static Attributes
- static final Map< Integer, LogLevels > brainflow::ll_map = new HashMap<Integer, LogLevels> ()
-
inline int get_code()
-
class brainflow::brainflow::MLModel¶
Public Functions
-
inline MLModel(BrainFlowModelParams params)¶
Create MLModel object
-
inline void prepare()¶
Prepare classifier
- Throws
-
inline void release()¶
Release classifier
- Throws
- inline double[] predict (double[] data)
Get score of classifier
- Throws
Public Static Functions
-
static inline void enable_ml_logger()¶
enable ML logger with level INFO
-
static inline void enable_dev_ml_logger()¶
enable ML logger with level TRACE
-
static inline void disable_ml_logger()¶
disable BrainFlow logger
-
static inline void set_log_file(String log_file)¶
redirect logger from stderr to a file
-
static inline String get_version()¶
Get version
-
static inline void release_all()¶
release all classifiers
-
static inline void log_message(int log_level, String message)¶
send user defined strings to BrainFlow logger
-
static inline void set_log_level(int log_level)¶
set log level
-
inline MLModel(BrainFlowModelParams params)¶
-
enum NoiseEstimationLevelTypes¶
enum to store all possible Noise Level Types
Public Functions
-
inline int get_code()
- inline brainflow::NoiseEstimationLevelTypes (final int code)
Public Members
- brainflow::FIRST_LEVEL =(0)
- brainflow::ALL_LEVELS =(1)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline NoiseEstimationLevelTypes brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::value
Private Static Attributes
- static final Map< Integer, NoiseEstimationLevelTypes > brainflow::map = new HashMap<Integer, NoiseEstimationLevelTypes> ()
-
inline int get_code()
-
enum NoiseTypes¶
enum to store all supported noise types
Public Functions
-
inline int get_code()
- inline brainflow::NoiseTypes (final int code)
Public Members
- brainflow::FIFTY =(0)
- brainflow::SIXTY =(1)
- brainflow::FIFTY_AND_SIXTY =(2)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline NoiseTypes brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::noise_type
Private Static Attributes
- static final Map< Integer, NoiseTypes > brainflow::nt_map = new HashMap<Integer, NoiseTypes> ()
-
inline int get_code()
-
enum ThresholdTypes¶
enum to store all possible Threshold Types
Public Functions
-
inline int get_code()
- inline brainflow::ThresholdTypes (final int code)
Public Members
- brainflow::SOFT =(0)
- brainflow::HARD =(1)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline ThresholdTypes brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::value
Private Static Attributes
- static final Map< Integer, ThresholdTypes > brainflow::map = new HashMap<Integer, ThresholdTypes> ()
-
inline int get_code()
-
enum WaveletDenoisingTypes¶
enum to store all possible Wavelet Denoising Types
Public Functions
-
inline int get_code()
- inline brainflow::WaveletDenoisingTypes (final int code)
Public Members
- brainflow::VISUSHRINK =(0)
- brainflow::SURESHRINK =(1)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline WaveletDenoisingTypes brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::value
Private Static Attributes
- static final Map< Integer, WaveletDenoisingTypes > brainflow::map = new HashMap<Integer, WaveletDenoisingTypes> ()
-
inline int get_code()
-
enum WaveletExtensionTypes¶
enum to store all possible Wavelet Extenstion Types
Public Functions
-
inline int get_code()
- inline brainflow::WaveletExtensionTypes (final int code)
Public Members
- brainflow::SYMMETRIC =(0)
- brainflow::PERIODIC =(1)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline WaveletExtensionTypes brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::value
Private Static Attributes
- static final Map< Integer, WaveletExtensionTypes > brainflow::map = new HashMap<Integer, WaveletExtensionTypes> ()
-
inline int get_code()
-
enum WaveletTypes¶
enum to store all possible Wavelet Types
Public Functions
-
inline int get_code()
- inline 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
- static inline String brainflow::string_from_code (final int code)
- static inline WaveletTypes brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::value
Private Static Attributes
- static final Map< Integer, WaveletTypes > brainflow::map = new HashMap<Integer, WaveletTypes> ()
-
inline int get_code()
-
enum WindowOperations¶
Public Functions
-
inline int get_code()
- inline brainflow::WindowOperations (final int code)
Public Members
- brainflow::NO_WINDOW =(0)
- brainflow::HANNING =(1)
- brainflow::HAMMING =(2)
- brainflow::BLACKMAN_HARRIS =(3)
Public Static Functions
- static inline String brainflow::string_from_code (final int code)
- static inline WindowOperations brainflow::from_code (final int code)
- static inline brainflow::[static initializer]
Private Members
- final int brainflow::window
Private Static Attributes
- static final Map< Integer, WindowOperations > brainflow::window_map = new HashMap<Integer, WindowOperations> ()
-
inline int get_code()
C# API Reference¶
Content of brainflow namespace:
- brainflow.LogLevels
Values:
-
enumerator LEVEL_TRACE¶
-
enumerator LEVEL_DEBUG¶
-
enumerator LEVEL_INFO¶
-
enumerator LEVEL_WARN¶
-
enumerator LEVEL_ERROR¶
-
enumerator LEVEL_CRITICAL¶
-
enumerator LEVEL_OFF¶
-
enumerator LEVEL_TRACE¶
- brainflow.BrainFlowPresets
Values:
-
enumerator DEFAULT_PRESET¶
-
enumerator AUXILIARY_PRESET¶
-
enumerator ANCILLARY_PRESET¶
-
enumerator DEFAULT_PRESET¶
- brainflow.BrainFlowExitCodes
Values:
-
enumerator STATUS_OK¶
-
enumerator PORT_ALREADY_OPEN_ERROR¶
-
enumerator UNABLE_TO_OPEN_PORT_ERROR¶
-
enumerator SET_PORT_ERROR¶
-
enumerator BOARD_WRITE_ERROR¶
-
enumerator INCOMMING_MSG_ERROR¶
-
enumerator INITIAL_MSG_ERROR¶
-
enumerator BOARD_NOT_READY_ERROR¶
-
enumerator STREAM_ALREADY_RUN_ERROR¶
-
enumerator INVALID_BUFFER_SIZE_ERROR¶
-
enumerator STREAM_THREAD_ERROR¶
-
enumerator STREAM_THREAD_IS_NOT_RUNNING¶
-
enumerator EMPTY_BUFFER_ERROR¶
-
enumerator INVALID_ARGUMENTS_ERROR¶
-
enumerator UNSUPPORTED_BOARD_ERROR¶
-
enumerator BOARD_NOT_CREATED_ERROR¶
-
enumerator ANOTHER_BOARD_IS_CREATED_ERROR¶
-
enumerator GENERAL_ERROR¶
-
enumerator SYNC_TIMEOUT_ERROR¶
-
enumerator JSON_NOT_FOUND_ERROR¶
-
enumerator NO_SUCH_DATA_IN_JSON_ERROR¶
-
enumerator CLASSIFIER_IS_NOT_PREPARED_ERROR¶
-
enumerator ANOTHER_CLASSIFIER_IS_PREPARED_ERROR¶
-
enumerator UNSUPPORTED_CLASSIFIER_AND_METRIC_COMBINATION_ERROR¶
-
enumerator STATUS_OK¶
- brainflow.BoardIds
Values:
-
enumerator NO_BOARD¶
-
enumerator PLAYBACK_FILE_BOARD¶
-
enumerator STREAMING_BOARD¶
-
enumerator SYNTHETIC_BOARD¶
-
enumerator CYTON_BOARD¶
-
enumerator GANGLION_BOARD¶
-
enumerator CYTON_DAISY_BOARD¶
-
enumerator GALEA_BOARD¶
-
enumerator GANGLION_WIFI_BOARD¶
-
enumerator CYTON_WIFI_BOARD¶
-
enumerator CYTON_DAISY_WIFI_BOARD¶
-
enumerator BRAINBIT_BOARD¶
-
enumerator UNICORN_BOARD¶
-
enumerator CALLIBRI_EEG_BOARD¶
-
enumerator CALLIBRI_EMG_BOARD¶
-
enumerator CALLIBRI_ECG_BOARD¶
-
enumerator NOTION_1_BOARD¶
-
enumerator NOTION_2_BOARD¶
-
enumerator GFORCE_PRO_BOARD¶
-
enumerator FREEEEG32_BOARD¶
-
enumerator BRAINBIT_BLED_BOARD¶
-
enumerator GFORCE_DUAL_BOARD¶
-
enumerator GALEA_SERIAL_BOARD¶
-
enumerator MUSE_S_BLED_BOARD¶
-
enumerator MUSE_2_BLED_BOARD¶
-
enumerator CROWN_BOARD¶
-
enumerator ANT_NEURO_EE_410_BOARD¶
-
enumerator ANT_NEURO_EE_411_BOARD¶
-
enumerator ANT_NEURO_EE_430_BOARD¶
-
enumerator ANT_NEURO_EE_211_BOARD¶
-
enumerator ANT_NEURO_EE_212_BOARD¶
-
enumerator ANT_NEURO_EE_213_BOARD¶
-
enumerator ANT_NEURO_EE_214_BOARD¶
-
enumerator ANT_NEURO_EE_215_BOARD¶
-
enumerator ANT_NEURO_EE_221_BOARD¶
-
enumerator ANT_NEURO_EE_222_BOARD¶
-
enumerator ANT_NEURO_EE_223_BOARD¶
-
enumerator ANT_NEURO_EE_224_BOARD¶
-
enumerator ANT_NEURO_EE_225_BOARD¶
-
enumerator ENOPHONE_BOARD¶
-
enumerator MUSE_2_BOARD¶
-
enumerator MUSE_S_BOARD¶
-
enumerator BRAINALIVE_BOARD¶
-
enumerator MUSE_2016_BOARD¶
-
enumerator MUSE_2016_BLED_BOARD¶
-
enumerator EXPLORE_4_CHAN_BOARD¶
-
enumerator EXPLORE_8_CHAN_BOARD¶
-
enumerator GANGLION_NATIVE_BOARD¶
-
enumerator EMOTIBIT_BOARD¶
-
enumerator GALEA_BOARD_V4¶
-
enumerator GALEA_SERIAL_BOARD_V4¶
-
enumerator NTL_WIFI_BOARD¶
-
enumerator ANT_NEURO_EE_511_BOARD¶
-
enumerator FREEEEG128_BOARD¶
-
enumerator AAVAA_V3_BOARD¶
-
enumerator EXPLORE_PLUS_8_CHAN_BOARD¶
-
enumerator EXPLORE_PLUS_32_CHAN_BOARD¶
-
enumerator NO_BOARD¶
- brainflow.FilterTypes
Values:
-
enumerator BUTTERWORTH¶
-
enumerator CHEBYSHEV_TYPE_1¶
-
enumerator BESSEL¶
-
enumerator BUTTERWORTH_ZERO_PHASE¶
-
enumerator CHEBYSHEV_TYPE_1_ZERO_PHASE¶
-
enumerator BESSEL_ZERO_PHASE¶
-
enumerator BUTTERWORTH¶
- brainflow.WindowOperations
Values:
-
enumerator NO_WINDOW¶
-
enumerator HANNING¶
-
enumerator HAMMING¶
-
enumerator BLACKMAN_HARRIS¶
-
enumerator NO_WINDOW¶
- brainflow.WaveletTypes
Values:
-
enumerator HAAR¶
-
enumerator DB1¶
-
enumerator DB2¶
-
enumerator DB3¶
-
enumerator DB4¶
-
enumerator DB5¶
-
enumerator DB6¶
-
enumerator DB7¶
-
enumerator DB8¶
-
enumerator DB9¶
-
enumerator DB10¶
-
enumerator DB11¶
-
enumerator DB12¶
-
enumerator DB13¶
-
enumerator DB14¶
-
enumerator DB15¶
-
enumerator BIOR1_1¶
-
enumerator BIOR1_3¶
-
enumerator BIOR1_5¶
-
enumerator BIOR2_2¶
-
enumerator BIOR2_4¶
-
enumerator BIOR2_6¶
-
enumerator BIOR2_8¶
-
enumerator BIOR3_1¶
-
enumerator BIOR3_3¶
-
enumerator BIOR3_5¶
-
enumerator BIOR3_7¶
-
enumerator BIOR3_9¶
-
enumerator BIOR4_4¶
-
enumerator BIOR5_5¶
-
enumerator BIOR6_8¶
-
enumerator COIF1¶
-
enumerator COIF2¶
-
enumerator COIF3¶
-
enumerator COIF4¶
-
enumerator COIF5¶
-
enumerator SYM2¶
-
enumerator SYM3¶
-
enumerator SYM4¶
-
enumerator SYM5¶
-
enumerator SYM6¶
-
enumerator SYM7¶
-
enumerator SYM8¶
-
enumerator SYM9¶
-
enumerator SYM10¶
-
enumerator HAAR¶
- brainflow.BrainFlowMetrics
Values:
-
enumerator MINDFULNESS¶
-
enumerator RESTFULNESS¶
-
enumerator USER_DEFINED¶
-
enumerator MINDFULNESS¶
- brainflow.BrainFlowClassifiers
Values:
-
enumerator DEFAULT_CLASSIFIER¶
-
enumerator DYN_LIB_CLASSIFIER¶
-
enumerator ONNX_CLASSIFIER¶
-
enumerator DEFAULT_CLASSIFIER¶
- brainflow.brainflow.BoardDescr
- 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 config_board_with_bytes (byte[] bytes)
send raw bytes to device, dont use it
- Parameters
bytes –
-
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 ringbuffer
streamer_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>
- Returns
session status
- Returns
Master board id
-
int get_board_id()¶
summary> Get input params /summary>
- Returns
input params
-
int get_board_data_count(int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶
get number of packages in ringbuffer
- Parameters
preset – preset for device
- Returns
number of packages
- double[,] get_current_board_data (int num_samples, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get latest collected data, doesnt remove it from ringbuffer
- Parameters
num_samples –
preset – preset for device
- Returns
latest collected data, can be less than “num_samples”
- double[,] get_current_board_data (double[,] result, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get latest collected data, doesnt remove it from ringbuffer
- Parameters
preset – preset for device
result – array to store results, if provided BrainFlow does not allocate new memory
- Returns
latest collected data, can be less than “num_samples”
- double[,] get_board_data ()
get all collected data and remove it from ringbuffer
- Returns
collected data
- double[,] get_board_data (int num_datapoints)
get collected data and remove it from ringbuffer
- Returns
collected data
- double[,] get_board_data (int num_datapoints, int preset)
get collected data and remove it from ringbuffer
- Parameters
num_datapoints – number of datapoints to get
preset – preset for device
- Returns
all collected data
- double[,] get_board_data (double[,] data_arr, int preset)
get collected data and remove it from ringbuffer
- Parameters
data_arr – array to store results, if provided BrainFlow will not allocate memory
preset – preset for device
- Returns
all collected data
Public Members
-
int board_id¶
BrainFlow’s board id
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
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
sampling rate
-
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
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
row num in 2d array
-
int get_timestamp_channel(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶
get row index which holds timestamps
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
row num in 2d array
-
int get_marker_channel(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶
get row index which holds marker
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
row num in 2d array
-
int get_battery_channel(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶
get row undex which holds battery level
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
row num in 2d array
-
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
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
number of rows in 2d array
- 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
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of 10-20 locations
- int[] get_board_presets (int board_id)
get presets for selected device
- Parameters
board_id –
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of strings
-
template<>
T get_board_descr<T>(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶ get board description
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If board id is not valid exit code is UNSUPPORTED_BOARD_ERROR
- Returns
board description
-
string get_device_name(int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)¶
get device name
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
device name
-
string get_version()¶
get version
- Throws
BrainFlowException –
- Returns
version
- 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\EEG.. data and return the same array for all of them
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- 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\EEG.. data and return the same array for all of them
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- 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\EEG.. data and return the same array for all of them
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- 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\EEG.. data and return the same array for all of them
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- int[] get_exg_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices of EXG channels for this board
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- 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\EEG.. data and return the same array for all of them
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- int[] get_ppg_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indeces which hold ppg data
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- int[] get_accel_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices which hold accel data
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- int[] get_rotation_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices which hold rotation data
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- int[] get_analog_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices which hold analog data
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- int[] get_gyro_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get row indices which hold gyro data
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- int[] get_other_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get other channels for this board
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- int[] get_temperature_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get temperature channels for this board
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- int[] get_resistance_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get resistance channels for this board
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
- int[] get_magnetometer_channels (int board_id, int preset=(int) BrainFlowPresets.DEFAULT_PRESET)
get magnetometer channels for this board
- Parameters
board_id –
preset – preset for device
- Throws
BrainFlowException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
- Returns
array of row nums
-
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 –
-
BoardShim(int board_id, BrainFlowInputParams input_params)¶
- brainflow.brainflow.BrainFlowError : public Exception
BrainFlowError class to notify about errors
Public Members
-
int exit_code¶
exit code returned from low level API
-
int exit_code¶
- brainflow.brainflow.BrainFlowInputParams
Check SuportedBoards to get information about fields which are required for specific board
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
-
string serial_port¶
- brainflow.brainflow.BrainFlowModelParams
Describe model
- 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
- Parameters
data –
sampling_rate –
cutoff –
order –
filter_type –
ripple –
- Returns
filtered data
- double[] remove_environmental_noise (double[] data, int sampling_rate, int noise_type)
remove env noise using notch filter
- Parameters
data –
sampling_rate –
noise_type –
- Returns
filtered data
- 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
- Parameters
data –
sampling_rate –
cutoff –
order –
filter_type –
ripple –
- Returns
filtered data
- 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
- Parameters
data –
sampling_rate –
start_freq –
stop_freq –
order –
filter_type –
ripple –
- Returns
filtered data
- 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
- Parameters
data –
sampling_rate –
start_freq –
stop_freq –
order –
filter_type –
ripple –
- Returns
filtered data
- 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
- Parameters
data –
period –
operation –
- Returns
filered data
- double[] detrend (double[] data, int operation)
detrend, unlike other bindings instead in-place calculation it returns new array
- Parameters
data –
operation –
- Returns
data with removed trend
- double[] perform_downsampling (double[] data, int period, int operation)
perform data downsampling, it just aggregates data without applying lowpass filter
- Parameters
data –
period –
operation –
- Returns
data after downsampling
- 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
///
- Parameters
data –
start_pos –
end_pos –
- Returns
stddev
- double get_railed_percentage (double[] data, int gain)
get railed percentage
- Parameters
data –
gain –
- Returns
railed
- double get_oxygen_level (double[] ppg_ir, double[] ppg_red, int sampling_rate, double coef1=1.5958422, double coef2=-34.6596622, double coef3=112.6898759)
calc oxygen level from ppg values
///
- Parameters
coef1 – appxorimation coef for power of 2
coef2 – approximation coef
coef3 – intercept for approximation
- Returns
stddev
- double get_heart_rate (double[] ppg_ir, double[] ppg_red, int sampling_rate, int fft_size)
calc heart rate
- Parameters
fft_size – recommended 8192
- Returns
stddev
- Tuple< double[], int[]> perform_wavelet_transform (double[] data, int wavelet, int decomposition_level, int extension)
perform wavelet transform
- Parameters
data – data for wavelet transform
wavelet – use WaveletTypes enum
extension – use WaveletExtensionTypes enum
decomposition_level – decomposition level
- 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
- 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
- Parameters
wavelet_data – tuple returned by perform_wavelet_transform
original_data_len – size of original data before direct wavelet transform
wavelet – use WaveletTypes enum
decomposition_level – level of decomposition
extension – use WaveletExtensionTypes enum
- Returns
restored data
- 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
- Parameters
data – data for denoising
wavelet – use WaveletTypes enum
decomposition_level – level of decomposition in wavelet transform
extenstion_type – use WaveletExtensionTypes enum
noise_level – use NoiseEstimationLevelTypes enum
threshold – use ThresholdTypes enum
wavelet_denoising – use WaveletDenoisingTypes enum
- Returns
denoised data
- Tuple< double[,], double[]> get_csp (double[,,] data, double[] labels)
get common spatial patterns
- Parameters
data – data for csp
labels – labels for each class
- Returns
Tuple of two arrays: [n_channels x n_channels] shaped array of filters and n_channels length array of eigenvalues
- double[] get_window (int window_function, int window_len)
perform windowing
- Parameters
window_function – window function
window_len – len of the window
- Returns
array of the size specified in window_len
- Complex[] perform_fft (double[] data, int start_pos, int end_pos, int window)
perform direct fft
- Parameters
data – data for fft
start_pos – start pos
end_pos – end pos, end_pos - start_pos must be even
window – window function
- Returns
complex array of size N / 2 + 1 of fft data
- double[] perform_ifft (Complex[] data)
perform inverse fft
- Parameters
data – data from perform_fft
- Returns
restored data
- 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
- Parameters
file_name –
- Returns
-
int get_nearest_power_of_two(int value)¶
calculate nearest power of two
- Parameters
value –
- Returns
nearest power of two
- 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
- Parameters
data – 2d array with values
bands – bands to calculate
channels – rows of data array which should be used for calculation
sampling_rate – sampling rate
apply_filters – apply bandpass and bandstop filters before calculation
- Returns
Tuple of avgs and stddev arrays
- Tuple< double[,], double[,], double[,], double[,]> perform_ica (double[,] data, int num_components)
Calculate ICA
- Parameters
data –
num_components –
- Returns
- Tuple< double[,], double[,], double[,], double[,]> perform_ica (double[,] data, int num_components, int[] channels)
Calculate ICA
- Parameters
data –
num_components –
channels –
- Returns
- Tuple< double[], double[]> get_avg_band_powers (double[,] data, int[] channels, int sampling_rate, bool apply_filters)
calculate avg and stddev bandpowers across channels
- Parameters
data – 2d array with values
channels – rows of data array which should be used for calculation
sampling_rate – sampling rate
apply_filters – apply bandpass and bandstop filters before calculation
- Returns
Tuple of avgs and stddev arrays
- Tuple< double[], double[]> get_psd (double[] data, int start_pos, int end_pos, int sampling_rate, int window)
calculate PSD
- Parameters
data – data for PSD
start_pos – start pos
end_pos – end pos, end_pos - start_pos must be even
sampling_rate – sampling rate
window – window function
- Returns
Tuple of ampls and freqs arrays of size N / 2 + 1
- Tuple< double[], double[]> get_psd_welch (double[] data, int nfft, int overlap, int sampling_rate, int window)
calculate PSD using Welch method
- Parameters
data – data for log PSD
nfft – FFT Size
overlap – FFT Window overlap, must be between 0 and nfft
sampling_rate – sampling rate
window – window function
- Returns
Tuple of ampls and freqs arrays
-
double get_band_power(Tuple<double[], double[]> psd, double start_freq, double stop_freq)¶
calculate band power
- Parameters
psd – psd data returned by get_psd or get_psd_welch
start_freq – lowest frequency of band
stop_freq – highest frequency of band
- Returns
band power
-
string get_version()
get version
- Throws
BrainFlowException –
- Returns
version
- 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
- Parameters
data –
row_num –
sampling_rate –
start_freq –
stop_freq –
order –
filter_type –
ripple –
- Returns
filtered data
- 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
- Parameters
data –
row_num –
period –
operation –
- Returns
filered data
- unsafe void detrend (double[,] data, int row_num, int operation)
detrend, unlike other bindings instead in-place calculation it returns new array
- Parameters
data –
row_num –
operation –
- Returns
data with removed trend
- unsafe double[] perform_downsampling (double[,] data, int row_num, int period, int operation)
perform data downsampling, it just aggregates data without applying lowpass filter
- Parameters
data –
row_num –
period –
operation –
- Returns
data after downsampling
- 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
///
- Parameters
data –
row_num –
start_pos –
end_pos –
- Returns
stddev
- unsafe double get_railed_percentage (double[,] data, int row_num, int gain)
get railed percentage
- Parameters
data –
row_num –
gain –
- Returns
railed
- unsafe Tuple< double[], int[]> perform_wavelet_transform (double[,] data, int row_num, int wavelet, int decomposition_level, int extension)
perform wavelet transform
- Parameters
data – data for wavelet transform
row_num –
wavelet – use WaveletTypes enum
extension – use WaveletExtensionTypes enum
decomposition_level – decomposition level
- 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
- 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 denoising
row_num –
wavelet – use WaveletTypes enum
decomposition_level – level of decomposition in wavelet transform
extenstion_type – use WaveletExtensionTypes enum
noise_level – use NoiseEstimationLevelTypes enum
threshold – use ThresholdTypes enum
wavelet_denoising – use WaveletDenoisingTypes enum
- unsafe Complex[] perform_fft (double[,] data, int row_num, int start_pos, int end_pos, int window)
perform direct fft
- Parameters
data – data for fft
row_num –
start_pos – start pos
end_pos – end pos, end_pos - start_pos must be even
window – window function
- Returns
complex array of size N / 2 + 1 of fft data
- unsafe Tuple< double[], double[]> get_psd (double[,] data, int row_num, int start_pos, int end_pos, int sampling_rate, int window)
calculate PSD
- Parameters
data – data for PSD
row_num –
start_pos – start pos
end_pos – end pos, end_pos - start_pos must be even
sampling_rate – sampling rate
window – window function
- Returns
Tuple of ampls and freqs arrays of size N / 2 + 1
- 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
- Parameters
data – data for log PSD
row_num –
nfft – FFT Size
overlap – FFT Window overlap, must be between 0 and nfft
sampling_rate – sampling rate
window – window function
- Returns
Tuple of ampls and freqs arrays
-
void set_log_level(int log_level)
- 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
- Throws
BrainFlowException –
- Returns
version
-
MLModel(BrainFlowModelParams input_params)¶
- brainflow.brainflow.PlatformHelper
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.MLModel(params)¶
MLModel for inference
- Method Summary
- 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
- prepare()¶
prepare model
- release()¶
release model
- predict(input_data)¶
perform inference for input data
- class brainflow.NoiseTypes¶
Bases:
int32
Store noise types
- class brainflow.FilterTypes¶
Bases:
int32
Store all possible filters
- class brainflow.DetrendOperations¶
Bases:
int32
Store possible detrend operations
- class brainflow.BoardIds¶
Bases:
int32
Store all supported board ids
- class brainflow.IpProtocolTypes¶
Bases:
int32
Store all possible IP protocols
- class brainflow.DataFilter¶
DataFilter class for signal processing
- Method Summary
- 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_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
- class brainflow.WaveletTypes¶
Bases:
int32
Store all possible Wavelet Types
- class brainflow.BrainFlowExitCodes¶
Bases:
int32
Store all possible exit codes
- class brainflow.ThresholdTypes¶
Bases:
int32
Store all possible threshold types
- class brainflow.WaveletExtensionTypes¶
Bases:
int32
Store all possible extensions
- class brainflow.WindowOperations¶
Bases:
int32
Store window functions
- class brainflow.NoiseEstimationLevelTypes¶
Bases:
int32
Store all possible noise estimation levels
- class brainflow.BrainFlowClassifiers¶
Bases:
int32
Store supported classifiers
- class brainflow.BrainFlowModelParams(metric, classifier)¶
Store MLModel params
- class brainflow.BrainFlowInputParams¶
BrainFlow input params, check docs for params for your device
- class brainflow.BoardShim(board_id, input_params)¶
BoardShim object to communicate with device
BoardShim constructor
- Method Summary
- 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_rotation_channels(board_id, preset)¶
get rotation 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
- prepare_session()¶
prepare BoardShim session
- config_board(config)¶
send string to the board
- config_board_with_bytes(bytes)¶
send bytes to the board, do not use it
- 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.AggOperations¶
Bases:
int32
Store all supported Agg Operations
- class brainflow.LogLevels¶
Bases:
int32
Store all possible log levels
- class brainflow.BrainFlowPresets¶
Bases:
int32
Store all supported presets
- class brainflow.WaveletDenoisingTypes¶
Bases:
int32
Store all possible denoising methods for wavelets
- class brainflow.BrainFlowMetrics¶
Bases:
int32
Store all supported metrics
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);
}
Typescript API Reference¶
Typescript binding calls C/C++ code as any other binding. Use Typescript examples and API reference for other languaes as a starting point.
Example:
import {BoardIds, BoardShim} from 'brainflow';
function sleep (ms: number)
{
return new Promise ((resolve) => { setTimeout (resolve, ms); });
}
async function runExample (): Promise<void>
{
const board = new BoardShim (BoardIds.SYNTHETIC_BOARD, {});
board.prepareSession();
board.startStream();
await sleep (3000);
board.stopStream();
const data = board.getBoardData();
board.releaseSession();
console.info('Data');
console.info(data);
}
runExample ();