Running Blocks of Trials
To run a block of trials that is set up in the GUI, first set up you experiment using the GUI and then add this line of code when SightLab is called (where "2" is the number of repetitions or "blocks" you want to run):
sl.SightLab(repetitions= 2)
or, if not wanting to see GUI, use this code
sightlab = sl.SightLab(configpath = "sightlab\_configs/Randomize Blocks.stlb", repetitions = 2\)
configPath \- the path to the sightlab\_config file that was created from the GUI (the project that you saved in "sightlab\_configs")
How to set a condition that only happens the first block
if sightlab.getTrialNumber() == 1 and sightlab.getCurrentRepetition() == 1:
This could be something like waiting for a keypress or showing an instruction screen
yield sightlab.startTrial(condition = [KEY_PRESS,SPACEBAR])
Example in Context
Find this example in ExampleScripts\- Randomize \- SightLab\_VR\_Randomize\_Blocks.py
. In the included Example there are 3 trials that are set to randomize between 3 different environments (by checking "Randomize" in the GUI when configuring the .stlb file).
import sightlab_utils.sightlab as sl
from sightlab_utils.settings import *
#Setup SightLab Options
sightlab = sl.SightLab(configpath = "sightlab_configs/Randomize Blocks.stlb", repetitions = 2)
def sightLabExperiment():
yield viztask.waitEvent(EXPERIMENT_START)
for trial in range(sightlab.getTrialCount()):
if sightlab.getTrialNumber() == 1 and sightlab.getCurrentRepetition() == 1:
yield sightlab.startTrial(condition = [NO_CONDITION, ""], startExperimentText =
"Press trigger When Ready")
elif sightlab.getTrialNumber() > 1:
yield viztask.waitEvent(TRIAL_START)
yield viztask.waitEvent(TRIAL_END)
viztask.schedule(sightlab.runExperiment)
viztask.schedule(sightLabExperiment)
viz.callback(viz.getEventID('ResetPosition'), sightlab.resetViewPoint)