PyBpodBase
- class PyBpodBase[source]
Bases:
objectBase class for Bpod interface.
- error
Error message.
- Type:
str
- session
Bpod session object.
- Type:
Session | Any
- connected
Connection status.
- Type:
bool
- __init__()
Methods
__init__()add_state(state_name[, state_timer, ...])Adds a state to the state machine.
close()Closes the connection to the Bpod.
connect(functions)Connects to the Bpod device.
Creates and initializes a new state machine.
led(i, close)Controls an LED.
manual_override_input(message)Simulates an input event manually.
manual_override_output(message)Manually triggers an output.
poke(i, close)Simulates a poke event.
receive_softcode(idx)Handles received softcodes.
register_value(name, value)Registers a value to be tracked or logged.
Sends the current state machine to the Bpod and starts it.
set_condition(condition_number, ...)Sets a condition for the state machine.
set_global_counter(counter_number, ...)Configures a global counter.
set_global_timer(timer_id, timer_duration[, ...])Configures a global timer.
stop()Stops the current trial or operation.
water(i, close)Controls a water valve.
Attributes
- error: str = 'Error connecting to the bpod '
- session: Session | Any = None
- connected: bool = False
- connect(functions: list[Callable]) None[source]
Connects to the Bpod device.
- Parameters:
functions (list[Callable]) – List of callback functions for softcodes.
- add_state(state_name: Any, state_timer: float = 0, state_change_conditions: Any = {}, output_actions: Any = ()) None[source]
Adds a state to the state machine.
- Parameters:
state_name (Any) – Name of the state.
state_timer (float) – Duration of the state in seconds.
state_change_conditions (Any) – Conditions to transition to other states.
output_actions (Any) – Actions to perform in this state.
- set_global_timer(timer_id: Any, timer_duration: Any, on_set_delay: int = 0, channel: Any | None = None, on_message: int = 1, off_message: int = 0, loop_mode: int = 0, loop_intervals: int = 0, send_events: int = 1, oneset_triggers: Any | None = None) None[source]
Configures a global timer.
- Parameters:
timer_id (Any) – ID of the timer.
timer_duration (Any) – Duration of the timer.
on_set_delay (int) – Delay before the timer starts.
channel (Any | None) – Output channel to link.
on_message (int) – Message when timer starts.
off_message (int) – Message when timer ends.
loop_mode (int) – Loop mode.
loop_intervals (int) – Interval between loops.
send_events (int) – Whether to send events.
oneset_triggers (Any | None) – Triggers to set.
- set_condition(condition_number: Any, condition_channel: Any, channel_value: Any) None[source]
Sets a condition for the state machine.
- Parameters:
condition_number (Any) – The condition ID.
condition_channel (Any) – The channel to check.
channel_value (Any) – The value to match.
- set_global_counter(counter_number: Any, target_event: Any, threshold: Any) None[source]
Configures a global counter.
- Parameters:
counter_number (Any) – The counter ID.
target_event (Any) – The event to count.
threshold (Any) – The count threshold.
- create_state_machine() None[source]
Creates and initializes a new state machine.
- send_and_run_state_machine() None[source]
Sends the current state machine to the Bpod and starts it.
- close() None[source]
Closes the connection to the Bpod.
- stop() None[source]
Stops the current trial or operation.
- manual_override_input(message: str) None[source]
Simulates an input event manually.
- Parameters:
message (str) – The input message/event string.
- manual_override_output(message: str | tuple) None[source]
Manually triggers an output.
- Parameters:
message (str | tuple) – The output command.
- register_value(name: str, value: Any) None[source]
Registers a value to be tracked or logged.
- Parameters:
name (str) – Name of the value.
value (Any) – The value itself.
- receive_softcode(idx: int) None[source]
Handles received softcodes.
- Parameters:
idx (int) – The softcode index.
- led(i: int, close: bool) None[source]
Controls an LED.
- Parameters:
i (int) – The LED index.
close (bool) – Whether to turn it off (or close the circuit).
- water(i: int, close: bool) None[source]
Controls a water valve.
- Parameters:
i (int) – The valve index.
close (bool) – Whether to close the valve.
- poke(i: int, close: bool) None[source]
Simulates a poke event.
- Parameters:
i (int) – The poke index.
close (bool) – State of the poke.