psychopy.org | Reference | Downloads | Github

Is it possible to make it show the value while the mouse is moving along the RatingScale without click?

Hi All,

I’m using RatingScale in my experiment to let the participant assess their liking towards the presented image. What I want to do is to let the ratingscale show the value where the mouse stops(without click), so that participant can see the value they are going to choose and it will go on to the next trial after a single click.

The part of code is attached below.

baseline_ratingscale = visual.RatingScale(myWin, scale = u'-100=Extremely Dislike . . . . . . . . . . . . . . +100=Extremely Like', size=0.6, markerStart=0, low=-100, high=100, 
        precision =1, pos = (0.0,-0.6),marker = 'circle', 
        showValue = True, singleClick = True, acceptPreText = u'Click on the line') 
    locB_stimulus.setImage('materials/'+Trial['locB']+'.jpg')  
    baseline_ratingscale.reset()
    while baseline_ratingscale.noResponse:
        locB_stimulus.draw()
        baseline_ratingscale.draw()
        myWin.flip()
    print baseline_ratingscale.getRating(), baseline_ratingscale.getRT()
    Trial["resp"]=baseline_ratingscale.getRating()
    Trial["rt"]=baseline_ratingscale.getRT()
    myWin.flip()
    core.wait(1)

For now, the program can work just can’t show the value been chosen.
The code has been written under PsychoPy version 1.85.6, operation system win7.
And I know it says while singleClick = True, showValue will be ignored. I just wanna try and it didn’t work.

Can anyone please help?
Thanks a lot in advance!

Hi @Jin, yes this is possible. You can call one of the rating scale methods called _getMarkerFromPos and pass it the X position of the mouse from mouse.getPos. You can assign the returned value to a text component so that it can appear on screen.

Please see the attached example from a Builder experiment ratingXPos.psyexp (7.8 KB)

I’d say this is handled better in the new Slider though (a new alternative to Rating).

http://www.psychopy.org/api/visual/slider.html#psychopy.visual.Slider

Slider allows you to check the current value of the slider by querying its markerPos and this is set continuously as the participant drags the marker. This is only set as a “rating” when they release the mouse button. Does that make sense.

I had included a Builder demo called newRatings to show this. I’ve just discovered that fails in 3.0.0b3 but in versions before (and after) that it will be fine.

Hi Jon,

Thanks for your reply, I tried it, code as follow,

def phase_1_trial(Trial):
    baseline_ratingscale = visual.Slider(myWin, ticks=(-100,100),labels= (u'-100=Extremely Dislike', u'+100=Extremely Like'),pos = (0.0,-0.6), size=0.6,
        style='rating', granularity=0,textSize=1.0, readOnly=False, color='LightGray',font='Helvetica Bold',depth=0,
        name = None, autoDraw=False,autoLog = True)
    locB_stimulus.setImage('materials/'+Trial['locB']+'.jpg')  
    baseline_ratingscale.reset()
    while baseline_ratingscale.noResponse:
        locB_stimulus.draw()
        baseline_ratingscale.draw()
        myWin.flip()
    print baseline_ratingscale.getRating(), baseline_ratingscale.getRT()
    Trial["resp"]=baseline_ratingscale.getRating()
    Trial["rt"]=baseline_ratingscale.getRT()
    myWin.flip()
    core.wait(1)
    exp.addData('part_num',part_num)
    exp.addData('trial_num',Trial['trial'])
    if Trial['locA'] == ' ':
        exp.addData('locA','n/a')
    if Trial['locA'] != ' ':
        exp.addData('locA',Trial['locA'])
    if Trial['locB'] == ' ':
        exp.addData('locB','n/a')
    if Trial['locB'] != ' ':
        exp.addData('locB',Trial['locB'])
    if Trial['locC'] == ' ':
        exp.addData('locC','n/a')
    if Trial['locC'] != ' ':
        exp.addData('locC',Trial['locC'])
    exp.addData('flag',Trial['flag'])
    exp.addData('resp',Trial['resp'])
    exp.addData('rt',Trial['rt'])
    exp.nextEntry()
    return Trial

But I got an error.

AttributeError: 'module' object has no attribute 'Slider'

Do I need to update the psychopy software or do anything else in order to use visual.Slider?

Thanks a lot for your help!

Hi,

I tried to run the example you sent me, I think I understand what you mean, but I can’t successfully run it, I got an error, which I don’t know whether it is caused by different version of psychopy, it says,

############## Running: C:\Users\c1728176\Downloads\ratingXPos.py ##############
  File "C:\Users\c1728176\Downloads\ratingXPos.py", line 122
    x = rating._getMarkerFromPos(mouse.getPos()[0])+1
    ^
IndentationError: expected an indented block

Do you know what caused it?

Thanks a lot for your help!

Hi @Jin, the indentation error occurs when the code is not indented properly. - see here for documentation on how Python programs are structured through indentation.

If you want to follow Jon’s newer version of Slider you should use the new PsychoPy 3.