Multiple responses and tone during coroutine
Hi,
I have been trying to implement an experiment in which subjects can give two keyboard responses while they see a fixation cross, followed by some text and a tone that is played during the text display. Only if there is a "first" response, the experiment should check for a "second" response in the trial.
Sounds easy enough, but somehow I am not able to get it to work.
Since subjects should be able to respond during the whole trial (i.e., even during fixation and befor the tone has been played), I used the coroutine plugin with two "keyboard response" items. I also tried doing this with just one keyboard response item that is reset after a response, which I could not get to work; and also tried using just an in-line script with "while" loops but was not able to present anything while OpenSesame was waiting for responses. I also tried setting the "runif" or "starttime" properties of the second keyboard response only after the first response, which unfortunately did not work.
The problems with the coroutine solution are as follows:
- When I just set up the coroutine to end after the second response, the first response sometimes is not recognized, so I need three key presses to proceed.
- In other cases the trials advance immediately after the first response. In these instances, the first response is logged as "None"
I then added an in-line script with a generator function that should get the coroutine to start checking for a second response only after a first response is given.
- With this, the responses seem to be logged okay and trials only advance after two responses, but at some undefined point, python crashes. From then on, trials are of course displayed way too long and responses are not registered correctly or at all. I suspect this is due to my limited python knowledge, but as of now I could not isolate the issue.
I have attached an experiment with boiled down versions of the two variants that I tried out. 10 trials without a generator function for the coroutine and 10 trials with a generator function for the coroutine. I also attached a small logfile of a run in which I just alternated between pressing 1 and 2.
Any input would be greatly appreciated.
Best,
Marcus
Comments
Hi Marcus,
That's an interesting scenario. As I understand it, the main issue is to collect two key presses, and to abort the
coroutines
when this is done.Collecting two key presses is relatively easy: you can have two
keyboard_response
items (let's call them kb1 and kb2) running for the duration of thecoroutines
, and this will end up collecting two key presses, even though it's unpredictable which key is captured by which item (but that doesn't really matter either).Next, you can write a simple generator function that raises an
AbortCoroutines()
when both response variables have been given a value, i.e. when two keys have been pressed. And then you specify this generator function in thecoroutines
. Does that make sense? I attached a basic demo experiment below.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
thanks for your response. I used a generator function like the one you outlined, however, I did not know about the AbortCoroutines() function yet and but in "break" commands instead.
Collecting the two responses was easy indeed. The critical issue for me was that I needed to do stuff depending on the first response, that is, really do a sequential query of the response items. After a while I figured that the coroutine plugin is functioning the way it is supposed to but, as you said, "...it's unpredictable which key is captured by which item".
As a workaround I specified both conditions: either var.response_kb1 captures the first key press or var.response_kb2 captures the first keypress (see below).
Thanks again.
Best,
Marcus
Hello,
I am having a similar problem with a psychological refractory period study,
The experiemnt presents a green circle then a red circle. The time difference (SOA) between the onset of the green and red circle varies (SOA, 100ms, 200ms and 400ms). The idea is to respond to the green cricle then red circle as quicikly as possible. RT to the red circle is often longer than RT to the Green circle espceially with a shorter SOA (PRP effect)
Responses to both stimuli need to happen in parallel so I have used a coroutine. I extended the end time to 3000ms.
However, on some trials, the trial does not end with response 2 and on some trials, response 1 is not registered. Do coroutines not cope with mutliple response items?
I have tried adding the "check-response" inline script but that has not worked. I ran it in a window with the variable inspector open and it looks like there there is a delay between stimulus onset and the keyboard response being able to collect the response.
Best wishes and thanks for any help you might be able to offer.
Deiniol
Yay!!!!! I have fixed it. I hadn't specified the name of the keyboard response item properly in the check_response inline script. All good now.
Here is the experiemnt if anyone is interested in using it.