Howdy, Stranger!

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

Supported by

[solved] Go backwards / forwards within a sequence and record all of the keyboard response times

edited July 2012 in OpenSesame

Hi, Sebastiaan,

Just similar with David’s question in http://forum.cogsci.nl/index.php?p=/discussion/119/open-backwards-within-a-sequence. In my experiment, I want to present 50 pictures in a sequential order. The participants can go backwards / forwards within the sequence by pressing a specific key. Besides, I also want to know all of the response times, so I need to see all records in the logger.

Although l had studied the example that you made in http://forum.cogsci.nl/index.php?p=/discussion/comment/215, but I still have no idea how to use it. Could you teach me how to do this with inline code, please? Thank you so much.

Best regards,

Peter

Comments

  • edited 12:20AM

    Hi Peter,

    This is not trivial, as you have experienced, but I thought of a better and simpler way to do it.

    First, don't put trial_sequence in a loop, but at the start of the experiment with 'run_if = never' or in the 'unused items' bin (or anywhere, as long as it's not automatically called). Then insert the script below instead of a block loop. This will call the trial_sequence and advance or go back based on the response of the user. You will also manually have to set the variables, because there's no loop table to help you. For more info, see the comments in the script.

    # Uncomment for 0.25 and before
    # exp = self.experiment
    
    # Create a list of conditions, such as picture names. Change
    # based on your experiment.
    condList = ['pic1', 'pic2', 'pic3', 'pic4', 'pic5'] 
    
    # Loop until the last trial has been done
    trialId = 0
    while trialId < len(condList):
    
        # Explicitly set the appropriate condition based on the
        # condition list and the trial id. Change the variable
        # name from 'pic' based on your experiment.
        exp.set('pic', condList[trialId])
        
        # Prepare and run the trial_sequence. Change 'trial_sequence'
        # based on the name of the item that you want to run.
        exp.items['trial_sequence'].prepare()
        exp.items['trial_sequence'].run()
        
        # If 'response' was left, go back one trials, otherwise
        # advance one trial. Change this criterion based on your
        # experiment.
        if self.get('response') == 'left':
            trialId -= 1
        else:
            trialId += 1
            
        # Negative trial IDs are not valid
        if trialId < 0:
            trialId = 0

    Hope this gets you started!

    Cheers,
    Sebastiaan

    Buy Me A Coffee

  • edited 12:20AM

    Thank you Sebastiaan!

    You’re so nice and replied quickly. However, I tried many times, it still didn’t work. The debug window showed lots of errors:

    Error: Inline script error
    In: trial_sequence (run phase)
    File "libopensesame\inline_script.pyo", line 123, in run

    Python traceback:
    inline_error: Error: Inline script error
    In: trial_sequence (run phase)
    File "libopensesame\inline_script.pyo", line 123, in run

    I didn’t know What I have done wrong. Please help me. By the way I'm using OpenSesame 0.26.

    Thanks again.

    Best regards,

    Peter

  • edited 12:20AM

    I think something must have gone wrong with copy-pasting the code into OpenSesame's inline_script editor. Please make sure that all the indentation etc. is correct. If it doesn't work you can just copy the relevant bits by hand. The script itself should be fine.

    Cheers!

    Buy Me A Coffee

  • edited 12:20AM

    [ITA] Someone expressed an intent to answer your post. This means that person intents to answer your question (very) soon, but doesn't have the time right now.

  • edited 12:20AM

    Hi Sebastiaan,

    Thank you so much. When I copied the relevant bits by hand, it seemed to work. However, there is another problem with variable. I don’t know how to set it without loop table. Could you please take a look at the simple example below? Tell me what I have done wrong. Thank you.

    Direct link (save as .opensesame file) :
    https://docs.google.com/open?id=0B30WJRj7lOisTHRFdk04blQwODA

    Best regards,

    Peter

  • edited 12:20AM

    Hi Peter,

    Right, I can see why this would confuse you (it confused me too for a bit). The thing is that OpenSesame tries to prepare the trial_sequence, even though it will not be executed ('run if = never'). Because the preparation occurs before the inline_script is executed (which has only code for the 'run' phase, which comes after the 'prepare' phase) the variable 'pic' has not yet been set when OpenSesame tries to prepare the sketchpad. Hence you get an error. Does this make sense?

    There are (at least) two ways to solve this:

    • Give 'pic' a default value at the start of the experiment, for example by opening the general script (general tab → show script editor) and adding something like this to the top of the script (and press apply):
    set pic 1
    • Delete 'trial_sequence' so that it's in the Unused items bin. Unused items are never prepared. But don't empty the Unused items!

    Good luck.

    Cheers,
    Sebastiaan

    Buy Me A Coffee

  • edited 12:20AM

    Hi Sebastiaan,

    It works! It works! I really appreciate your help! The first way is great to my experiment. Thank you!

    Best regards,

    Peter

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