Skip to content

Synapse Control

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.

Slot name Event
s_Mode_change(newmode) Triggers on any mode change
s_Mode_idle Mode changed to idle
s_Mode_standby Mode changed to standby
s_Mode_preview Mode changed to preview
s_Mode_record Mode changed to record
s_Mode_recprev Mode changed to preview or record


If you use p_State.switch() inside s_Mode_standby(), this overrides the 'Initial State' setting on the General Tab.


Preload a stimulus output buffer before the experiment runs

import numpy as np

class Always:   #StateID = 0
    def s_Mode_standby():
        import random

When experiment starts, switch to PreTrial state as the default starting state.

class Always:   #StateID = 0
    def s_Mode_standby():


Pynapse also exposes an instance of the SynapseAPI class as the variable syn in the source code editor. Type 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 Manual.


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():