Basic Zapit API Use in Python

Make sure you are first familiar with Basic API Usage in MATLAB.

The following code presents 10 random trials using Zapit's Python bridge.

import zapit_python_bridge.bridge as zpb
from time import sleep

# Create an instance of the bridge object
hZP = zpb.bridge()
num_cond = hZP.num_stim_cond()

numTrials = 10
currentTrial = 1

while currentTrial <= numTrials:
    # Send stimuli and do not log because this an example.
    # In a real experiment you likely want to enable both logging
    # and hardware triggering.
    print("Presenting stimulus %d/%d" % (currentTrial, numTrials))
    hZP.send_samples(conditionNum=-1, hardwareTriggered=False, logging=False)

    sleep(1)

    hZP.stop_opto_stim()
    currentTrial += 1

hZP.release_matlab()

Last updated