Zapit Optostim
  • Zapit Optostim: Introduction
    • Feature List
    • FAQ
  • Installation and Setup
    • Hardware setup
    • Software setup
    • Configuring Zapit
      • General settings
      • NI DAQ settings
      • Experiment settings
      • Scanner & Camera settings
      • Laser Power Calibration
      • Blanking settings
    • Staying up to date
  • Using the GUI
    • Introduction: Using the GUI
    • Scanner Calibration
    • Sample Calibration
    • StimConfig Editor
    • Generating stimulus patterns at the CLI
    • Advanced Usage
  • Running Experiments
    • Introduction: Running Experiments
    • MATLAB
      • Basic API Usage in MATLAB
      • Running an Experiment in MATLAB
    • Python
      • Connecting Python to Zapit
      • Basic Zapit API Use in Python
    • Remote Control and Other Programming Languages
  • Developer Notes
    • Project Structure
    • Conventions
    • Hints and Tips
Powered by GitBook
On this page
  1. Running Experiments
  2. Python

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()
PreviousConnecting Python to ZapitNextRemote Control and Other Programming Languages

Last updated 1 year ago