Morelia.packet.data packageο
Submodulesο
Morelia.packet.data.data_packet moduleο
Morelia.packet.data.data_packet_8206hr moduleο
- class Morelia.packet.data.data_packet_8206hr.DataPacket8206HR(raw_packet, preamp_gain)ο
Bases:
DataPacket
This class handles decoding 8206HR data packets (previously known as Binary4 packets). It is optimized to be as effectient as possible for quick streaming by implementing lazy decoding via properties, slots, and memoization. On a binary level, data packets for the 8206HR look as follows:
The raw packet and several values from the device (with the same names as the parameters) needed for calculations are passed to the constructor. Outside of testing, users should never be instantiating this class directly, that should be limited to instances of the
Pod8206HR
class.- Parameters:
raw_packet (
bytes
) β Raw bytes of packet read from device.- Preamp_gain:
Desired preamplifer gain. Used for decoding read values from device. Must be 10 or 100.
- property ch0: intο
- Returns:
Value read from channel 0.
- property ch1: intο
- Returns:
Value read from channel 1.
- property ch2: intο
- Returns:
Value read from channel 2.
- property ttl1: DigitalSignalο
- Returns:
The first bit of the TTL byte.
- property ttl2: DigitalSignalο
- Returns:
The second bit of the TTL byte.
- property ttl3: DigitalSignalο
- Returns:
The third bit of the TTL byte.
- property ttl4: DigitalSignalο
- Returns:
The fourth bit of the TTL byte.
Morelia.packet.data.data_packet_8401hr moduleο
- class Morelia.packet.data.data_packet_8401hr.DataPacket8401HR(preamp_gain, ss_gain, primary_channel_modes, secondary_channel_modes, raw_packet)ο
Bases:
DataPacket
This class handles decoding 8401HR data packets (previously known as Binary5 packets). It is optimized to be as effectient as possible for quick streaming by implementing lazy decoding via properties, slots, and memoization. On a binary level, data packets for the 8401HR look as follows (this packet is big, so you may need to zoom inβ¦ sorry about that π):
There are a couple things to note. Firstly, you may see that some of the byte indices are repeated between the segements containing the channels. That is because each 18-bit channel value is packed over 3 bytes. Meaning, for example, that bytes 7 and 8 contain entirely data related to CH3βs value but byte 9 is mixed. The first two bits contain the 2 least significant bits of CH3βs value, and the remaining six bits contain the six most significant bits of CH2βs value.
Secondly, you may notice we capture both analog and digital information for each secondary channel. Based on the
secondary channel modes
passed to the packet constructor, we will present the proper value read (analog or digital) to the user.In terms of reading the digital status values, the byte is decoded as follows:
The raw packet and several values from the device (with the same names as the parameters) needed for calculations are passed to the constructor. Outside of testing, users should never be instantiating this class directly, that should be limited to instances of the
Pod8401HR
class.- Parameters:
preamp_gain (
tuple
[int
]) β Tuple storing the pramplifier gain for all four channels.ss_gain (
tuple
[int
]) β Tuple storing the second-stage gain for all four channels.primary_channel_mode β A tuple containing the mode of operation for each primary channel (EEG/EMG or Biosensor).
secondary_channel_modes (
tuple
[SecondaryChannelMode
]) β A tuple containing the mode of operation for each secondary (TTL/AEXT) channel (analog or digital).raw_packet (
bytes
) β Raw bytes of packet read from device.
- property ch0: intο
- Returns:
Value read from channel 0.
- property ch1: intο
- Returns:
Value read from channel 1.
- property ch2: intο
- Returns:
Value read from channel 2.
- property ch3: intο
- Returns:
Value read from channel 3.
- property ext0: int | DigitalSignalο
- Returns:
Value read from EXT0.
- property ext1: int | DigitalSignalο
- Returns:
Value read from EXT1.
- property ttl1: int | DigitalSignalο
- Returns:
Value read from TTL1.
- property ttl2: int | DigitalSignalο
- Returns:
Value read from TTL2.
- property ttl3: int | DigitalSignalο
- Returns:
Value read from TTL3.
- property ttl4: int | DigitalSignalο
- Returns:
Value read from TTL4.