Howdy, Stranger!

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

Supported by

[solved] Help getting started on an experiment.

edited April 2013 in OpenSesame

Hello all,

I hate doing this, because I know there's a good chance that these questions will have been answered piecemeal in the forums here, but I'm in a bit more of a hurry than I like to be thanks to some consistent difficulties with E-Prime (story of my life). I created the first block of a six-block study in E-Prime, and any attempt at replicating that block for the next five results in the program crashing. So I thought I might try OpenSesame again, as it's had some updates since the last time I tried. The problem is that I was intending to have this experiment listed on my University's signup page next week, so I'm somewhat rushed.

That said, the experiment itself is simple in design, but apparently a little more difficult to program. The basic layout is this: There are 6 blocks of trials. Each block consists of 6 trials, and each trial consists of the following sequence--

Study list of 8 images, presented one at a time, randomly

Brief Two-step arithmetic problem

Test array of 4 images, presented simultaneously, in random locations
----The test array may or may not contain one of the study list images

Confidence judgment on test array choice

Re-presentation of all four test items with a visual analog scale for participants to rate the likelihood each item was in the study list

I would like to be able to explicitly specify which items appear in each study list and test array, though I would like for their presentation orders to be random.

So it would randomly select a Block [1-6], then randomly select Trials [1-6] until it exhausted all six trials, then move on to another random block.

Unfortunately for me, I'm not very familiar with OpenSesame at all. I haven't even yet figured out how to get it to perform a single trial, let alone setting up the structure for all the randomizations. I think perhaps part of that problem is that I'm used to using E-Prime, and thus might be biased to trying to do things in that manner (I had little trouble building the structure there, but the constant crashing was frustrating beyond belief). If I've not been clear enough here, I'd be happy to try explaining this again. What I would really like is just a few pointers in the right direction, such as how to get OpenSesame to randomly draw images from specified lists of images, or how I might start building the randomization structure.

I'll keep digging around the website as well. Thanks in advance for any help. I would love it if I could get up and running with an experimental software other than E-Prime... if you can't tell, I'm at least a little bit disillusioned with it.

Edit: Apologies for the bad formatting, I'm not quite familiar with the best ways to structure posts on this forum.


  • edited 9:48PM


    I'm sorry to hear about your problems with E-Prime. However, I'm afraid that this post will not get you the answers that you need, because essentially you're asking someone to build the experiment for you. The 'few pointers' that you mention, are all addressed in the tutorial, so I would recommend walking through this first. Then, when you have constructed the experiment as far as possible, and run into specific issues, please post them, and you will receive extensive help. However, I'm afraid that right now I can do little more than refer you back to the tutorial to get a basic understanding of how OpenSesame works.


  • edited 9:48PM

    Thanks for the frankness. I suppose I didn't intend for someone to do it for me, but rather direct me to a portion of a tutorial that was most applicable to this. Perhaps I didn't have as much luck as I should have looking for information because I tried to find a specific spot in the tutorial rather than starting at the beginning. I'll try that approach instead, which will probably be more beneficial in the long run anyway. If it wasn't obvious, I was just frustrated and probably a little impatient yesterday.

  • edited 9:48PM

    I figured you were frustrated, and of course I can understand that (I don't wish E-Prime on anybody). Please don't hesitate to post further questions after you have done the tutorial. You will find the forum more welcoming than it might seem now!

  • edited 9:48PM

    I do have one quick question: Every now and then, text fields do not seem to accept keyboard input. For example, sometimes when I click on an object's name to rename it, it won't let me type anything. This can be circumvented by right clicking on the item in the overview area, so that's not too much a problem. However, I've also had it happen with the "Run if" box and the "background color/foreground color" boxes in the experiment overview. Is this a normal bug in the OS X version, and is there something I can do? Thus far, I've just been saving and restarting the program.

  • edited April 2013

    Okay, I've got a more specific question now. I've gotten to the point where I'm ready to build the test. I figured I would use a form, using image_button widgets for the four options. However, I'm not sure how I can get it to randomly place the four images into the widgets instead of always using the same ones.

    What I intended to do was to have four variables, test1-test4, and create different rows of combinations in each until all combinations of the four images were exhausted. Then I would have the program just select one of those possible "trials" per test, and use that for the rest of the test procedure. But it seems that if I create multiple rows in the variable fields, it wants the program to run all possible cycles, rather just select one of them. Is there a more elegant/appropriate way to accomplish this? This is how I did it in e-prime, for reference.

    Edit: Here is how I have it set up currently, although it has yet to let me accept changes. I think I may be missing some sort of "end line" symbol, but I used the examples at as a model.

    Edit2: It seems the error I keep getting is a bug in the OS X version. I just opened it up in a virtual machine with Windows 7, and it allowed me to save it. Moving forward again.

  • edited 9:48PM

    But it seems that if I create multiple rows in the variable fields, it wants the program to run all possible cycles, rather just select one of them.

    Do I understand correctly that you want to randomly select one row from a loop table? You can do this by setting repeat to a value smaller than 1. Say that you have 10 cycles, and set repeat to 0.1, then only 1 cycle (=row) will be executed. If the order is random, this will be a randomly selected row, otherwise it will be the first.

    Other than that, your approach sounds good. A slightly more flexible alternative (not necessarily better) is described here:

    Does this answer your question?

    Regarding the Mac OS issues. It's very well possible that these are specific bugs in the Mac OS packaging. I'll pass this on.


  • edited 9:48PM

    Hi cjp,

    Could you tell me which specific version of OpenSesame for OS X you are using (0.26 or 0.27.1 / 32-bit or 64-bit)


    Buy Me A Coffee

  • edited April 2013

    Sebastiann, thanks! That's what I needed to know for that. I kept trying to change the cycles field instead of repeat. I'll also check out the link to see which would be easier for me to replicate down the line for the other trials.

    Daniel, I just checked, and it's version 0.27.1. And for additional reference, I'm running OS X 10.8.3. When I copied text directly from the OS X version of OpenSesame to the Windows version (also 0.27.1), the issue cleared up.

    Edit: Upon checking Activity Monitor, looks like it's the 64-bit version.

  • edited April 2013

    Hmm. So I tried your second method because I believe it will save me a lot of time down the road, but I've hit another unusual snag. When I exit the script editor for the test form, it erases all the changes I made, even if I click "accept" or "accept and close". Here's a short youtube video demonstrating, and the script I'm trying to use beneath it (not sure if it works, since it won't let me keep it).

    from libopensesame import widgets
    from random import shuffle
    rows = [1,2]
    cols = [0,1]
    shuffle (cols)
    form = widgets.form(self.experiment, cols=[1,1], rows=[1,2,2,1])
    title = widgets.label(form, text='Which object did you see in the study list?')
    test1 = widgets.image_button(form, path=self.experiment.get_file('[test1].jpg'), var='response')
    test2 = widgets.image_button(form, path=self.experiment.get_file('[test2].jpg'), var='response')
    test3 = widgets.image_button(form, path=self.experiment.get_file('[test3].jpg'), var='response')
    test4 = widgets.image_button(form, path=self.experiment.get_file('[test4].jpg'), var='response')
    none = widgets.button(form, text='None of these', var='response')
    form.set_widget(title, (0,0), colspan=2)
    form.set_widget(test1, (cols[0],rows[1]))
    form.set_widget(test2, (cols[1],rows[1]))
    form.set_widget(test3, (cols[0],rows[2]))
    form.set_widget(test4, (cols[1],rows[2]))
    form.set_widget(button, (0,3))
  • edited 9:48PM


    Sebastiaan refered you to a post in which he and Jason used Python inline scripting instead of OpenSesame script to present the form widgets. If you try to paste Python code into the form_base script editor it's not recognised as 'correct' OpenSesame script and therefore not saved when you close the editor.

    If you want to use the 'second method', you should replace your form_base item by an inline_script item and paste the above Python code there. For an example, see:

    For more information on how to present form widgets via Python inline scripting, see:

    Best wishes,


    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 9:48PM

    Hah, what a simple mistake to make a big deal over. Thanks again.

    Is the way in which I called variables correct in this case? For example, [test1].jpg refers to a variable in the parent loop of this object, where [test1] is "apple1", and so it should fill that with "apple1.jpg". When I ran this as it was, after correcting a spacing error with the equal signs (doh!), it said it couldn't find the image [test1].jpg. Or is there something else required to get the python script to read the loop variables?

    I do apologize if this is all too basic stuff. I've definitely been trying to use the resources on the site as well as asking questions here.

  • edited April 2013


    To make in-the-GUI-defined variables available in an inline_script item, you use a different approach than the square-bracket method, namely the experiment function self.get().

    For example, if you want to use your in-the-loop-defined variable 'test1', in an inline_script item you retrieve its value like so:

    my_pict1 = self.get("test1")

    So, in your case, for example:

    my_pict1 = self.get("test1")
    my_pict2 = self.get("test2")
    widget_test1 = widgets.image_button(form, path=self.experiment.get_file(my_pict1), var='response')
    widget_test2 = widgets.image_button(form, path=self.experiment.get_file(my_pict2), var='response')

    Does that make sense?

    For more info, see:



    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 9:48PM

    That made perfect sense, thank you again. Everything seems to be working except one of my four images isn't displaying, which I think may be some error I haven't figured out with the form structure. The nice thing is, I think once I finish this, the only thing I'll have to do is duplicate it and change the variables.

  • edited April 2013

    I think I'm down to my final two questions, and I really appreciate all the help that got me here. If I can get these two things worked out, I'll be ready to start collecting data as soon as I have participants ready.

    Edit: I think I've figured out the logging issue. I was just labeling everything as "response", when I should have been defining specific variables for each response I wanted. So I think this section is okay, and I removed all the logger placement questions.

    Edit 2: I was half-correct. It seems to only be logging "yes" for any of the image_button widgets when clicked. I set what I thought to be recording values for the widgets, as seen in the code below. Is this not the correct way to define the value of an image_button? What I attempted to do was to have it record the value in the loop variable "test1" to the locations "test_response" when the button is clicked. I'm having the same issue with the standard button "none", which is the not present option in the test seen below.

    from libopensesame import widgets from random import shuffle test1img = self.get("test1") test2img = self.get("test2") test3img = self.get("test3") test4img = self.get("test4") rows = [1,2] cols = [1,2] shuffle(rows) shuffle(cols) form = widgets.form(self.experiment, cols=[1,1], rows=[1,2,2,1]) title = widgets.label(form, text='Which object did you see in the study list?') test1 = widgets.image_button(form, path=self.experiment.get_file(test1img), var='test_response') test2 = widgets.image_button(form, path=self.experiment.get_file(test2img), var='test_response') test3 = widgets.image_button(form, path=self.experiment.get_file(test3img), var='test_response') test4 = widgets.image_button(form, path=self.experiment.get_file(test4img), var='test_response') none = widgets.button(form, text='None of these', var='test_response') form.set_widget(title, (0,0), colspan=2) form.set_widget(test1, (cols[0],rows[0])) form.set_widget(test2, (cols[1],rows[0])) form.set_widget(test3, (cols[0],rows[1])) form.set_widget(test4, (cols[1],rows[1])) form.set_widget(none, (0,3), colspan=2) test1.set_var(self.get("test1"), 'test_response') test2.set_var(self.get("test2"), 'test_response') test3.set_var(self.get("test3"), 'test_response') test4.set_var(self.get("test4"), 'test_response') none.set_var("Not Here", 'test_response') form._exec()

    Second, I can't seem to get one image_button to appear in my test forms during the experiment. Here is the form's script (it should be similar to the script I posted earlier):

    And here is the result in the experiment Runtime:


    I'll keep plugging away at these issues in the meantime. I'm really looking forward to having this completed.

  • edited 9:48PM

    Update, in case someone comes across this on a google search and wants to set up something similar: The error regarding my missing item was because I had the list as "cols = [1,2]" in the pre-shuffle definition, when I only had two columns. When I changed that to "cols = [0,1]", the missing image_button reappeared.

    I've tried several things to fix my logging problem with the image_buttons, however, and have not reached a solution for that just yet.

  • edited April 2013


    Great to hear that you're almost there!

    I can't seem to get one image_button to appear in my test forms during the experiment

    I just noticed you already solved this one yourself. Just for your interest, herewith a bit of explanation:

    Your list of possible column positions was:

    cols = [1,2]

    Because in Python we start counting at 0, this list assumes that the form_base consists of at least 3 columns. However, your form_base contains only two columns:

    form = widgets.form(self.experiment, cols=[1,1], rows=[1,2,2,1])

    So, simply changing the 'cols' list into

    cols = [0,1]

    indeed makes sure that all four images will be presented, at the desired locations.

    I was just labeling everything as "response", when I should have been defining specific variables for each response I wanted.

    Yes, that's right. However, you changed all output variables into 'test_response' now, but then you still have the problem that the first four 'test_response' values are lost/overwritten, and the output file only contains the 'test_response' value of the last button (which is in your case the 'None of these' button). Right?

    So I think it's best if you save the values from the five different buttons with five different output variables, for example by calling those variables (i.e. column headers in your output file) 'test1_response', 'test2_response', etc. The variable 'test1_response' will have the value 'yes' if this button was clicked, and the value 'no' otherwise. Note that it's not necessary to use the set_var() function for this, you can just change the name of the variable like so:

    test1 = widgets.image_button(form, path=self.experiment.get_file(test1img), var='test1_response')
    test2 = widgets.image_button(form, path=self.experiment.get_file(test2img), var='test2_response')
    test3 = widgets.image_button(form, path=self.experiment.get_file(test3img), var='test3_response')
    test4 = widgets.image_button(form, path=self.experiment.get_file(test4img), var='test4_response')
    none = widgets.button(form, text='None of these', var='test_none_response')~~~

    If you would like to add a variable containing the name of the clicked image to your output file as well, you could do something like the following:

    # Create the dictionary:
    resp_dict = {}
    # Store responses (keys) with corresponding buttons (values):
    resp_dict[self.get("test1_response")] = test1img
    resp_dict[self.get("test2_response")] = test2img
    resp_dict[self.get("test3_response")] = test3img
    resp_dict[self.get("test4_response")] = test4img
    resp_dict[self.get("test_none_response")] = "None"
    # Determine which image got the 'yes' response:
    # Note that this works because a participant cannot
    # click multiple buttons. So the dictionary contains
    # only one 'yes'.
    clicked_img = resp_dict["yes"]
    # Finally, set the variable for future use in the GUI 
    # (e.g. the logger item):
    exp.set("clicked_img", clicked_img)

    Does this help? Don't hesitate to post again if something is unclear or if you have any more questions!



    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 9:48PM

    Ah, thanks, that works great. I was hung up on getting any of the buttons to fill the same variable, so much that I didn't even think of having a variable for each of them. And since the logger saves them right next to the image name (e.g. what's filling variable "test1"), the simple "yes" or "no" actually works quite well.

    I think with that, this is actually ready to get started. I really appreciate all the help here, and I'm definitely looking forward to showing our lab a fully-running experiment with something other than E-Prime. And, all things considered, learning OpenSesame and building to this point took me less time (5 days) than troubleshooting the E-prime program I knew how to use (9 days).

    So thanks again, all. Now to get this thing out to the subject pool.

  • edited 9:48PM

    Good to hear! :)

    And since the logger saves them right next to the image name (e.g. what's filling variable "test1"), the simple "yes" or "no" actually works quite well.

    Just as a final note: When using the above-suggested Python inline code, the variable 'clicked_img' contains the name of the clicked item.

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 9:48PM

    Yes, that works as well, : )

    I did have one unexpected question turn up regarding logging. I have it logging all the responses I would like, but reaction time is not logged on the test_slide in-line script, despite telling the logger to record "time_test_slide". All that shows up under "time_test_slide" is "NA". Is there an additional piece of script needed to record reaction times on in-line script items? Or do I need to set an explicit variable for time? This isn't vital, but it would be a nice piece of data to look at, given our hypotheses.

    Thanks again.

  • edited April 2013

    Edit: I'm making a habit of making posts about 5 minutes too soon. I solved the problem. I believe this can, yet again, and hopefully for good, be marked as Solved. : )

  • edited 9:48PM

    Marked as solved, then ;)

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games