Streaming data#
Channels#
A stream carries the channels enabled with
ba_eeg_manager_set_channel_enabled() before ba_eeg_manager_start_stream().
Per-electrode and per-axis channels add an index to a base ID.
Channel ID |
Type |
Value |
|---|---|---|
|
|
Sample number, from 0 at the stream start |
|
|
Electrode i in µV; its impedance in kΩ in impedance mode |
|
|
Whether electrode i touches the skin |
|
|
Digital (trigger) input level, 0 or 1 |
|
|
Acceleration along x, y, z in m/s² |
|
|
Angular velocity around x, y, z in degrees per second |
|
|
1 for a received sample, 0 for a filled-in lost one |
Electrode indices run from 0 to the electrode count minus one
(ba_core_device_features_electrode_count()). Enable the motion channels only
on devices that have the sensors.
Chunks#
The chunk callback receives samples in blocks of
sBACORE_Config_t::chunk_size (25 by default):
typedef void (*ba_callback_chunk)(const void* const* data, size_t data_size, void* user_data);
data holds one row per enabled channel, each with data_size values of
the channel’s type. Find a channel’s row with
ba_eeg_manager_get_channel_index():
static void on_chunk(const void* const* data, size_t size, void* user_data)
{
ba_eeg_manager* manager = user_data;
const size_t* sample = data[ba_eeg_manager_get_channel_index(manager, BA_EEG_CHANNEL_ID_SAMPLE_NUMBER)];
const double* electrode0 = data[ba_eeg_manager_get_channel_index(manager, BA_EEG_CHANNEL_ID_ELECTRODE_MEASUREMENT + 0)];
for (size_t i = 0; i < size; ++i)
{
printf("%zu %f\n", sample[i], electrode0[i]);
}
}
The arrays are valid only while the callback runs: copy what you keep. Always
use data_size: the last chunk of a stream, and chunks in impedance mode, can
be shorter.
Lost samples#
Samples lost on the radio link are filled in, so sample numbers stay
continuous. A filled-in row has BA_EEG_CHANNEL_ID_STREAMING set to 0 and
zeros in its measurement channels; count those rows to measure the loss.
Units#
Electrode values are in microvolts, already scaled by the gain set with
ba_eeg_manager_set_channel_gain().
Annotations#
Mark events in a recording with ba_eeg_manager_annotate(). The library
stores your text with the number of the sample the device was recording at that
moment, timed with the device clock. Read them with
ba_eeg_manager_get_annotations() and clear them with
ba_eeg_manager_clear_annotations().