bpod_base
— Bpod Base¶
Implementation¶
-
class
pybpodapi.bpod.bpod_base.
BpodBase
(serial_port=None, sync_channel=None, sync_mode=None, net_port=None)[source]¶ API to interact with Bpod
Variables: -
open
()[source]¶ Starts Bpod.
Connect to Bpod board through serial port, test handshake, retrieve firmware version, retrieve hardware description, enable input ports and configure channel synchronization.
Example:
my_bpod = Bpod().open("/dev/tty.usbmodem1293", "/Users/John/Desktop/bpod_workspace", "2afc_protocol")
Parameters: - serial_port (str) – serial port to connect
- workspace_path (str) – path for bpod output files (no folders will be created)
- session_name (str) – this name will be used for output files
- baudrate [optional] (int) – baudrate for serial connection
- sync_channel [optional] (int) – Serial synchronization channel: 255 = no sync, otherwise set to a hardware channel number
- sync_mode [optional] (int) – Serial synchronization mode: 0 = flip logic every trial, 1 = every state
Returns: Bpod object created
Return type: pybpodapi.model.bpod
-
send_state_machine
(sma, run_asap=None)[source]¶ Builds message and sends state machine to Bpod
Parameters: sma (pybpodapi.model.state_machine) – initialized state machine
-
run_state_machine
(sma)[source]¶ Adds a new trial to current session and runs state machine on Bpod box.
While state machine is running, messages are processed accordingly.
When state machine stops, timestamps are updated and trial events are processed.
Finally, data is released for registered data consumers / exporters.
See also
Send command “run state machine”:
pybpodapi.bpod.bpod_base.BpodBase.run_state_machine()
.Process opcode:
pybpodapi.bpod.bpod_base.BpodBase._BpodBase__process_opcode()
.Update timestamps:
pybpodapi.bpod.bpod_base.BpodBase._BpodBase__update_timestamps()
.:param (
pybpodapi.state_machine.StateMachine
) sma: initialized state machine
-
load_serial_message
(serial_channel, message_ID, serial_message)[source]¶ Load serial message on Bpod
Parameters:
-
reset_serial_messages
()[source]¶ Reset serial messages to equivalent byte codes (i.e. message# 4 = one byte, 0x4)
-
softcode_handler_function
(data)[source]¶ Users can override this function directly on the protocol to handle a softcode from Bpod
Parameters: data (int) – soft code number
-