6/13/2023 0 Comments Psychopy key getUsing event module for keyboard component.Ģ. However, by using the Keyboard class, I got the following warnings:ġ.4501 WARNING Import Error: No module named ‘psychtoolbox’. # Save the RT of the current trial in the variable RT # While the video is played, check if participant presses 'space' key and get the RT Kb.clock.reset() # when you want to start the timer from I used the new checking for key presses also, and here is the solution: from psychopy.hardware import keyboard The problem comes from the fact that my if condition was inside the trial loop instead of the drawing loop. There is a new way of checking for key presses, which has better timing (if timing is important for you):.You have a nested loop with in your trials loop and you’re only checking for space at the end of each trial. If you want to terminate the optic_flow_movie with a space press, then you’re checking for space at the wrong place in your script.Are you sure, you don’t want to check for “escape” key presses? There is no way to terminate your experiment in that loop.If my hunch is right keys might return ‘s’ instad of ‘space’ if the participant spressed space, because the first item in the list would be “space”, and the first item of this string would be “s”. I didn’t check and you could well be right, but the documentation of says nothing of nested lists. Why are you indexing the keys array in this way keys? continue would only be important if you have some lines at the end of your loop which you want to skip by “continuing” to the next iteration of your loop. Instead of if (keys = 'space') is True:īecause continue is redundant, if that is the last line in your loop. For running psychology and neuroscience experiments - psychopy/psychopy. You could use the line if 'space' in keys: Key Fixes: Online: Button Component is now fully working. Is your issue that you cannot terminate the loop by pressing space? RTs = # This converts from list of lists to a flat list RTs = for sublist in keys] # This stores only the timestamps # Take only the timestamps from the variable key and store it in the variable RTs I tried to implement the idea in my code with break and continue, but it doesn’t work: for i in range(nTrials): As feedback that confirms the key pressing, I’d like to move to the next trial (move to the next loop iteration) after the key was pressed. In my experiment, I have 10 trials, and at each trial, the participant has to press a key (“space”) asap after seeing a change of colour in the animation.
0 Comments
Leave a Reply. |