User API
MindRove 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 MindRove API only for data streaming and perform signal processing by yourself and vice versa.
MindRove data acqusition API is board agnostic, so to select a specific board you need to pass MindRove’s board id to BoardShim’s constructor and an instance of MindRoveInputParams 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
mindrove.board_shim
mindrove.exit_codes
- exception mindrove.exit_codes.MindRoveError(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 mindrove.exit_codes.MindRoveExitCodes(value)
Bases:
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
mindrove.data_filter
mindrove.ml_model
C++ API Reference
BoardShim class
-
class BoardShim
BoardShim class to communicate with a board.
Public Functions
-
void prepare_session()
prepare MindRove’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)MindRovePresets::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)MindRovePresets::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
-
MindRoveArray<double, 2> get_current_board_data(int num_samples, int preset = (int)MindRovePresets::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)MindRovePresets::DEFAULT_PRESET)
get number of packages in ringbuffer
-
MindRoveArray<double, 2> get_board_data(int preset = (int)MindRovePresets::DEFAULT_PRESET)
get all collected data and flush it from internal buffer
-
MindRoveArray<double, 2> get_board_data(int num_datapoints, int preset)
get required amount of datapoints or less and flush it from internal buffer
-
std::string config_board(std::string config)
send string to a board, use it carefully and only if you understand what you are doing
-
void insert_marker(double value, int preset = (int)MindRovePresets::DEFAULT_PRESET)
insert marker in data stream
Public Static Functions
-
static void disable_board_logger()
disable MindRove loggers
-
static void enable_board_logger()
enable MindRove logger with LEVEL_INFO
-
static void enable_dev_board_logger()
enable MindRove logger with LEVEL_TRACE
-
static void set_log_file(std::string log_file)
redirect MindRove 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 MindRove logger
-
static void log_message(int log_level, const char *format, ...)
write user defined string to MindRove logger
-
static json get_board_descr(int board_id, int preset = (int)MindRovePresets::DEFAULT_PRESET)
get board description as json
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – If board id is not valid exit code is UNSUPPORTED_BOARD_ERROR
-
static int get_sampling_rate(int board_id, int preset = (int)MindRovePresets::DEFAULT_PRESET)
get sampling rate for this board
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row index which holds package nums
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static int get_timestamp_channel(int board_id, int preset = (int)MindRovePresets::DEFAULT_PRESET)
get row index which holds timestamps
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static int get_marker_channel(int board_id, int preset = (int)MindRovePresets::DEFAULT_PRESET)
get row index which holds markers
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static int get_battery_channel(int board_id, int preset = (int)MindRovePresets::DEFAULT_PRESET)
get row index which holds battery level info
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
-
static int get_num_rows(int board_id, int preset = (int)MindRovePresets::DEFAULT_PRESET)
get number of rows in returned from get_board_data() 2d array
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get device name
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::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:
MindRoveException – 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)MindRovePresets::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:
MindRoveException – 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)MindRovePresets::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:
MindRoveException – 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)MindRovePresets::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:
MindRoveException – 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)MindRovePresets::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:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row indices which hold EXG data
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row indices which hold PPG data
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row indices which hold EDA data
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row indices which hold accel data
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row indices which hold rotation data
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row indices which hold rotation calib data
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row indices which hold gyro data
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row indices which hold other information
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row indices which hold temperature data
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row indices which hold resistance data
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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)MindRovePresets::DEFAULT_PRESET)
get row indices which hold magnetometer data
- Parameters:
board_id – board id of your device
- Throws:
MindRoveException – 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 mindrove 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:
MindRoveException –
-
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 MindRove 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<MindRoveArray<double, 2>, MindRoveArray<double, 1>> get_csp(const MindRoveArray<double, 3> &data, const MindRoveArray<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 MindRoveArray<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 MindRoveArray<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 MindRoveArray<double, 2> &data, std::string file_name, std::string file_mode)
write file, in file data will be transposed
-
static MindRoveArray<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<MindRoveArray<double, 2>, MindRoveArray<double, 2>, MindRoveArray<double, 2>, MindRoveArray<double, 2>> perform_ica(const MindRoveArray<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<MindRoveArray<double, 2>, MindRoveArray<double, 2>, MindRoveArray<double, 2>, MindRoveArray<double, 2>> perform_ica(const MindRoveArray<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 mindrove 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 MindRove logger
-
static void release_all()
release all currently prepared classifiers
-
static std::string get_version()
get mindrove version
-
void prepare()
MindRove constants
#pragma once
enum class MindRoveExitCodes : 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,
MINDROVE_WIFI_BOARD = 0,
MINDROVE_SYNCBOX_BOARD = 1,
// use it to iterate
FIRST = PLAYBACK_FILE_BOARD,
LAST = MINDROVE_SYNCBOX_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 MindRoveMetrics : int
{
MINDFULNESS = 0,
RESTFULNESS = 1,
USER_DEFINED = 2
};
enum class MindRoveClassifiers : int
{
DEFAULT_CLASSIFIER = 0,
DYN_LIB_CLASSIFIER = 1,
ONNX_CLASSIFIER = 2
};
enum class MindRovePresets : 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
};
C# API Reference
Content of mindrove namespace:
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 MindRove 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 MindRove API
- class mindrove.AggOperations
Bases:
int32
Store all supported Agg Operations
- class mindrove.BoardIds
Bases:
int32
Store all supported board ids
- class mindrove.BoardShim
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
- 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 mindrove session prepared
- class mindrove.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 mindrove.DetrendOperations
Bases:
int32
Store possible detrend operations
- class mindrove.FilterTypes
Bases:
int32
Store all possible filters
- class mindrove.IpProtocolTypes
Bases:
int32
Store all possible IP protocols
- class mindrove.LogLevels
Bases:
int32
Store all possible log levels
- class mindrove.MindRoveClassifiers
Bases:
int32
Store supported classifiers
- class mindrove.MindRoveExitCodes
Bases:
int32
Store all possible exit codes
- class mindrove.MindRoveInputParams
MindRove input params, check docs for params for your device
- class mindrove.MindRoveMetrics
Bases:
int32
Store all supported metrics
- class mindrove.MindRoveModelParams
Store MLModel params
- class mindrove.MindRovePresets
Bases:
int32
Store all supported presets
- class mindrove.MLModel
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 mindrove.NoiseEstimationLevelTypes
Bases:
int32
Store all possible noise estimation levels
- class mindrove.NoiseTypes
Bases:
int32
Store noise types
- class mindrove.ThresholdTypes
Bases:
int32
Store all possible threshold types
- class mindrove.WaveletDenoisingTypes
Bases:
int32
Store all possible denoising methods for wavelets
- class mindrove.WaveletExtensionTypes
Bases:
int32
Store all possible extensions
- class mindrove.WaveletTypes
Bases:
int32
Store all possible Wavelet Types
- class mindrove.WindowOperations
Bases:
int32
Store window functions