Pynapse has built in slots for Synapse mode change events. These are useful in the 'Always' state to initialize variables or buffers for stimulation before the recording begins. It also has a built-in instance of SynapseAPI to control other gizmo parameters from Pynapse.
Slot Methods for Responding to Synapse Mode Changes
These slots capture Synapse system mode change events. They are available as method definitions inside Pynapse states. Write a method with this name to react to the corresponding mode change event.
If you use
s_Mode_standby(), this overrides the 'Initial State' setting on the
Preload a stimulus output buffer before the experiment runs
import numpy as np class Always: #StateID = 0 def s_Mode_standby(): import random p_Output.MyOutput.setBuffer(np.random.random(1000).tolist())
When experiment starts, switch to PreTrial state as the default starting state.
class Always: #StateID = 0 def s_Mode_standby(): p_State.switch(PreTrial)
Pynapse also exposes an instance of the SynapseAPI class as the variable
syn in the source code editor.
syn. in the Code Editor and code completion shows you all of the available method calls. For the
complete list of SynapseAPI methods and how to use them, see
SynapseAPI calls goes through sockets, and that adds some extra delay. The SynapseAPI calls are also affected by what is happening in the Synapse window. For example, if you do something that is graphically intensive such as resizing the windows during a recording, you can see a big (>100 ms) lag before the call gets through. It shouldn't be relied on for time critical events.
User puts system into Standby mode, then when trigger is received Pynapse switches system to Record mode.
class Always: #StateID = 0 def s_MyInput_rise(): syn.setModeStr('Record')