psychopy.org | Reference | Downloads | Github

Visual analogue scale: saving data, changing "submit response" button


#1

HI everyone,

I am quite the psychopy and python novice so I think it should be very easy fix but I can’t seem to figure it out myself.

I have created two visual analogue scales in PsychoPy (to be presented 4 times (after 4 blocks) during a task) and now I need to insert some code so that the responses will be saved to .csv/text file with the participant ID and the block number. I have been going over the literature and the forums but I can’t seem to work it out. I have tried a few things and I think the main problem I am having is with the placement of the code in my script. Any advice?

I would also like to have it so that the response number chosen does not appear on the bar at the bottom so that participants are less likely to remember what they selected on previous blocks. I would instead like it to read “submit response” – I can’t seem to find where to change this. I built this scale by editing one of the demos available through PsychoPy. This second issue is less important because I can just comment in “singleClick=‘True’” to ensure that participants cannot see their selection, if need be (this may, in fact, be better as participants will only have one chance for selection but I just worry about them making a mistake by arbitrarily clicking on the scale and not being able to go back and adjust after).

Code is below (apologies – not even sure how to get the code into a box :neutral_face: :

from future import division

from psychopy import visual, event, core, logging
import os

from psychopy import gui

dlg = gui.Dlg(title=“VAS block questions”, pos=(200, 400))
dlg.addText(‘Subject Info’, color=‘Blue’)
dlg.addField(‘participant code:’)
dlg.addField(‘block:’)

thisInfo = dlg.show() # you have to call show() for a Dlg (automatic with a DlgFromDict)
if dlg.OK:
print(thisInfo)
else:
print(‘User cancelled’)

fatigue scale

win = visual.Window(fullscr= ‘false’, size=[1920, 1080], units=‘pix’, monitor=‘testMonitor’)

myRatingScale = visual.RatingScale(win, low=0, high=100, marker=‘slider’,
tickMarks=[0, 100], stretch=1.5, tickHeight=1.5, #singleClick=‘true’, #comment in for single click
labels=[“not at all”, “extremely”])
txt = “How fatigued do you feel right now?”
myItem = visual.TextStim(win, text=txt, height=.08, units=‘norm’)

while myRatingScale.noResponse:
myItem.draw()
myRatingScale.draw()
win.flip()
if event.getKeys([‘escape’]):

    core.quit()

print ‘VAS fatigue =’, myRatingScale.getRating()

#engagement scale

win = visual.Window(fullscr=‘false’, size=[1920, 1080], units=‘pix’, monitor=‘testMonitor’)

myRatingScale = visual.RatingScale(win, low=0, high=100, marker=‘slider’,
tickMarks=[0, 100], stretch=1.5, tickHeight=1.5, #singleClick=‘True’, #comment in for single click
labels=[“not at all”, “extremely”])
txt = “How engaged in the task do you feel right now?”
myItem = visual.TextStim(win, text=txt, height=.08, units=‘norm’)

while myRatingScale.noResponse:
myItem.draw()
myRatingScale.draw()
win.flip()
if event.getKeys([‘escape’]):
core.quit()

print ‘VAS engagement =’, myRatingScale.getRating()

win.close()
core.quit()\

Thanks!


#2

Hi everyone, this has been solved :slight_smile: Thanks anyways


#3

Hi Jen,
How did you do it?
I want to generate a visual analogue scale for a preference rating for each image, with 10 images in each block, and 4 blocks with short breaks in between. I’m a beginner psychopy.