Howdy, Stranger!

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

Supported by

Serial reaction time task (SRT)

I am planning to programme an SRT task.
Is there anyone who programmed a serial reaction time task in open sesame already?
I would be grateful for scripts or any helpful comments.

The tricky thing is:
I have a series of 10 consecutive stimuli / "trials" (fixed sequence) which repeats 10 times (100 stimuli in total).
However, the series is starting at any point of the 10 stimuli.

Comments

  • I actually want to log every sinlge keypress. That's why i inserted a logger item after each stimulus.
    No the next question: Is it possible to insert a variable in the logfile that contains the name of the previous stimulus/picture? Just for an easy match of response times and stimulus.

  • Hi Dahm,

    I have to admit I don't really understand your design. Could you maybe explain again with a little more detail?

    Thanks,

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    here the main design of the SRT task.
    Participants are instructed to press one special key on each stimulus. We have four different stimuli (resulting in four different responses). What participants do not know is that the stimuli appear in a fixed sequence (10 trials), which repeats (10 times). So they perform 100 presses in a row and learn the sequence implicitly (motor learning). The sequence shall start at a random point.

    My idea was something like this:
    I have build the sequence with the ten stimuli, ten responses, and ten loggers.
    Now i put this sequence in a loop, so that it repeats 11 times. I define a random number x from 1-10. Now from the first sequence x trials will be skipped. And from the last sequence 10-x trials will be skipped at the end.

    However, i have very little experience with programming in open sesame.

    Stephan

  • Another idea:
    I build ten sequences each starting at a different point of the sequence. Then i put them all in one loop and select randomly only one of them. But how do i put more than one sequence in a loop?

  • Hi Stephan,

    Not sure whether there is a solution that relies only on OpenSesame items and doesn't require some coding, but this idea was the first that came to my mind. So, I basically, you define all the sequences and important information in inline_scripts using python directly.

    This piece of code you execute once per subject, to define the random sequence. Therefore, it is best to put it once in the beginning of the experiment before you enter the loop, in which you present the sequence to the participants.

    import random
    
    # build the generic sequence
    default_seq = [ 1, 2, 3,4,5,6,7,8,9,10]
    
    # choose a random starting point in this default list
    starting_point = random.randint(0,9)
    # the sequence that you use per trial/subject?
    trial_seq = [default_seq[i%10] for i in range(starting_point,starting_point + 10)]
    

    In the loop itself you can add this code. It takes care of stimulus presentation, response collection, and evaluation whether response is correct or not. Note, you need to place a logger item in the loop after the inline_script


    # init a canvas and a keyboard object cv = canvas() kb = keyboard(allowed_responses = ['z','x','n','m']) # set the keys that you expect pp to press # choose current stimulus stim = trial_seq[0] # some arbitrary rules to define correct responses (Can also be done in the script above) if stim == 0: var.correct_resp = 'z' elif stim == 1: var.correct_resp = 'x' elif stim == 2: var.correct_resp = 'n' else: var.correct_resp = 'm' # draw the stimulus (depending on what your stimulus is, you have to adapt the code) cv.text(stim) # show the stimulus start_time = cv.show() key,time = kb.get_key(timeout = 3000) # wait for a key press if key != None: var.correct = key == var.correct_resp # pressed key equals correct_key? var.resp_time = time-start_time else: var.correct = None var.resp_time = None # if you wanna show feedback, it would come now

    Does this make sense?

    Eduard

    Buy Me A Coffee

  • edited September 2016

    Hey Eduard,
    i have now decided to use inline_scripts only. So your suggestions may help even more.
    I have replaced "cv.text(stim)" with "cv.image(stim)". But unfortunately this does not work out in my case.

    This is what i placed in the "prepare section"

        #Define the single stimuli and their corresponding responses
        A = canvas()
        A_path = pool ['0_A.tif']
        A.image(A_path)
    
        B = canvas()
        B_path = pool ['0_B.tif']
        B.image(B_path)
    
        C = canvas()
        C_path = pool ['0_C.tif']
        C.image(C_path)
    
        D = canvas()
        D_path = pool ['0_D.tif']
        D.image(D_path)
    
        empty = canvas()
        empty_path = pool ['empty.tif']
        empty.image(empty_path)
        #no response fixed timeout 195
    
        #Define the 10 starting points of sequence A
    
        seq_A = [D,B,C,A,B,D,C,B,A,C]
    
        # choose a random starting point in any list
        import random
        starting_point = random.randint(0,9) 
    
        # the sequence that you use per trial/subject?
        seq_A_Rstart = [seq_A[i%10] for i in range(starting_point,starting_point + 10)]
    
        stim = seq_A_Rstart[0]
    
        if stim == A:
            var.correct_resp = 'f'
        elif stim == B:
            var.correct_resp = 'g'
        elif stim == C:
            var.correct_resp = 'h'
        elif stim == D:   ### the smiley is beautiful, but of course it is not a smiley
            var.correct_resp = 'j'
    

    and this is what i placed in the start section

        cv = canvas()
        kb = keyboard(allowed_responses = ['f','g','h','j']
        cv.image(stim)
    
        empty.show()
        start_time = cv.show()
    
        key, time = kb.get_key #wait for key press
        var.resp_time = time-start_time
    
  • Hi,

    Three remarks:

    1) Watch out that you don't add unnecessary whitespaces.
    A_path = pool ['0_A.tif'] won't work due to the space between pool and [

    2) Watch out to include brackets when you call a function
    key, time = kb.get_key won't work because kb.get_key() is a function that is only doing what it is supposed to do, when brackets are attached to it.

    3) If you describe that something is not doing what it is supposed to do, provide the complete error message. This way, it will be a lot easier to track the issues down.

    Thanks,

    Eduard

    Buy Me A Coffee

  • Thanks for your remarks.
    1) Actually this works even with the space. Anyway i will try to avoid unnessary spaces ;)
    2) I am sorry for this. Unfortunately the error is above, so i did not even come to this point.
    3) cv.image(stim) makes the problem. you suggested cv.text(stim). As i use image items i thought i would be good to change it.

    Here is the complete error message:

          File "<string>", line 4
            cv.image(stim)
             ^
        SyntaxError: invalid syntax
    

    By the way. Does it help if i attach the file?

  • Hi,

    Ah, I missed another little error in your code: You forgot to class the brackets in this line:
    kb = keyboard(allowed_responses = ['f','g','h','j']. So, it should be kb = keyboard(allowed_responses = ['f','g','h','j'])

    Eduard

    Buy Me A Coffee

  • I am sorry for the bracket error.

    Unknown argument: allowed_responses :(

    so i tried "keylist" instead of "allowed_responses"
    "" does not exist :(

  • What is not working? kb = keyboard(keylist = ['f','g','h','j']) should be fine (sorry for the allowed_responses error)

    Buy Me A Coffee

  • edited September 2016

    Stopped:
    The experiment could not be terminated because of the following reasons:
    "" does not exist

    Thats the complete error message when i use keylist.
    INFO: i am using legacy back-end.

  • Can you copy the entire error message, please? I need more information, i.e. which line, etc... (Btw, I can't open your experiment due to this problem.

    Eduard

    Buy Me A Coffee

  • edited September 2016

    In order to solve the file format problem i used a file of a colleague and overwrote it.
    Now it should be possible to open the file.
    It runs now with xperiment back-end.

    And now i get a more sophisticated error message:

        ...  
        File "C:\Program Files (x86)\OpenSesame\lib\site-packages\expyriment\stimuli\_stimulus.py", line 52, in __init__
            log_txt = u"{0},{1}".format(log_txt, byte2unicode(log_comment))
          File "C:\Program Files (x86)\OpenSesame\lib\site-packages\expyriment\misc\_miscellaneous.py", line 85, in byte2unicode
            u = s.decode(LOCALE_ENC)
        AttributeError: 'xpyriment' object has no attribute 'decode'
    
  • Hi,

    I see now. What you had defined as stim was not the image, but already the canvas to which the image was drawn. so calling cv.image(stim) was trying to draw a canvas onto a canvas with the draw-image-function. So, instead of cv.image(stim), just show it stim.show(), and you should be good.

    kb = keyboard(keylist = ['f','g','h','j']) # Better move this line in the prepare phase
    start_time =stim.show()
    key, time = kb.get_key() #wait for key press
    var.resp_time = time-start_time
    print var.resp_time
    

    Eduard

    Buy Me A Coffee

  • Hey Eduard. Thank you very much. I reached a big step further.
    Unfortunately i am very new to python. I am even struggeling to make a simple loop :(
    But i noticed that we do not need stim, which shortens the text substantially. :)
    Could you help me with the loop, please?

        for i = 0 
        until i > 39
            start_time = seq_A_Rstart[i].show()
            key, time = kb.get_key() #wait for key press
            var.resp_time = time-start_time
            i = i + 1
    

    in the preparation i need to multiply the sequence
    is there a shortcut, instead of repeating the whole statement? something like this...

        seq_A_Rstart = [seq_A[i%10] for i in range(starting_point,starting_point + 10), rep=4] #repeat the sequence 4 times
    
  • A for-loop has the structure:

    for index in list:
        # do stuff
    
    # in your case:
    for i in range(40):
            start_time = seq_A_Rstart[i].show()
            key, time = kb.get_key() #wait for key press
            var.resp_time = time-start_time
            #log resp_time, otherwise it will just be overwritten in the following iteration
    

    If you a very new to python, then you should first invest some time and get familiar with it. It is easy to learn and you will benefit from it a lot (you wouldn't have to rely on others to make experiments).

    There are plenty of nice python tutorials online that will teach you enough to make an experiment like that.
    See here for example: http://osdoc.cogsci.nl/3.1/manual/python/about/

    Eduard

    Buy Me A Coffee

  • Thanks a lot.
    I already found a list of tutorials earlier this week on this page https://computingforpsychologists.wordpress.com/tag/python/

    My problem on these tutorials is that they want to teach me how to make calculations, data structuring etc. But that is not exactly what i am looking for. I can use "R" for these things. I want to use python only for programming experiments. Until now i have not found a tutorial on this...

  • You'll find a link to such a tutorial in the link I provided above. Or simple google for python basics tutorial.

    Buy Me A Coffee

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