Binary to EEG¶
A transformer for Kafka that reads binary data and stream EEG data.
Binary -> Kafka-Transformer -> EEG
For examples and descriptions refers to documentation: Data storage handler
- class openbci_stream.daemons.stream_bin2eeg.BinaryToEEG(board_id: str = '')[source]¶
Kafka transformer with parallel implementation for processing binary raw data into EEG microvolts. This script requires the Kafka daemon running and enables an auto-kill process
- align_data(binary: bytes) Tuple[numpy.ndarray, bytes] [source]¶
Align data following the headers and footers.
- Parameters
binary – Data raw from OpenBCI board.
- Returns
data_aligned – Numpy array of shape (33, LENGTH) with headers and footer aligned.
remnant – This bytes could be used for complete next binary input.
- deserialize(data: numpy.ndarray, context: Dict[str, Any]) None [source]¶
From signed 24-bits integer to signed 32-bits integer.
- Parameters
data – Numpy array of shape (33, LENGTH)
context – Information from the acquisition side useful for deserializing and that will be packaged back in the stream.
- classmethod deserialize_aux(stop_byte: int, aux: int, context: Dict[str, Any]) numpy.ndarray [source]¶
Determine the content of AUX bytes and format it.
Auxialiar data could contain different kind of information: accelometer, user defined, time stamped and digital or analog inputs. The context of AUX bytes are determined by the stop byte.
If stop_byte is 0xc0 the AUX bytes contain Standard with accel, this data are packaged at different frequency, they will be show up each 10 or 11 packages, the final list will contain accelometer value in G units for axis X, Y and Z respectively and None when are not availables.
If stop_byte is 0xc1 the AUX bytes contain Standard with raw aux, there are 3 types of raw data: digital in wich case the final list will contain the values for D11, D12, D13, D17, D18; analog with the values for A7 (D13), A6 (D12), A5 (D11); markers data contain the the marker sended with send_marker() method.
- Parameters
stop_byte – 0xCX where X is 0-F in hex.
aux – 6 bytes of data defined and parsed based on the Footer bytes.
context – Information from the acquisition side useful for deserializing and that will be packaged back in the stream.
- Returns
Correct data formated.
- Return type
list
- deserialize_eeg_serial(eeg: numpy.ndarray, ids: numpy.ndarray, context: Dict[str, Any]) numpy.ndarray [source]¶
From signed 24-bits integer to signed 32-bits integer by channels.
The Cyton data format says that only can send packages of 33 bits, over serial (RFduino) this limit is absolute, when a Daisy board is attached these same amount of packages will be sent, in this case, the data must be distributed and interpolated in order to complete the sample rate.
- Parameters
eeg – Numpy array in signed 24-bits integer (8, LENGTH)
ids – List of IDs for eeg data.
context – Information from the acquisition side useful for deserializing and that will be packaged back in the stream.
- Returns
EEG data in microvolts, signed 32-bits integer, (CHANNELS, LENGTH), if there is a Daisy board CHANNELS is 16, otherwise is 8.
- Return type
eeg_data
- deserialize_eeg_wifi(eeg: numpy.ndarray, ids: numpy.ndarray, context: Dict[str, Any]) numpy.ndarray [source]¶
From signed 24-bits integer to signed 32-bits integer by channels.
The Cyton data format says that only can send packages of 33 bits, when a Daisy board is attached these same packages will be sent at double speed in favor to keep the desired sample rate for 16 channels.
- Parameters
eeg – Numpy array in signed 24-bits integer (8, LENGTH)
ids – List of IDs for eeg data.
context – Information from the acquisition side useful for deserializing and that will be packaged back in the stream.
- Returns
EEG data in microvolts, signed 32-bits integer, (CHANNELS, LENGTH), if there is a Daisy board CHANNELS is 16, otherwise is 8.
- Return type
eeg_data
- process(record: openbci_stream.daemons.stream_bin2eeg.kafka - stream) None [source]¶
Prepare the binary package for a successful unpack and stream.
- Parameters
record – Kafka stream with binary data.
- property scale_factor_eeg: float¶
Vector with the correct factors for scale eeg data samples.