Skip to content

Gizmo Outputs

You can have up to 8 gizmo outputs from the Pynapse gizmo. The outputs can be logic signals that are either turned on/off, triggered for a single sample, or strobed high for a fixed duration. You can also load a custom analog waveform into a buffer and trigger Pynapse to play it out.

Set the Name of the output to something that makes sense for your experiment, e.g. 'Reward'. This will be used throughout the Python code and to link to other gizmos.

You can optionally save epoch timestamp events for each output. A timestamp is saved when the output turns on. If the output is high for more than 2 samples then the offset is stored as well.

Triggered - output stays high for a fixed amount of time (controlled by hardware). If Duration is 0, this is a single sample.

Strobed - output turns on when the turnOn() method is called and turns off when the turnOff() is called.

See Synchronizing Events for information on the Sync to State Change option.

In the Buffer Options, there is an optional low pass filter (Image Filter) to remove aliased signals. If unsure, set this to ~⅓ of the output Sample Freq.

Buffering

Buffering lets you write a small waveform to hardware memory and trigger it for presentation. This allows you to create fully custom stimuli on the fly, either pre-loaded or adaptive in response to behavioral events.

Parameter Outputs

Pynapse has a set of Parameter outputs which can control all parameters that define a stimulation gizmo. For example, control the waveform parameters of an Audio Stimulation gizmo or an Electrical Stim Driver gizmo directly from Pynapse. This mimics the behavior of the Parameter Sequencer gizmo. Create the parameters on the fly based on subject feedback, or play from a python-generated list. See Parameter Methods below.

See Synchronizing Events for information on the Sync to State Change option.

Tip

See Using Parameters for more general information on parameters.

Output Methods

All output methods have the form p_Output.{OUTPUT_NAME}.{METHOD}. Type p_ in the Pynapse Code Editor and let the code completion do the work for you. 'Output1' is the default name of the first output. The name of each method gets replaced with the name of your actual output, so if you name the output 'Reward' then p_Output.Reward.fire() is an available method.

Manual Control

Manual turn outputs on, off, or fires a pulse waveform during runtime. Useful for stimulus/ reward presentation.

fire

p_Output.MyOutput.fire()

Quickly pulse the output. This is only available when Control Mode is set to Triggered. If Duration is non-zero, the output will stay high for that set duration. Set Duration to zero to use this output to trigger other gizmos e.g. trigger an Audio Stimulation gizmo. If Output Type is Buffer, this will play the output buffer one time.

Example

Trigger an output when the input goes high.

class Always:   #StateID = 0

    def s_MyInput_pass():
        p_Output.MyOutput.fire()

turnOn

p_Output.MyOutput.turnOn()

Turn the output on indefinitely. If the output is a buffer, it will continuously loop until turned off. This is only available when Control Mode is set to Strobed.

Example

Link an input status to an output.

class Always:   #StateID = 0

    def s_MyInput_rise():
        p_Output.MyOutput.turnOn()

    def s_MyInput_fall():
        p_Output.MyOutput.turnOff()

turnOff

p_Output.MyOutput.turnOff()

Turn the output off. This is only available when Control Mode is set to Strobed.

Example

Link an input status to an output.

class Always:   #StateID = 0

    def s_MyInput_rise():
        p_Output.MyOutput.turnOn()

    def s_MyInput_fall():
        p_Output.MyOutput.turnOff()

Duration Settings

setPulseShape

p_Output.MyOutput.setPulseShape(dur_sec, outval=None)

Override the output Duration (if Control Mode is set to Triggered) and the Output Value settings (if Output Type is set to Float or Integer).

Inputs Type Description
dur_sec float Duration of the output pulse when triggered with fire, in seconds
outval float or integer Output value when true
Example

Modify the pulse shape and output value based on performance.

def s_State_enter():
    # if more than 5 successful trials, decrease the output pulse time by 50 ms and output value by 1.
    if p_Metric.success.read() > 5:
        p_Metric.pulse_dur.dec(delta=0.05)
        p_Metric.output_val.dec(delta=1)
        p_Output.MyOutput.setPulseShape(p_Metric.pulse_dur.read(), p_Metric.output_val.read())

setDuration

p_Output.MyOutput.setDuration(dur_sec)

Override the output Duration (if Control Mode is set to Triggered) setting.

Inputs Type Description
dur_sec float Duration of the output pulse when triggered with fire, in seconds
Example

Modify the pulse shape and output value based on performance.

def s_State_enter():
    # if more than 5 successful trials, decrease the output pulse time by 50 ms.
    if p_Metric.success.read() > 5:
        p_Metric.pulse_dur.dec(delta=0.05)
        p_Output.MyOutput.setDuration(p_Metric.pulse_dur.read())

setValue

p_Output.MyOutput.setValue(outval)

Override the output Output Value setting (if Output Type is set to Float or Integer).

Inputs Type Description
outval float or integer Output value when true
Example

Modify the pulse shape and output value based on performance.

def s_State_enter():
    # if more than 5 successful trials, decrease the output value by 1.
    if p_Metric.success.read() > 5:
        p_Metric.output_val.dec(delta=1)
        p_Output.MyOutput.setValue(p_Metric.output_val.read())

Buffer operations

Load a list of values into a memory buffer on the hardware and trigger playback.

setBuffer

p_Output.MyOutput.setBuffer(wave)

Loads a python list or NumPy array into an output buffer. Call fire to play the output buffer once. Call turnOn to play buffer on a loop until calling turnOff. Supports waveforms between 2 and 100,000 samples long.

Inputs Type Description
wave list List of numbers to load into output buffer
Example

Load an output buffer with 1,000 random numbers before the recording starts, and trigger it when MyInput goes true.

import numpy as np

class Always:   #StateID = 0

    def s_Mode_standby():
        import random
        p_Output.MyOutput.setBuffer(np.random.random(1000).tolist())

    def s_MyInput_rise():
        p_Output.MyOutput.fire()

Status

Get information on the current state of the output.

isOn

p_Output.MyOutput.isOn()

Returns true if the output is currently true.

Example

When entering a state, check if an output is already true.

def s_state_enter():
    if p_Output.MyOutput.isOn():
        print('MyOutput is on')
    else:
        print('MyOutput is off')    

isOff

p_Output.MyOutput.isOff()

Returns true if the output is currently false.

Example

When entering a state, check the status of the output.

def s_state_enter():
    if p_Output.MyOutput.isOff():
        print('MyOutput is off')
    else:
        print('MyOutput is on')    

Parameter Methods

All parameter methods have the form p_Param.{PARAMETER_NAME}_write. Type p_ in the Pynapse Code Editor and let the code completion do the work for you. 'Par1' is the default name of the first parameter. The name of each write method gets replaced with the name of your actual parameter, so if the parameter is called 'Freq' then p_Param.Freq_write(val) is an available method.

Par1_write

p_Param.Par1_write(val)

Write a new value for this parameter.

Inputs Type Description
val float Floating point value to send to this parameter output
Example

Modify the wave frequency for an Audio Stimulation gizmo when a state changes.

class PrepStim:   #StateID = 0
    def s_State_enter():
        # get next stim ready
        wave_freq = 1000
        p_Param.p_Param.WaveFreq_write(wave_freq)

List_write

p_Param.List_write(vlist)

Write all the parameters at once using a list.

Inputs Type Description
vlist list List of floating point numbers to send to all parameter outputs
Example

Prepare a list of stimulation parameters for an Audio Stimulation gizmo when a state changes.

class PrepStim:   #StateID = 0
    def s_State_enter():
        # get next stim ready
        pulse_count = 3
        pulse_period = 100
        wave_freq = 1000
        p_Param.List_write([pulse_count, pulse_period, wave_freq)