Adding a Rating Scale GUI

There are examples in the ExampleScripts folder under "RatingScale_GUI" to see how to have the rating available. You can use different yield statements to trigger the rating GUI to show up.


#Import modules, along with rating module

import viz, vizfx, viztask

from utils import sightlab

from utils import rating

from settings import *


#Set to 1 for GUI and 0 for not using the GUI

sightlab.is_GUI = 1


#run sightlab experiment

def sightLabExperiment():

yield viztask.waitKeyDown(' ')

viz.sendEvent(TRIAL_START_EVENT)

#Trigger in this example is rating will show after 5 seconds

yield viztask.waitTime(5)

#Set Rating Text and Show Rating Scale

rating.setRatingText('How Are You Feeling?')

yield rating.showRating()

yield viztask.waitKeyDown(' ')

viz.sendEvent(TRIAL_END_EVENT)


viztask.schedule(sightlab.experiment)

viztask.schedule(sightLabExperiment)


For getting access to the rating value you can use this code:

chosen_rating = rating.feeling


And for something to change based on the rating value:

if chosen_rating >= 8:  

  print("Rating too high.")


There are many options available to trigger an event. Here are just a few examples: 

When you run the experiment now the rating will show up after the specified trigger. Use the right hand trigger to proceed and the left and right trackpad or thumbstick to choose the answers. For the desktop use the left mouse button and arrow keys. 

The chosen values will also be saved in the tracking_data.txt file


To use 360 videos, just use the example file RatingScale_GUI_360 


import viz, vizfx,viztask

from utils import sightlab_360

from utils import rating360

from settings import *


def sightLabExperiment():

        

        yield viztask.waitKeyDown(' ')

        

        yield viztask.waitTime(5) 

        rating360.setRatingText('How Are You Feeling?')

        yield rating360.showRating()

        

        yield viztask.waitKeyDown(' ')

        

viztask.schedule(sightlab_360.experiment)

viztask.schedule(sightLabExperiment)

As of version 1.9.8 you can also use the version 2 of the Rating GUI to be able to use strings of text for the rating as well (see also ExampleScripts- Rating_Scale_GUI_v2


import viz, vizfx, viztask

from utils import sightlab

from utils import rating_v2

from settings import *


#Set to 1 for GUI and 0 for not using the GUI

sightlab.is_GUI = 1


ratingNew = rating_v2.Ratingv2()


scaleList = ["A", "B", "C"]


#run sightlab experiment

def sightLabExperiment():

yield viztask.waitKeyDown(' ')

viz.sendEvent(TRIAL_START_EVENT)

yield viztask.waitTime(1)

#Set Rating Text and Show Rating Scale

yield ratingNew.showRatings('test', ratingScale = scaleList)

final_choice = ratingNew.getFinalChoice()

print("Final choice:", final_choice)

yield viztask.waitKeyDown(' ')

viz.sendEvent(TRIAL_END_EVENT)


viztask.schedule(sightlab.experiment)

viztask.schedule(sightLabExperiment)