Recording multiple responses in a dual-task design
I am currently setting up an experiment in which multiple responses need to be recorded during each trial. For brevity I will only describe the relevant sequence of the experiment. I want to present a first stimulus (image on sketchpad) for 2000 ms, followed by a 500 ms delay (also image on sketchpad), and a second stimulus (a third image on sketchpad) for 1500 ms. Throughout the full 4000 ms timeframe a response to the first stimulus can be given and should be recorded. There are two designated keys for this response [e.g., o and p]. In the last 1500 ms of the trial a response to the second stimulus should be recorded. Two different keys [e.g., q and w] are designated for this response. I have tried using the coroutines plugin to achieve this setup, but if the response for Stimulus 1 is given while stimulus 2 is already displayed and accordingly the keyboard_response item for this stimulus is active (i.e., response to stimulus 1 is given after 2500+ ms) it seems to be unpredictable whether any of the two responses, both responses or just one response is logged. I have since tried to use inlinescript to overcome this issue but that has not worked out.
Ideally, within the coroutine the program would constantly check whether one of the response keys designated to stimulus 1 is pressed. If that happens, it would log the response and the response time. Starting with the onset of the second stimulus, the program should additionally check whether one of the designated keys for stimulus 2 is pressed and if that happens log the response and response time.
Thank you in Advance,
Based on your description, I think you can achieve this using a co-routine like this.
You'd need to use the response_time and response variables for the individual keyboard events to retrieve the data (the generic response_time and response variables will only contain data from the last respnse recorded).
Also, it looks as if you need to disable the "Flush pending key events" for both keyboard events. This means you may record anticiptions (subject pressing q or w before the second stimulus is shown, but these are easily detectable in your data since the RT would be 0). The keys flushin of the co-routine is enabled, so that no response prior to the trial is registered in the current trial.
It's important to define the allowed responses for your keyboard events. If you don't, the program will take the first response as the response to the first stimulus nd the second response as the response to the second. If you specific the allowed keys, the task can seperate the two events and responses are recorded correctly even if subjects respond to the second stimulus before they respond to the first.
I had a go at simulating the task you described and it seems to work, though I'm not sure how reliable it would be if the two responses are very close in time). Have a look at my implementation and try it ou to see if it does what you need.
Thank you very much for your response! This resembles the approach I had first implemented very closely, although I did not disable the "Flush pending key events". However, upon trying out the experiment you attached, I still encounter the problem that if a response to stim1 is given late (i.e., after 2500ms+) it is not recorded. In the meantime I seem to have solved the issue using inline script. I think my solution is not the most elegant and some of the variables I create may even be redundant, but everythings is recorded. I have adjusted your exemplary experiment by inserting the inline scripts and removing the coroutine, feel free to have a look.
Not sure why my task didn't run properly when you tested. I did test it and, did it again just now and it does register the first response even if produced during the interval or the presentation of the second stimulus. Here's an example as displayed on he feedback object (you can see that the first response's RT is well over the duration of the first stimulus and the interval):