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:

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")

repetitions - How many blocks you want to run


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). Note: If using a condition like startExperimentText, you would need to set the condition in the GUI to be whatever is the default one and use condition = in the code. This is different than the normal setup for the GUI with instructions. 

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)