Sequence Mode Basics
Sequence mode for ScanImage Photostimulation allows output of stimulus patterns in a prescribed order. When the experiment starts, everytime a trigger arrives the next group in the sequence is output. The trigger can come from software or a digital pulse. Using a digital pulse allows a high level to timing precision to synchronize the stimulation with external events. The following screenshot shows an example of the setup of a sequence mode experiment:
In this example, 4 stimulus patterns have been designed using the stimulus editor. The sequence of "1 2 3 1 1 4" specifies the order that groups will be output. In this case, groups 1, 2, and 3 will be output, then group 1 twice, then group 4. The "Stim immediately" option specifies whether or not the first group will output immediately when the experiment is started. With this option disabled, no output will happen immediately when the experiment starts, as the first output will wait for a trigger. The "Stim Trigger PFI Terminal" specifies the terminal where digital triggers are accepted. The number of sequences specifies how many times the sequence can repeat. If set to infinite, the experiment will continue until aborted. The following figures shows an example of what will happen during the experiment.
As you can see, each trigger causes the next stimulus to be output. Since the number of sequences is greater than 1, after the sequence completes it starts again from the beginning. The next example shows what would happen is "Stim Immediately" was on:
The only difference is that the first stimulus pattern in the sequence was output immediately without waiting for a trigger. All subsequent outputs were then triggered. In this case the time from when the start button is clicked to when the output starts is non deterministic, as software operations such as computing and loading the analog output signals for the scanners.
The stimulus patterns can also be
triggered from software by clicking the trigger button (or using the command line API). Software triggers are inherently non-deterministic so this should be taken into consideration. The following example shows the experiment with "Stim Immediately" off and a combination of software and external triggers.
ScanImage Photostimulation includes a "sync" option if it is desired to ensure that stimulus output always starts synchronized to an external signal. A common example of this is if you always want the start of stimuli to coincide with the start of an imaging frame. To utilize the sync function, set the Sync PFI terminal to the source of the sync signal. With this set, whenever a software or external trigger arrives, the stimulus output begins with the next sync signal. The following example shows the same experiment where the sync terminal is set to PFI2 and the imaging frame clock is wired into this terminal:
You can see that in this example, the sync option ensures that regardless of when a trigger comes, stimulus output always starts at the beginning of a frame. The software trigger still incurs some jitter to when the trigger is registered, but once registered the next output still occurs synchronously with the sync signal.