2

I want to present the same rating scale multiple times in a for loop.

I tried doing it like this

for i in range(5):
    while rating_scale.noResponse:
        rating_question.draw()
        rating_scale.draw()
        win.flip()
        if event.getKeys(['escape']):
            core.quit()

But it doesn't present the rating scale multiple times. It just gives the value of the first loop 5 times.

So, I thought, maybe if I redefine the rating scale (I have two rating scales PsychoPy can choose from):

rating_question     = visual.TextStim(win, text = "Hoe moeilijk vond je deze trial?", pos = (0,0.5))
rating_scale_1      = visual.RatingScale(win, low=0, high=100, marker='slider', tickMarks=[0, 25, 50, 75, 100], stretch=2, tickHeight=1.5, labels=["Heel makkelijk", "Makkelijk", "Neutraal", "Moeilijk", "Heel moeilijk"], showValue=False)
rating_scale_2      = visual.RatingScale(win, low=0, high=100, marker='slider', tickMarks=[0, 25, 50, 75, 100], stretch=2, tickHeight=1.5, labels=["Heel moeilijk", "Moeilijk", "Neutraal", "Makkelijk", "Heel makkelijk"], showValue=False)
rating_scales       = [rating_scale_1, rating_scale_2]

for i in range(5):
    rating_scale = rating_scales[random.randint(0,2)]
    while rating_scale.noResponse:
        rating_question.draw()
        rating_scale.draw()
        win.flip()
        if event.getKeys(['escape']):
            core.quit()

But this gives an error, because, I assume, it automatically chooses the same rating scale 5 times. So, when the random integer is different in following loops, it just doesn't work.

So, then I tried it like this, but it just does the same as the first part of code. Still only one presentation of the rating scale and 5 times the same value.

for i in range(5):
    rating_scale = rating_scales[1]
    while rating_scale.noResponse:
        rating_question.draw()
        rating_scale.draw()
        win.flip()
        if event.getKeys(['escape']):
            core.quit()

I know why it happens (because I say the loop only has to present when there is no response), but I have no idea how to fix it. Rating scale has nothing like a .clear() property as far as I know.

halfer
  • 19,824
  • 17
  • 99
  • 186
Selin
  • 33
  • 3
  • PsychoPy is an open-source application allowing you run a wide range of neuroscience, psychology and psychophysics experiments. It’s a free, powerful alternative to Presentation™ or e-Prime™, written in Python – Selin Mar 10 '19 at 15:59
  • Thanks for the clarification. I have corrected "psychopy" (which sounded like a mistranslation of a word to English) to "PsychoPy", with the correct case. – halfer Mar 10 '19 at 16:00

1 Answers1

1

You need to take some action in between one response and the next, something like:

for trial in trials:

    # update the question for this trial:
    rating_question.text = trial['question']

    # present the rating scale:        
    while rating_scale.noResponse:
        rating_question.draw()
        rating_scale.draw()
        win.flip()
        if event.getKeys(['escape']):
            core.quit()

    # a response was made, so save it on each iteration
    trials.addData('rating.response', rating.getRating())
    trials.addData('rating.rt', rating.getRT())

    # reset the scale to its original state for the next iteration:
    rating_scale.reset()

Above, trials represents the TrialHandler handler object you are using to control your trials.

Michael MacAskill
  • 2,411
  • 1
  • 16
  • 28