bpod_core.bpod.structs

Data structures used by the bpod module.

Classes

class bpod_core.bpod.structs.BpodInfo

Bases: Struct

Information about a specific Bpod device.

location: str

User-defined location of the device.

name: str

User-defined name of the device.

port: str | None

Port on which the device is connected.

serial_number: str

Serial number of the device.

zmq_pub: str | None

ZeroMQ PUB service address.

zmq_rep: str | None

ZeroMQ REP service address.

class bpod_core.bpod.structs.BpodMessage

Bases: Struct

Base Envelope for a Bpod IPC message.

class bpod_core.bpod.structs.BpodMessageBye

Bases: BpodMessageHello

Envelope for a disconnect notice.

class bpod_core.bpod.structs.BpodMessageCallRequest

Bases: BpodMessage

Envelope for a method call request.

args: tuple

The arguments to be passed to the method.

kwargs: dict[str, Any]

Keyword arguments to be passed to the method.

method_name: str

The name of the method to be called.

class bpod_core.bpod.structs.BpodMessageDataRequest

Bases: BpodMessageCallRequest

Envelope for a data request.

compression: Literal['uncompressed', 'lz4', 'zstd']

The compression method to be used for the data.

class bpod_core.bpod.structs.BpodMessageGeneric

Bases: BpodMessage

Envelope for a generic message.

data: Any

The content of the reply.

class bpod_core.bpod.structs.BpodMessageHello

Bases: BpodMessage

Envelope for a handshake request.

bpod_core_version: str

The version of bpod-core that the client is using.

ip: str

The client’s IP address.

local: bool

Whether the client is running on the same machine as the host.

pid: int

The process ID of the client.

class bpod_core.bpod.structs.BpodMessageWelcome

Bases: BpodMessage

Envelope for a handshake reply.

location: str | None

The Bpod’s user-defined location.

name: str | None

The Bpod’s user-defined name.

serial_number: str

The Bpod’s unique serial number.

version: VersionInfo

Version information of the Bpod’s firmware and hardware.

class bpod_core.bpod.structs.BpodSettings

Bases: Struct

Settings for a specific Bpod device.

location: str

User-defined location of the device.

name: str

User-defined name of the device.

serial_number: str

Serial number of the device.

zmq_port_pub: int | None

Port number for the ZeroMQ PUB service.

zmq_port_rep: int | None

Port number for the ZeroMQ REP service.

class bpod_core.bpod.structs.HardwareConfiguration

Bases: Struct

Represents the Bpod’s on-board hardware configuration.

cycle_frequency: int

Frequency of the state machine’s refresh cycle during a trial in Hertz.

cycle_period_us: int

Period of the state machine’s refresh cycle during a trial in microseconds.

input_description: bytes

Array indicating the state machine’s onboard input channel types.

max_bytes_per_serial_message: int

Maximum number of bytes allowed per serial message.

max_serial_events: int

Maximum number of behavior events allocatable among connected modules.

max_states: int

Maximum number of supported states in a single state machine description.

n_conditions: int

Number of condition-events supported.

n_global_counters: int

Number of global counters supported.

n_global_timers: int

Number of global timers supported.

n_inputs: int

Number of input channels.

n_modules: int

Number of modules supported by the state machine.

n_outputs: int

Number of channels in the state machine’s output channel description array.

output_description: bytes

Array indicating the state machine’s onboard output channel types.

class bpod_core.bpod.structs.RawEvent

Bases: NamedTuple

Raw event data from the Bpod device.

event_id: int

Index of the event.

micros_us: int

Time of the event relative to the Bpod’s session clock (microseconds).

class bpod_core.bpod.structs.RawSoftcode

Bases: NamedTuple

Raw softcode data from the Bpod device.

micros_us: int

Bpod session clock at the time of softcode firing (microseconds).

received_ns: int

time.perf_counter_ns() captured immediately after the serial read.

softcode: int

Zero-based softcode value.

class bpod_core.bpod.structs.StateMachineLookup

Bases: NamedTuple

Lookup data to decode the raw event stream during a state machine trial.

fsm_hash: bytes

The state machine’s hash value.

state_actions: list[dict[str, int]]

Per-state mapping of action name to value.

state_lookup: dict[int, str]

Mapping from state index to state name.

state_names: list[str]

Names of all states, indexed by state index.

state_transition_matrix: ndarray[tuple[Any, ...], dtype[uint8]]

Transition matrix of shape (n_states, 255).

use_back_op: bool

Whether the >back operator is used.

class bpod_core.bpod.structs.TimeReferences

Bases: NamedTuple

Reference values for performance counters.

init_perf_counter_ns: int

Performance counter at class initialization (nanoseconds).

init_system_time_ns: int

System time at class initialization (nanoseconds relative to epoch).

reset_system_time_ns: int

System time when Bpod’s session clock was last reset (nanoseconds).

class bpod_core.bpod.structs.VersionInfo

Bases: Struct

Data structure representing various version information.

bpod_core: str

bpod-core version

firmware: tuple[int, int]

Firmware version (major, minor)

machine: int

Machine type (numerical)

machine_str: str

Machine type (string)

pcb: int | None

PCB revision, if applicable