Using a Timer for Experiment

There are a few ways you can set up your experiment to run on a timer. Perhaps the easiest would be to use the start and end conditions in the GUI. You can set the first trial to wait for a signal to start (such as Custom Event- triggerPress or Key Press - SPACEBAR, then set the timer for all trials to use End- Timer  and choose number of seconds to run. Each subsequent trial could use a Start- Timer to choose how long of a cooldown you want between trials. 

To see another method of setting this up with code see the ExampleScript - "Timer". This uses the built in startTrial(trialLength) to choose how long to run trials and viztask.waitTime to set up the cooldown. You can also use viztask.waitTime for the trial length if you want. 

import sightlab_utils.sightlab as sl

from sightlab_utils.settings import *


sightlab = sl.SightLab()


import viztask

def sightLabExperiment():

yield viztask.waitKeyDown(' ')

while True:

yield sightlab.startTrial(trialLength=3)

yield viztask.waitEvent(TRIAL_END)

yield viztask.waitTime(2)

viztask.schedule(sightlab.runExperiment)

viztask.schedule(sightLabExperiment)