Howdy, Stranger!

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

Supported by

letters generation task

Hello,

As part of my thesis, I program a sequence learning task on OpenSesame.

Sequences consist of letters F, G, H, I presented either in sequential order or randomly. To answer the participants must press the keys of the keyboard E, R, Y, U.

To determine if there is indeed a learning, I ask them to carry out after this task a task of generation of letters. from a letter displayed in the center of the screen I ask the participants to recall the following 3 letters. From the sequence following the serial order presented in the previous task. I used the inline_script item. I managed to display the letter serving as a clue on the sketchpad and then transfer it to my canvas.

The difficulty I currently have is that I would like the letters to display when I press E, R, Y or U because at the moment I can only display the letters when I press the keys keyboard F, G, H, I. I thought maybe use: my_keyboard = Keyboard(keylist=['', ''], timeout=keypress) but I have a doubt.

Anyone have an idea?

Comments

  • Hi @lorinap ,

    It's not entirely clear to me what you want to do exactly, and it what sense it currently doesn't work as you'd like it to. However, when it comes to specifying the allowed responses, you can do this by:

    • entering the key names separated by semicolons in the Allowed responses field of a keyboard_response item as shown here; or
    • passing a list of key names to a Keyboard object in a Python inline_script as shown here.

    Hope this helps!

    — Sebastiaan

  • Hi sebastiaan,

    Thank you for your message.

    I'm sorry if my explanation was not very clear.

    My experience is divided into two different tasks. In the first task the participants have to categorize the letters F, G, H, I with the keyboard keys E, R, Y, U. The stimuli are presented in a certain order. In the second task, participants must recall these letters in this specific order. To help them, a single letter serving as a clue is displayed on the screen. Participants must then complete. Using the inline_script item, I managed to get the answers to display on the screen. However, to display the stimuli you have to press the F, G, H keys. However, in order not to disturb the participants, I would like to keep the same correspondence between the letters and the keys of the keyboard as the first task.

    I had tried using the keyboard_keylist function but failed. I will try your idea.

    Thank you for your advice !

    lorinap

  • edited June 2022

    Here is my programming regarding responses. By using conditional statements, I wanted to allow participants to delete their errors. I wanted for the last line to add keyboard_list but I have already defined my_keyboard.

    my_keyboard = keyboard(self.experiment)
    resp = "" # Here we store the response
    while True:
      # Get a keyboard response
      key, time = my_keyboard.get_key()
      # keyboard.to_chr() converts the keycode to a description,
      # like 'space' or 'return'. If return is pressed the loop
      # should be exited.
      if my_keyboard.to_chr(key) == "return":
          break
      # Handle backspace by removing the last character
      if my_keyboard.to_chr(key) == "backspace":
         resp = resp[:-1]
      else:
         # The built-in chr() converts the keycode to a character,
         # like ' ' and '/'.
         resp += my_keyboard.to_chr(key)
    
  • Hi Lorinap,

    I think this should do:

    kb = Keyboard()
    resp = "" # Here we store the response
    key_mapper = {'f':'e', 'g':'r', 'h':'y', 'i':'u'}
    while True:
        key, time = kb.get_key()
        if key == "return":
            break
        if key == "backspace":
            resp = resp[:-1]
            print(resp)
        else:
            try:
                resp += key_mapper[key]
            except KeyError:
                print(f"{key} is not valid")
    var.resp = resp
    

    ps, I edited your post to properly format code to make it more readable

    Buy Me A Coffee

  • Hi eduard,

    Thank you for your message.

    I didn't know that with key_mapper you could map keys to stimuli. Thanks for showing it to me. However I believe that the except KeyError part is incompatible with the display of my canvas. Here is my coding, I transfer my sketchpad on my canvas. OpenSesame gives me a problem with the first line of this coding.

    What do you think ?


    my_canvas.copy(self.experiment.items["my_sketchpad"].canvas)my_canvas.text(resp,x=0,y=0)

    my_canvas.show()

    # Save the response

    self.experiment.set("response", resp)

  • If you want me to help you, you at least have to tell me what the error is, and provide some more context. Like that I could only guess what is happening

    Buy Me A Coffee

  • I corrected the error. It was necessary to remove an indent at the level of the first line of the code that I have just sent to you. However when I type on the keys, the answers are not displayed following the hint on the screen.

  • edited June 2022

    I believe it's related to this line :

    except KeyError:

    print(f"{key} is not valid")

    OpenSesame considers e, r, y, u keys invalid

  • The KeyError is raised when the key is not present in the mapping. I thought you want paricipants to press f, g,h, or i which should then appear as e, r, y, and u. So I added each of these maps to the mapping. If you need anything else, like pressing e should present an e, you can add that map yourself, e.g.

    key_mapper = {'f':'e', 'g':'r', 'h':'y', 'i':'u', 'e':'e'}
    

    but as you see that would be an 1 to 1 map and therefore a bit pointless. Generally, though, design this map such that all key strokes that you want to appear on the screen are mapped the correct way.

    Does that make sense?

    Buy Me A Coffee

  • I understand what you mean. In my experience, the letters f, g, h, i are the stimuli while e, r, y, u are the response keys. According to your explanation, I fixed this problem by reversing what you showed me for key_mapper. However, participants must complete a series of letters from a letter (f, g, h or i) displayed on the screen. But the answers of the subjects are displayed briefly only when you press Enter to move on to the next trial, which is a problem.

  • I can't help you without seeing any code. I mean I could write you something that could work, but without knowing anything that would again only lack something else.

    Buy Me A Coffee

  • edited June 2022

    I'm sorry if I'm not very clear, I don't know the Python language very well yet. Here is the code with the changes.

    from openexp.canvas import canvas
    my_canvas = canvas(self.experiment)
    kb = Keyboard()
    resp = "" # Here we store the response
    key_mapper = {'e':'f', 'r':'g', 'y':'h', 'u':'i'}
    while True:
    key, time = kb.get_key()
    if key == "return":
    break
    if key == "backspace":
    resp = resp[:-1]
    print(resp)
    else:
    try:
    resp += key_mapper[key]
    except KeyError:
    print(f"{key} is not valid")
    var.resp = resp
    my_canvas.copy(self.experiment.items["my_sketchpad"].canvas)
    my_canvas.text(resp,x=0,y=0)
    my_canvas.show()
    # Save the response
    self.experiment.set("response", resp)
    


    Do you want me to send you my start code ?

  • Yes, unless you format your code properly (the way you see it in the editor), it is better to simply share your entire experiment.

    This now also presents the the typed letters onto the canvas of your sketchpad. Your problem was that you copied it on every loop iteration, therefore deleting all, previous changes.

    cv = Canvas()
    cv.copy(items['my_sketchpad'].canvas)
    resp = "" # Here we store the response
    cv['resp'] = Text(resp)
    kb = Keyboard()
    key_mapper = {'f':'e', 'g':'r', 'h':'y', 'i':'u'}
    while True:
        cv.show()
        key, time = kb.get_key()
        if key == "return":
            break
        if key == "backspace":
            resp = resp[:-1]
            print(resp)
        else:
            try:
                resp += key_mapper[key]
                cv['resp'].text = resp
            except KeyError:
                print(f"{key} is not valid")
    var.resp = resp
    


    Eduard

    Buy Me A Coffee

  • Thanks for your feedback. I tested the script it seems to work. The only problem, but I don't think it comes from the script, is that the first time you press a key, the answer is not displayed immediately on the screen, so you have to press it a second time.

  • Indeed, that is not related to the script I think. Perhaps it seems so because the sketchpad is presented first?

    Buy Me A Coffee

  • I agree, I've seen this problem before in a script from a colleague of mine. Even if we put it at the end, I think it's the sketchpad display that will have a time delay.

  • Hi @lorinap,

    Just picking up on that last bit of the thread, so I might be completely off the rails here but... you might want to check that your sketchpad has a duration of 0 ms. If you left it set on "keypress>", the task would require the participant to press a key to pass the sketchpad, and then again to register a response using the code above.

    Best,

    Fabrice.

    Buy Me A Coffee

  • Hi Fabrice,

    I just saw your message. Seeing the sketchpad display lag, last night I changed the sketchpad presentation duration to 0 and it worked.

    Thank you for your message.

    Best,

    lorinap

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