This documentation is for a legacy ScanImage version. The current documentation is ScanImage 2019.

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

On-Demand Mode Basics

On-demand mode for ScanImage Photostimulation allows output of stimulus patterns in a random access fashion. Any pattern can be immediately commanded at any time. This allows a high level of experimental flexibility but at the cost of some determinism. Unlike sequence mode, since the next stimulus to be output is not known beforehand, at the moment when a stimulus is commanded there is a non-deterministic delay associated with loading the desired stimulus into the analog output buffer and triggering it. This delay is dependent on factors such as the size of the stimulus pattern and the performance and current load on the CPU and typically is on the order of 1-100 ms. The following screenshot shows a simple setup for on-demand mode:

In this case four stimulus patterns have been defined. When the "START" button is clicked, the photostimulation module goes into active mode where it is waiting for the user to request a stimulus. This can be done by double clicking the desired stimulus in the list on the left (or via the command line API). If the "Stim immediately" option is on the stimulus is output immediately (with some non-deterministic delay). If "Stim immediately" is off, the stimulus is loaded into the analog output buffer, the waits for an external or software trigger. If allow mulitple outputs is on, once a stimulus is commanded it can be triggered multiple times. The following examples show behavior with the various selections for these options.

Stim Immediately: ON, Allow multiple outputs: OFF

Stim Immediately: OFF, Allow multiple outputs: OFF
In this example, (1) indicates the time points where the buffer has been loaded and the output is awaiting a trigger. While the time it takes to load the buffer is non-deterministic (and triggers that arrive during this time are ignored) once the buffer is loaded the stimulus starts deterministically with the next trigger. Note, the triggers indicated by (2) were ignored because since "Allow multiple outputs" is off. A stimulus can only be triggered once after being commanded.

Stim Immediately: OFF, Allow multiple outputs: ON
As with the last example, (1) indicates the time points where the buffer has been loaded and the output is awaiting a trigger. Since "Allow multiple outputs" is on, once a stimulus is commanded it can be triggered for an unlimited number of outputs. It stays loaded in the analog output buffer until a different stimulus is requested.

Stim Immediately: ON, Allow multiple outputs: ON


Just as with sequence mode, a synchronization signal can be used to align the start of any stimulus with an external source. A common use case of this is if you always want the start of stimuli to coincide with the start of imaging frames. The following is an example of functioning with a sync signal.

Stim Immediately: ON, Allow multiple outputs: ON, Sync PFI Terminal: PFI2 (frame clock wired in)


When using on-demand mode, hot keys can be enabled for faster access to commands. When the photostim module is active, with the hotkey option enabled, the following hotkeys are available:

  • Number Keys (0-9): Pressing a number key performs the same action as double clicking that stimulus in the list. Following the above example, pressing 3 will command the output of "Stim group C." The zero key allows commanding of groups numbered above 9. Each time 0 is pressed, 10 is added to the next number selected. For instance, the key combination 0-4 will output group 14. The combination 0-0-0-6 will output group 36.
  • T: Striking the "t" key sends a software trigger
  • S: Striking the "s" key sends a software sync signal
  • A: Striking the "a" key aborts the experiment

External Stimulus Selection

The external stimulus selection capability allows complete control of the photostim module using external digital signals. This is ideal if a separate system is controlling the experiment and needs to be able to command certain stimuli with digital triggers. To utilize this feature, PFI terminals are assigned to stimuli using the "Terms" and "Stimuli" settings. For example, if "Terms" is set to "7 8 9 10" and stimuli is set to "1 2 3 4", PFI terminal 7 indicates that stimulus 1 should be output, ect. The last option that needs to be set is the trig term. This is the terminal that triggers the selection operation. The following example shows the experimental setup and the behavior that results.

 Image Added