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

Introduction: Running Experiments

Integrating photostimulation into your experiments

PreviousAdvanced UsageNextMATLAB

Last updated 9 months ago

Once you have calibrated the scanners and the sample, and loaded a set of stimulus coordinates, you are ready to present the stimuli in an experiment. At this point the GUI plays little role, as the key task is to integrate photostimulation commands into the code that runs your experiment. The Zapit ecosystem provides APIs for and , or you can .

Common Basic Concepts

No matter how you control Zapit, the overall approach will be the same. Zapit can present stimuli of either a precise fixed duration or continuously until terminated with a software command. Laser power is ramped down gently over a user-defined period on stimulus offset. Stimuli can be started either immediately on receipt of a software command or queued until a hardware trigger is received. Optionally, stimulus onset can be delayed with respect to the TTL trigger. These triggering options allow opto-stim to be delivered precisely with respect to other stimuli.

Let's assume you want the photostimulation waveforms triggered by an external hardware trigger and to continue until some event has ceased. Your pseudo-code event sequence will then be something along these lines:

<Trial is initiated>
<Photo-stimulus condition is selected and queued to the DAQ buffer>
...
Misc. stuff happens in the trial
...
An external device or software entity sends a 5V trigger pulse to the Zapit DAQ
<Photo-stimulus begins>
...
Some event of unknown duration occurs
...
<Photo-stimulus is stopped by a software command>
...
Trial ends 

The two key commands needed to achieve these goals are sendSamples (send_samples in Python) and stopOptoStim (stop_opto_stim in Python). The following sections will discuss how these commands are used in practice and discuss other relevant commands. Please read the MATLAB docs even if you won't use MATLAB to control experiements: most of the information there is relevant to Python and TCP/IP.

Knowing what happens in each stimulus condition

Should you need to know what will happen in each stimulus condition you can type hZP.stimConfig.print into the command line to see a text summary.

>> hZP.stimConfig.print

1. ML = +3.56 / AP = -1.24  <-->  ML = -3.56 / AP = -1.24  1' somatosensory barrel field
2. ML = +3.95 / AP = -0.08  <-->  ML = -3.95 / AP = -0.08  1' somatosensory nose
3. ML = +0.01 / AP = -0.91  Retrosplenial dorsal part
4. ML = +2.73 / AP = +1.66  <-->  ML = +1.88 / AP = +0.94  1' motor 
5. ML = -2.73 / AP = -2.98  <-->  ML = -2.73 / AP = -4.09  1' visual 

Alternatively, you can press "Plot stim coords" in the "Calibrate Sample" tab to see a plot of the same information.

This plot is generated by a function called zapit.utils.plotStimuli and you can you can generate the same plot at the MATLAB command line as follows:

>> zapit.utils.plotStimuli(hZP.stimConfig)

This command also accepts file names of stimulus config files, so you can run it on any saved file on disk to visualise its contents (see help zapit.utils.plotStimuli).

MATLAB
Python
PControl Zapit via TCP/IP from any PC or language