End routine after number of keypresses psychopy builder
- #End routine after number of keypresses psychopy builder how to#
- #End routine after number of keypresses psychopy builder generator#
- #End routine after number of keypresses psychopy builder trial#
So what I need is a way to detect if two keys are pressed exactly at the same time or at a very close time. I precise that I tried it while removing the file writing process, so to lighten the instructions weight. It is not very probable (it seems that they need to be close by less than 10 ms) but it indeed happened during a pilot experiment. The problem I have is that when I receive a response really close to a trigger, then a trigger (or a response) can be missed. So i am trying to find a way to do that, but maybe there is another option I did not consider?
#End routine after number of keypresses psychopy builder trial#
Then my trial loop could read that cache progressively and perform the appropriate actions (end trial, store response). So I thought that a way to do that could be to have a loop running in the background, listening to keyboard inputs and storing them in a cache. For the first response I get, I need to set the response and response time and hide elements of the canvas.More precisely, each third trigger of a series ends the trial loop. I count them to know at which state of the trial I am.I would like to write them in a file for further data analysis (since this process must be quite heavy, I consider giving up on that if necessary).So the first issue I have is that a response and a trigger can occur at the "same" time, and so one of them can be missed.įinally, when I receive a trigger or a response, I need to react to them adequately and quickly: Their response on the response box is also received as a keyboard input: "b", "g" or "y". During the experiment, my participant is also able to respond when the canvas is presented.These triggers are received by the keyboard of the OpenSesame computer as a keyboard input "t" I have triggers that are sent by the MRI every 2 seconds.The problem I have to solve is the following: I assumed that using threads was what I needed but I couldn't manage to make it work. This aside, it's very probable that I am looking in the wrong direction. Therefore I assumed I had something to do in my Display_target_1 while loop. In particular, I tried to print "start" before the initialization yield, and "yield" after, and only "start" was printed. I assumed I had something to do in my Display_target_1 as well but I could not figure out what. I forgot I tried this with a yield in the while loop of the coroutine as well, but the result was the same.
#End routine after number of keypresses psychopy builder generator#
This generator is then called in a coroutines object in which I put the other script I want to run along with my coroutine. Key, end_time = phase_1_keyboard.get_key(timeout=None) I want to get keys in this function and set global variables accordingly. I have a function my_coroutine() that I define at the beginning of my experiment, in the prepare tab. While trying the experiment in real conditions, it happened that the participant responded close to a trigger, so some triggers were missed.įor these reasons, I really need to have a script running in the background, waiting for keys. While I wait for these triggers, my participant is able to answer using a response box. I am running my experiment in MRI, and I need to get the triggers sent by the MRI to write them in a file, and change what is shown to the participant accordingly.
#End routine after number of keypresses psychopy builder how to#
I read the documentation ( ) but I really don't get how to do it. I am trying to use coroutines with an inline script.