Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Small changes to my experiment


I'm currently creating an experiment and although it is mostly finished, I need to add some small changes to make it work even better. However for each of these things I can either find not enough in the documentation or not much at all, so I was wondering if anyone else has come across these things before?

First I will explain my experiment in general to make it more clear. The participants will first see a screen that will introduce them to the experiment. After that they see a fixation dot which they have to press a key to continue on. Then they will see and hear a Dutch idiom (e.g. "Toen kwam hij uit de kast"). After this they can choose if they have heard this idiom before, yes or no, or they can click on the speaker icon to hear the idiom again. After they pressed either the green yes button or the red no button they will see the next screen in which they will have to select who they think could've said the idiom. The speaker icon can be clicked to hear the idiom again if they please and after that they can click one or more of the 4 different pictures on screen. This screen is completed when they press the "next" arrow in the top right corner.

Now as mentioned this mostly works the way I want it to but there are a few things that don't yet:

1) I cannot seem to get the speaker icon to play the current sound file again.
As an example in the prepare part of the "know_screen" I have a line of code which says: text="[Spreekwoord]" , this means that the text displayed takes the current idiom that I'm looping over in the examples loop. However when I try to do the same kind of thing for the sound file, so try using src = exp.pool['[Geluid].ogg'] it tells me that Geluid.ogg does not exist. How should I make it such that it takes the [Geluid].ogg file (so the current sound file of the idiom) in the python code?

2)Creating a frame around a selected picture
It would be nice if a participant knows if they selected a picture. I wanted to do this by adding a frame around the button as soon as the variable of the button is 'yes'. I do this by using the image_button.draw_frame(rect=None, style=u'normal') code that is suggested here: However when I try and run the code, it gives me an error message that image_button does not have a function called draw_frame. How can I draw a frame around the picture? Is there another function?

3)Is it possible to select and deselect a button?
If a person make a mistake in their choice of selected picture I think it would be nice if they could deselect the picture if they would want to do so. However I can't really seem to find any documentation if this is possible or not. Is there a way? And if yes, what would be the most efficient way of doing so? Setting the variables to different values?

I know this is a lot of questions and I understand if there may not be an answer to all of them, but it would really help me get on with my project if even just one of these issues was fixed!


  • Hi Sannee,

    i have not worked with sound yet.
    For your questions 2 and 3:
    This piece of code may help you further. Of course, you need to adopt it for your purpose. Especially the x and y positions.
    It is a questionnaire with 12 items on one page. You need to select on a scale from 1 to 5 on each scale (scale and item is in the main picture). What i basically did was putting rectangles around the answer scales. You may even change your decisions (all but the last selected item).

    clock.s leep(1000) #9000 #delete the space (the forum code does not accept it)
    VMIQ2_start.text('weiter mit Entertaste' , font_size=18, x=0, y= 300)
    key, time=enter.get_key()
    list_x = [-135,-5,120,240,360]
    list_y = [-173,-132,-90,-49,-7,35,76,118,159,201,243,284]
    for modal_i in range(3):
        lst = []
        list_xy = []
        if modal_i == 0:
        elif modal_i == 1:
        elif modal_i == 2:
        for j in range(12):
            for i in range(5):
                pres_image[str(j)+'_'+str(i)] = Rect(x=list_x[i], y=list_y[j], w=90, h=30, color='grey', penwidth=2)
            list_xy = []
        loopi = ['x'] * 12
        my_mouse = Mouse(visible=True)
        var.Stim=1 #just to set mouse position
        var.Resp=1 #just to set mouse position
        while 'x' in loopi:
            my_mouse.set_pos((x, y)) #keep it in the last mouse position
            button, (x, y), time = my_mouse.get_click()
            for j in range(12):
                for i in range(5):
                    if (x, y) in lst[j][i]:
                        for ii in range(5): #set all others white
                            lst[j][ii].penwidth = 1
                            lst[j][ii].color = 'white'  
                        #mark the selected one
                        lst[j][i].penwidth = 4
                        lst[j][i].color = 'black'
                        print var.Stim, var.Resp
Sign In or Register to comment.