Build the "image-button" in scale function like SAM(Self Assessment Manikin)?

368 views
Skip to first unread message

june...@empathy-research.org

unread,
Mar 9, 2015, 10:34:58 PM3/9/15
to psychop...@googlegroups.com
Dear all!
Appreciate again for this amazing tool!
However, I'm thinking that there is any example for using image as the button of 'scale' function.
like self-assessment-manakin in below site.


Any option or code is available?

Thanks,
June

Jeremy Gray

unread,
Mar 10, 2015, 7:03:44 AM3/10/15
to psychop...@googlegroups.com
Hi June,

There is not an existing image option for SAM-like ratings. 

To do this, you would have to arrange for images to be displayed where you want them and use the current ratingscale code (easiest), or re-write the RatingScale code to use images instead (much more work).

--Jeremy


--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/b70c0453-e242-495c-9001-28646925bfe2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mario Reutter

unread,
Mar 10, 2015, 5:56:52 PM3/10/15
to psychop...@googlegroups.com
Hello,

I only work with coder but starting from this code might help you (see also attachments):
valencePic = "SAM valence.jpg" #or whatever the path and filename
arousalPic = "SAM arousal.jpg" #or whatever the path and filename
dimensions = ('valence', 'arousal')
displacement = 8

window = visual.Window(fullscr=True, color='black', allowGUI=False, monitor='Default', units='cm') #Creates the window object.  A monitor setup called "Default" with the physical dimensions of your monitor are needed in the monitor center (the icon with 2 monitors)
text = visual.TextStim(win=window, ori=0, name='Text', font='Arial', units=u'pix', pos=[0, 0], height=24, wrapWidth=None, color='white', colorSpace='rgb', opacity=1, depth=0.0)
ratingPic = visual.ImageStim(window, pos=[0,-displacement]) #suitable values for pos my vary according to screen size and resolution
ratingScale = visual.RatingScale(window, low=0, high=4, pos=[0, -displacement/8.0], stretch=2.5, showValue=False, scale="", labels=("", ""), acceptPreText='(choose)', acceptText='OK', mouseOnly=True) #suitable values for pos and stretch my vary according to screen size and resolution
image = visual.ImageStim(window, pos=[0,displacement]) #suitable values for pos my vary according to screen size and resolution
text = visual.TextStim(window, height=1.5, pos=[0,displacement])

def samRating(stimulus, dimension):
        event.Mouse(visible=True)
        ratingScale.reset()

        while ratingScale.noResponse:
            if event.getKeys(["escape"]): core.quit() #easy quitting while testing
           
            #set stimulus, i.e. pic or question
            if os.path.exists(stimulus) and not os.path.isdir(stimulus): image.setImage(stimulus); image.draw(window)
            else: text.setText(stimulus); text.draw(window)
           
            #set sam pic (valence or arousal)
            if dimension == dimensions[0]:
                samPic.setImage(valencePic)
            else:
                samPic.setImage(arousalPic)
           
            ratingPic.draw()
            ratingScale.draw()
            window.flip()
       
        return ratingScale.getRating())

Whenever you call the samRating function, you have to pass it a stimulus, i.e. either a valid pathname of a picture to be rated or a question (e.g. "How would you describe your current mood?") and which dimension you want to rate (i.e. 'valence' or 'arousal' or you can alternatively insert dimensions[0] or dimension[1] resp.). It then should operate as you need.
Note, however, that participants have to click on the scale below the SAM-picture and should be instructed to do so.

I also attached a picture (different background color).

Best wishes
Mario
example code.txt
example screen.jpg
Reply all
Reply to author
Forward
0 new messages