Rating scales

In some experiments, you will want to give the participant the option of rating some stimuli on a rating scale of for example 1-10. For this you will need to create a rating scale on the screen where the stimuli is shown, and you will want to record the participant's rating of the stimuli. This section focuses on teaching you how to do that.

Lets imagine, for instance, that we were interested in participants' emotional reactions to some pictorial stimuli. Then we could present images one-by-one and ask participants to rate the emotional intensity of the images on a scale from 1-10, where 1 is negative and 10 is positive.

The rating scale function is part of the visual module, so we will make sure to have that loaded. Also we need to define a window.

# load modules
from psychopy import visual

# define window
win = visual.Window()

Then let define our rating scale using the function visual.RatingScale(). This function has a lot of parameters and for once, psychopy's defaults are often not what you want, so here follows a suggestion to how we can specify these in order to get a nice and functional rating scale:

# define rating scale
ratingScale = visual.RatingScale(win, 
    scale = None,                                    #This makes sure there's no subdivision on the scale.
    low = 1,                                         #This is the minimum value I want the scale to have.
    high = 10,                                       #This is the maximum value of the scale.
    singleClick = True,                              #This allows the user to submit a rating by one click.
    showAccept = False,                              #This shows the user's chosen value in a window below the scale.
    markerStart = 5,                                 #This sets the rating scale to have its marker start on 5.
    labels = ['Negative Emotion', 'Positive Emotion'], #This creates the labels.
    pos = [0, -0.6])                                 #This sets the scale's position.

# show the rating scale until participant clicks 
while ratingScale.noResponse:
    ratingScale.draw()
    win.flip()

# record the response, i.e. the rating 
rating = ratingScale.getRating()
# print rating to the console
print(rating)

Notice that here we are using a new kind of loop, while. A while-loop create a state where things are repeated infinitely until a certain condition change. In this case, the condition is defined by the command ratingScale.noResponse. This means that the rating scale will continue to be drawn, updated and shown as long as the participant doesn't respond by clicking with the mouse on the desired rating.

Often this procedure will be part of a sequence where the participant sees an image and then responds to it through a number of trials. Below you will see an example of what such a script could look like.

# import the necessary modules:
from psychopy import visual
import glob 

# define the window. Notice that here we will get a window in full screen and with the color black
win = visual.Window(fullscr=True, color='black')

# set the path to the image directory
path = "images/"

# get all the image names from the directory
images = glob.glob(path + "*.jpg")

# then we loop through the images and for each image we also draw a rating scale  
for i in images: 

    # stimulus object 
    stimulus = visual.ImageStim(win, image = i, pos = [0,0.3]) 

    # create the rating scale:
    ratingScale = visual.RatingScale(win, 
          scale = None,          #This makes sure there's no subdivision on the scale.
          low = 1,               #This is the minimum value I want the scale to have.
          high = 10,             #This is the maximum value of the scale.
          singleClick = True,    #This allows the user to submit a rating by one click.
          showAccept = False,    #This shows the user's chosen value in a window below the scale.
          markerStart = 5,       #This sets the rating scale to have its marker start on 5.
          labels = ['Negative Emotion', 'Positive Emotion'], #This creates the labels.
          pos = [0, -0.6])       #This sets the scale's position.

    # draw and show the image and the rating scale
    while ratingScale.noResponse:
        stimulus.draw()
        ratingScale.draw()
        win.flip()

    # record the response, i.e. the rating 
    rating = ratingScale.getRating()
    # print rating to the console
    print(rating)

# close window
win.close()

Notice that so far we are just printing the responses to the console. This is not very practical. But in a later chapter we will see how we can record and save responses to a .csv logfile.

Figure 3.10: An example of how your screen could look after completing the steps above.

results matching ""

    No results matching ""