![]() The "yes" string will only be printed once because hello() is only called once.ĪllKeys = event. If test is 2 (a key was pressed), running will be set to 2 and the loop will exit. To get the effect you want, you need something like this: def hello():Īt the bottom of the while loop, if test has not changed (i.e., a key was not pressed), running will be set to 1 and the loop will continue. It's going to print the output once for every time it's called. Are there any specific workarounds that might enable. Specifically, the scripts crash when attempting to load psychopy.visual. use a for loop to go through the potential measurement points and an if statement to screen them make the measurements write the results to a text file. Can someone tell me why it seems to be storing print statements, despite that I would expect the print statement never to be reached until I pressed a key? def hello():įor frame in range(short_frames): # 2 secondsĪllKeys = event.getKeys(keyList = ('g','h')) I have several scripts that have been programmed in PsychoPy 1.8 and 1.9, and so far have found the forward compatibility to work fine when I upgrade the software, but each of the scripts crashes when running it in 1.73. ![]() ![]() For some reason, if I let the function loop over, for example, 4 times before i press a key, I then get 5 print staments out at the same time, whereas I would only expect one. Treat this as fun problem solving Using Python as a general programming language is a great way for you to get comfortable with syntax, so use it widely for any batch task you can think of. addData(name, value) Add the data with a given name to the current experiment. This is the method that allows you to do that. So if you quit your script early you may want to tell the Handler not to save out the data files for this run. That API assumes you only ever want to use a single parallel port at once. There is also a legacy API which consists of the routines which are directly in this module. Now that we have the text on a hidden screen, we need to flip the screen to reveal the text stimulus. When a key is pressed it exits the while loop and prints yes. Experiment handler will attempt automatically to save data (even in the event of a crash if possible). Either way, each instance of the class can provide access to a different parallel port. If a key isn't pressed, it waits 1 second and then runs the function again, over and over if no keys are pressed. When you ran the experiment after adding the call to the wait function, you may have noticed that the window was active for more than 2 seconds. My function 'hello()' simply displays a stimulus on screen for 2 seconds, during which time a key can be pressed. Import the wait function from the re module and, after initializing the window, use it to make PsychoPy wait 2 seconds.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |