Howdy, Stranger!

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

Supported by

Programming a multi-character (correct) response

Hi everyone,

I am programming my first OpenSesame experiment. The goal is a spelling bee task. My current trial sequence looks like this:

1) a word is presented through a sampler calling on a random word defined as [word] in the block loop

2) the answer_input_form is used to collect the participants answer

3) an inline script is written to compare the answer of the answer_input_form to the correct answer [word].

4) feedback is presented (correct/incorrect)


This set-up has some flaws: The answer_input_form cannot be timeout by the press of a butten (i.e. press enter when you have finished typing the word). Therefore, I have also tried this method: https://forum.cogsci.nl/discussion/31/solved-multi-character-keyboard-response-or-simultaneous-sketchpad-and-text-input but am unsure how to adapt the code to my situation.

Any help is appreciated, thanks in advance!

Comments

  • Hi @elisevt,

    Here's a hybrid solution using code inspired from that you found.

    It kind of works, with one limitation: it is not possible to enforce a strict timeout on the keyboard object using that method. This is because the keyboard call awaits a response before executring any other code, and so the timeout condition cannot be assessed until after a key has been pressed. This means that if you wanted to enforce a time limit of, say, 5000 ms, the response taking would not be interrupted until the first key being pressed after that 5000 ms interval. I searched for a solution to this but I don't think one exists (through I'm no Python expert; perhaps @eduard knows of a way around it).

    Other than that, I attach a demo task that does most of what you require: presents words in random order, takes multiple key presses (handles back spaces, special characters), kind of limits the response time window, and scores the response and provides feedback. Hopefully you can modify it and adapt it to your needs.

    I included notes throughout the code inside the task so that you can see what each bit does.

    The general logic is to encapsulate the registration of multiple key presses with it s own loop, nested within the loop controlling the trial. That way, we can interrupt the registration of responses when the subject presses "ENTER" or when the last response registered comes later than the maximim allowed time (not that I coded this as the "time_limit" variable inside the "words_list" loop, so that it could be set differently for different trial if you wanted to).

    Please also note the use of the break it function in the loop tasked with registering key presses:

    Here's my version of the task:

    Hope this helps,

    Fabrice.

    Buy Me A Coffee

  • Hi Fabrice,

    Thanks so much, the experiment is running now!


    Elise

  • Hi @elisevt,

    Glad I could help! Good luck with your experiment!

    Cheers,

    Fabrice.

    Buy Me A Coffee

  • edited May 2024

    Hi @Fab,

    I've slowly but surely been building my experiment, with your help! The trial set-up still looks similar to your screenshot. The only problem left to solve that the randomization in OS is random with replacement. However, I would like to have randomization without replacement so no word is presented twice during the experiment. My wordpool is large enough to allow this.

    Thanks in advance for your help!


    Cheers,

    Elise

  • Hi @elisevt,

    I'm not sure I understand what you mean. The random order setting of the loop does not allow the repetition of a trial within a cycle.

    If you set the number of cycle to a value greater than 1, then the trials will each be presented several times (the number of cycles you specified).

    If you're using this method and some words are repeated, then it must be that you have the same word featured on multiple rows in your loop.

    Hope this helps,

    Fabrice.

    Buy Me A Coffee

  • Hi @Fab,

    This is part of the experiment overview:

    The idea is that for each round (1 round = 3 trials) in the experiment, participants pick a difficulty level for words to spell (Keuzescherm - Keuzekey - Keuze). The screenshot shows level 1 and part of 2. Each level has its own library defined under LX_trial_loop, where X = chosen difficulty.

    Let's say difficulty 1 is chosen two rounds in a row, the experiment reloops through the L1_loop two times. I guess my question is: is there a way to write out words during the first L1_loop (let's call the variable already_presented) and removing these words from the possible rows during the second L1_loop.

    Hope this makes more sense.

    Elise

  • Hi Elise,

    You can define a list to which you add all words that were presented, essentially maintaining an "already_presented" list. Then you can use this list to check whether the selected word was already presented and if so, resample from the words list.

    There are different ways to approach that list. It is important where you initialize/reset it: (1) Once in the beginning of the experiment will keep all used_words throughout the entire experiment. (2) In every block will clear the list in every block, so that the same word can re-appear, but only in separate blocks. (3) In such a way that every run is replacing the previous one, such that you would end up with a "recent-words-list" of sorts. You could also use a dictionary instead of a list and keep track of the recent words per difficulty level simultaneously.

    Does this make sense?

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.