Converting from 1.9

For GUI based scenes with no modifications:


For scenes that have code modifications, you may need to refer to the SightLab  2.0 Code Attributes and Methods page, but here's a quick overview:

Importing SightLab

Change the typical import statements from this:

import viz, vizfx, viztask

from utils import sightlab

from settings import *

To this:

import sightlab_utils.sightlab as sl

from sightlab_utils.settings import *

Creating the SightLab Instance

Change the code where the sightlab instance is created

sightlab.is_GUI = 0 #for non-GUi

sightlab.is_GUI = 1# for using the GUI

To

sightlab = sl.SightLab(gui = False) #leave empty if running the GUI with default settings

For a list of all the attributes available on the sightlab class see section Class SightLab in SightLab  2.0 Code Attributes and Methods

Setting the Environment Object

Old method of setting the environment object

env = vizfx.addChild("utils/resources/environment/dojo.osgb")

sightlab.objects.append(env)

New Way

env = vizfx.addChild('resources/environments/dojo2.osgb')

sightlab.setEnvironment(env)

Adding Target Objects

Old way

basketball = env.getChild('basketball')

soccerball = env.getChild('soccerball')

sightlab.gazeObjectsDict = {'basketball':basketball,'soccerball':soccerball}

sightlab.grabObjectsDict = {'basketball':basketball,'soccerball':soccerball}

New way 

Either:

sightlab.addSceneObject('basketball',basketball,gaze = True, grab = True)

Or for multiple objects:

sceneDict = {'Soccerball': [True, True],

'Baseball': [True, True],'Globe': [True, True]}


for item in sceneDict:

sightlab.addSceneObject(item, env.getChild(item), gaze = sceneDict[item][0], grab = sceneDict[item][1]) 

Running and scheduling the SightLab Experiment

Old method

def sightLabExperiment():

while True:

yield viztask.waitKeyDown(' ')

viz.sendEvent(TRIAL_START_EVENT)

print('experiment start')


yield viztask.waitKeyDown(' ')

viz.sendEvent(TRIAL_END_EVENT)

print('experiment end')

viztask.schedule(sightlab.experiment)

viztask.schedule(sightLabExperiment)

New Method

def sightLabExperiment():

while True:

yield viztask.waitKeyDown(' ')

yield sightlab.startTrial()


yield viztask.waitKeyDown(' ')

yield sightlab.endTrial()


viztask.schedule(sightlab.runExperiment)

viztask.schedule(sightLabExperiment)

Referencing SightLab Resources

Any references to the resources that used to use "util/resources/..." now need to use "sightlab_resources/..."

This also includes import statements (i.e. "from utils import" change to "from sightlab_utils import")

Except for the avatar head and hands and gaze point, which are referenced as:

AVATAR_HEAD_RESOURCE_PATH, AVATAR_HANDS_RESOURCE_PATH and GAZE_POINT_RESOURCE_PATH

Redirect Code from Old Example Scripts

The redirect code at the top of the old example scripts is no longer necessary, so can be removed if converting a project based on any of those files. 

Setting Condition Based on Vizconnect being Used

Old way:

if VIZCONNECT_CONFIGS[sightlab.configuration] in ['Meta Quest Pro']

New way:

if sightlab.getConfig() == "Meta Pro Body":

Setting Number of Trials

Old way

sightlab.sceneConfigDict["trials"] = 1

New way

sightlab.setTrialCount(3)

Checking which object is being Targeted

Old way:

if e.object == sightlab.gazeObjectsDict['creature1']:

New way:

if e.object == sightlab.sceneObjects[GAZE_OBJECTS][TARGET_PAINTING]:

Toggling Visibility of Overlays

Old way:

sightlab.toggleOverlays()

New way:

sightlab.toggleHUD()

Some of the overlay toggles can also be set when calling sightlab:

sightlab = sl.SightLab(gui=False, fadequad = False, pid = False, gazepointvisible = False, timer = False, console = False)

If not wanting to see mouse cursor

viz.mouse.setVisible(viz.OFF)

Settings

Many settings are now accessible via the sightlab object (see below). The settings file is now in the sightlab_utils folder. See the settings documentation page for more detail

Additional Changes and Notes

TRIAL_END_EVENT is now TRIAL_END

VIZCONNECT_CONFIGS is now VIZCONNECT_CONFIG

ENVIRONMENT is a constant already used, use "ENVIRONMENT_MODEL" instead

Rating Scale

yield sightlab.showRatings('how are you feeling?',ratingScale= scaleList, pauseTimer = True)

scaleList can be anything now (i.e. "A", "B", "C" or "Yes", "No")

sightlab.ratingChoice #Get a handle to the rating that is chosen

Instructions

yield sightlab.showInstructions('test')

yield viztask.waitEvent('triggerPress')

yield sightlab.hideInstructions()

Adding to the Data Files

Note: For more detailed information about all the code changes please see SightLab  2.0 Code Attributes and Methods (much of this information is duplicated there, but that page is more complete)