Howdy, Stranger!

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

Supported by

[solved] Using a response form with the "question" being randomly generated image

edited January 2016 in OpenSesame

I'm doing a memory study with a rating task for the first sequence of stimuli. Basically I need the stimuli to appear randomly, with a rating option of 1, 2, and 3, with the selection of the number moving the participant on to the next stimuli. I'm brand new to Open Sesame, and so far I've figured out how to produce the random stimuli, and how to create a form, but separately. Is there a way to combine these two? There's no correct response, but I do need to record their answers. There will be no need for instructions or questions for each rating response, because the rules will apply to all stimuli and will be given at the beginning. A shove toward a tutorial would be much appreciated.

«1

Comments

  • edited 4:17PM

    Ah, I forgot to mention that this will be run on an Android tablet

  • edited 4:17PM

    Hello,

    When you say you want your stimuli to appear randomly, you mean you have a pool of stimuli and draw them in a random order, right? If this is the case, you can use the loop item and put some identifier (e.g. the name, some id, or whatever) of your stimuli into the loop table. By default OpenSesame runs the lines in a loop table in random order, so there you get your randomization. Subsequently, you just have to add your form to the loop, maybe embedded in a sequence and choose a generic stimulus name as item to be run. This stimulus name should be identical to the variable name that you specified in the loop table. If everything works out nicely, the current value of the stimulus identifier in the loop table will be updated on every iteration, passed to the form, and a unique stimulus will be drawn.

    Does this make sense to you?

    Eduard

    Buy Me A Coffee

  • edited 4:17PM

    Yes!! It's working :D Thank you. Also, is there any way to customize the color of the buttons? This is just aesthetics at this point.

    Oh, and do I need to define a response variable in the loop? Or does that just go automatically into the logger?

  • edited 4:17PM

    Hi,

    I don't think there is a way to customize the color of the buttons in the form items. Also, every button you create has an variable that you can create or change in the last statement of the widget:
    widget 0 0 1 1 button text='Click me!' center='yes' frame='yes' var='response'

    Make sure to change the variable for each unique button, otherwise you won't know which button has been pressed.

    Alternatively, since you work on a tablet, you could swith the form item for a sketchpad item followed by a touch response item with three columns. This allows you to draw your own 'buttons' in the color you want, one in each of the columns. And it only gives you only one variable (with the value of the column that has been touched) instead of three different variables.

    Laurent

  • edited 4:17PM

    That is definitely something I'm going to try, because the fewer the variables, the better.

    I'm trying to get it to run on my tablet now to test it. It automatically wants to find the file on an SD card, which I don't have. I've changed the file location several times and it's still not finding it. Any ideas?

  • edited 4:17PM

    If it asks for the sdcard it probably means that your tablet's default storage directory is called /sdcard. It took me some tries the first time too but i created a new folder in which i put all my experiment /sdcard/Experiments/ and set this as the folder to look for experiments.

    You could also use ES File Explorer as an alternative explorer to make sure your .osexp ended up in the right folder. Oh and SD Scanner might also come in handy to force Android to look for new and updated files, such as your experiment.

  • edited 4:17PM

    Turns out I had to be super specific, but I was able to find it. It's nearing completion! The last thing I'm worried about is having a series of math equations for participants to run through, but having it end after a set time instead of completion of the sequence. Haven't looked into it yet though, so maybe it's easy. Onward!

  • edited 4:17PM

    Hi,

    What you want, is to present those equations in a while-loop (inline_script). The idea is that you can keep track of time, by creating a variable using the self.time() function, e.g.: start_time = self.time(). Every iteration through the while loop you can check time by means of current_time = self.time() - start_time. When current_time > time_limit, you break from the while loop.

    Cheers,

    Josh

  • edited 4:17PM

    I'm wondering if I can start this one up again. Josh, that info makes sense in theory to me, but I'm not sure how to implement it, where to put it in the inline script, etc. I'm just too new with this kind of coding. My experiment was just approved though, and I only have a limited time in this area for data collection, so I don't have time to figure it all out myself :( Is there a specific way to start a while loop? Or is it something you do within the run if function or?

    Separately, how necessary are reset feedbacks and how often do we need them? And also do I just need one logger for the whole experiment as long as I've defined all my variables properly?

    Thank you!

  • edited 4:17PM

    Just bumping this

  • edited December 2015

    Hi,

    You can place the while loop anywhere in the run phase of a inline_script, as long as you've defined all neccessary variables before it. Basically, your loop would look something like:

    # Create variable that checks if the loop should break
    break = False
    
    # Create a time stamp
    start_time = self.time()
    
    # Specify your time limit, 5 min in this example
    time_limit = 300000
    
    while break == False:
             # Check the current time
             current_time =self.time() - start_time
             # Compare current time to time limit
             if current_time >= time_limit:
                      break = True          
    

    Now you have a variable that you can use in the loop that presents the equations. Check the advanced options box and insert in the break if line: [break] = True

    As for the logging, you'll just need one logger for the whole experiment, just make sure you have a logger item in every sequence you use. The reset feedback items are usefull to prevent collecting unwanted reaction times during, for example, breaks or instructions that could distort your average data. So it's best to use them just in case.

    Good luck!

    Laurent

  • edited 4:17PM

    Is there a way I could upload my experiment on here to have someone give it a once over....I feel that the interface is completely functional, but I'm entirely unsure if I've created all the proper variables and if it will record them appropriately.

    The responses I need are:
    study responses (with the response being either 1,2,3, through a button press)
    distractor responses (typed # response)
    test responses (responses are new and old, through button response)
    demographic responses (combo of multiple choice and text input)

    Somehow I'm still completely useless at implementing the while loop :( I think I'm just too novice with inline script.
    I've tried creating a variable for "break", but it keeps automatically changing back to "never".

    Related to this: the text input form is set to return_accept: yes, which is all good and fine on the computer, but I'm going to be collecting data on an android...so how does that translate? Just with the enter button on the virtual keyboard?

    Not 100% necessary, but preferred, would be to have one form display next in a sequence only if the answer on the previous form was "yes". The question is "Do you have any experience with other languages" with multiple choice answer of "yes" or "no". The next question asks which languages and how much experience, as a text input form. Obviously, it would make the most sense if this was displayed only if participants responded with "yes" to the former question. I think I understand that I need to change the "run if" statement in the sequence window to something involving "response=yes", but I'm not sure exactly what wording to use or if there are prior steps needed (this kind of goes back with my not being sure about variables) . This is in the demographic sequence.

    Maybe some of this won't make sense until I have the file available. I'm working on that now!

  • edited 4:17PM

    Here's a link to my drive file. Maybe this will work?

    https://drive.google.com/file/d/0B6lb194HR2omVWEteHVxSDJUWkk/view?usp=sharing

  • edited December 2015

    Hi Aboa

    I went over your experiment a couple of times and what i've noticed is that your experiment doesn't actually store anything:

    What you should do to store all variables, and maybe i wasn't clear enough in my previous post, sorry for that, is insert one copy of the same logger item within a sequence. So for example in your first loop study_buffer_loop you'd want to insert a sequence that contains your form and a copy of your logger. You can do this for every loop you created that presents stimuli.

    Furthermore, the current response for the familiarity of the symbol is impossible to trace because the three options are all linked to the same variable (e.g. var=buffer1_response), therefore the answer will always be 'yes' but you can never retrace which of the buttons has been pressed. What you can do is replace them with unique variables (e.g. var=buffer_response_1). Alternatively, you can swap the form for a touch_response item that presents the symbols. Set the amount of columns to three and the item will store which column (or button) has been pressed, instead of checking three different variables.

    As for the while loop, you can swap the form that presents the equation with an inline_script that creates the form in the prepare phase and executes it in the run phase. Prior to the dist_test_loop there should be another inline_script with

    var.break_seq = 'no'
    total_time = 0
    

    And then an inline_script instead of the dist_test_form with in the prepare phase:

    # Import the widgets library
    from libopensesame import widgets
    
    # Create form, there are three rows now instead of two
    # When you use the keyboard for text input it overlaps with the input box
    form = widgets.form(self.experiment, cols=[1], rows=[2,2,2],
    margins=(50,50,50,50), spacing=10)
    # Here it should pull the correct image from the file pool
    image = widgets.image(form, path=pool["6.png"])
    text_input = widgets.text_input(form, var='equation_response',return_accepts=True)
    form.set_widget(image,(0,0))
    form.set_widget(text_input,(0,1))
    

    And in the run phase:

    # Create a time stamp
    start_time = self.time()
    
    # Specify your time limit, 5 min in this example
    time_limit = 300000
    
    while var.break_seq == 'no':
        form._exec()
        if var.equation_response != None:
            # Check the current time
            total_time =  total_time + self.time() + start_time
            # Compare current time to time limit
            if total_time >= time_limit:
                var.break_seq = 'yes'
                break
            elif total_time <= time_limit:
                break
    

    The loop is somewhat different than the original idea, and it needs some work as well to check if the timing is correct. Furthermore, i wasn't able to pull the correct .png file from the pool to present on the form. Now it is substituted with a static equation ('6.png') to test the form execution. Maybe @sebastiaan knows the correct syntax to retrieve the equation image variable?

    Interesting hypothesis btw! :)

  • edited 4:17PM

    Thank youuuuu!! I've fixed the loggers and the variables for the rating task. I'm working on the loop. I've added an inline script item and copied what you have into it, but am getting a lot of red. Is it because it's in the python format, and it's expecting the inline script format, do you think?

  • edited 4:17PM

    Actually I'm messing with it now, and that looks to be the case. Fingers crossed that this comes out ok in a few minutes! XD

  • edited 4:17PM

    lol nope. So I think I modified the prepare page to be ok, but I'm getting a lot of red dots and what not in the run page. The experiment also crashes at this point in a test run, yet cheerfully tells me that the experiment successfully finished lol

    http://img.cogsci.nl/?q=567b4d0cb39ed

    http://img.cogsci.nl/?q=567b4d4b8fb82

  • edited 4:17PM

    Sorry for the confusion, i forgot to paste a few lines in my previous comment. I've edited now with the correct content :)

    The while loop still needs work though, i just don't know the correct syntax. Maybe you can leave it unchanged (stick with the old forms and no timer) until someone knows the answer. Meanwhile, perhaps you can do a few test runs to see if all your variables are stored as they should?

    As for the form creation, an inline_script only accepts Python script while the original form was created in the OpenSesame script. The part that goes into the prepare phase is a form created in Python. Check this page for more info about the difference.

  • edited 4:17PM

    Should I post a new thread with just that question, so it gets more attention?

    Also, the timing system works, but goes super fast. I'm gonna mess with the numbers a bit, but it doesn't even reach a minute yet.

  • edited December 2015

    I believe i've got the timer and random stimulus presentation working now. Turned out i was overthinking it way too much. Here is the correct script:

    In the run phase of an inline_script before dist_test_loop

    var.break_seq = 0
    total_time = 0
    start_time = self.time()
    

    In the Break If line of dist_test_loop insert [break_seq] = 1

    In the prepare phase of an inline_script within dist_test_loop

    # Import the widgets library
    from libopensesame import widgets
    
    # Create form
    form = widgets.form(self.experiment, cols=[1], rows=[2,2,2],
    margins=(50,50,50,50), spacing=10)
    image = widgets.image(form, path=pool["%d.png" % var.equation])
    text_input = widgets.text_input(form, var='equation_response',return_accepts=True)
    form.set_widget(image,(0,0))
    form.set_widget(text_input,(0,1))
    

    And in the run phase of that inline_script

    # Specify your time limit, 30sec in this example
    time_limit = 30000
    
    while var.break_seq == 0:
        form._exec()
        if var.equation_response != None:
            # Check the current time in equation loop
            total_time =  self.time()  - start_time
            # Compare current time to time limit
            if total_time >= time_limit:
                # Set break if variable
                var.break_seq = 1
                break
            elif total_time <= time_limit:
                break
    

    Let me know if it works!

  • edited 4:17PM

    Ok, so the image display works! It's bringing up random equations, which is perfect. However, the timing mechanism isn't working properly. What I've found is that it will only run through all of the 'equation' images twice (so a total of 118 equations) within 5 minutes (so I was just hitting enter repeatedly) and stopped then instead of at the 5 minute mark. If I let it run for 5 minutes without entering anything, then entered one (at this point it should stop), it would run through 59 images (1 each of the equations). Does that make sense?

  • edited 4:17PM

    Hmm, that's weird. Could it be that you have the dist_test_loop set to repeat twice? Or perhaps it loops through the dist_loop twice?

  • edited 4:17PM

    My multiple choice forms also do not seem to be recording responses in the logger? So far the others seem ok

  • edited 4:17PM

    O I did have it set to twice. Odd. I'll run through some more tests now!

  • edited 4:17PM

    Ok, so the dist_loop was set to 2 cycles. I've changed it to 1, which makes the distractor task end after 59 equations, regardless of the time. The dist_test_loop has 59 cycles, because that's how many options there are in the variable. Both dist_loop and dist_test_loop are set for 1 "repeat each cycle 1 time". So it still isn't relying on the time for when to end.

  • edited 4:17PM

    And did you insert the break_seq variable into the Break If line under advanced options?

    As for the multiple choice forms, for some reason OpenSesame doesn't recognize them as standard forms (like your text input forms) and therefore doesn't automatically log the variables. If you manually add the custom variables in the logger item they should be logged correctly.

  • edited 4:17PM

    Yes, dist_test_loop says break if [break_seq]= 1

    That worked with the variables! Thanks!
    I feel so close to this being finished! :D

  • edited 4:17PM

    A friend of mine knows python, but not opensesame. He's wondering if the .exec function is taking too long? Idk lol

  • edited 4:17PM

    Does it matter that I have the inline script within a sequence in the dist_test_loop?

  • edited 4:17PM

    Hmm nope. Tried it without the sequence and it doesn't change.

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 http://45.77.173.118/ 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