Give the component a sensible name, keep the letter height at the default (0.1), and leave the stop property empty. Importantly, you need to respond to the COLOR of the word and you need to ignore the actual word. As can been seen in the documentation, a Mouse object can be initialized with several optional arguments ( visible, newPos, and win) and contains various methods to query information about the mouse position ( getPos) and mouse clicks/presses ( getPressed).In this experiment, you will see words (either “green” or “red”) in different colors (also either “green” or “red”). Just like with keyboard responses, the psychopy package contains a class, Mouse (from psychopy.event), which implements interaction with the mouse. Whether you have participants respond with keyboard presses or with the mouse is of course up to you (and depends on your experiment)! For the sake of explaining how to implement interaction with mouse responses, let’s add another screen to our experiments with a big, red button, which the participant has to click (with the mouse) in order to start the experiment. Instead of interacting through the keyboard, you can interact with mouse responses of the participant. For example, suppose you want to check whether the particpant pressed the spacebar. Importantly, one common thing in working with keypresses is that you want to check whether a particular key was pressed. TDown: a float with the abolute time (in seconds unlikely you ever need this) ĭuration: a float with the time (in seconds) the key was pressed in (or None if still pressed in) Rt: a float with the time (in seconds) from start of the Keyboard clock (i.e., the clock attribute) Name: a string with the name of the pressed key (e.g., "a", "b", "return", "left", etc.) In fact, these KeyPress objects contain much more information that is contained in its attributes: Then, run the experiment and check the Experiment runner to see the printed output.Īs you can see, the getKeys method specifically returns a list of KeyPress objects! These objects are not just strings corresponding to the pressed keys (e.g., “a”, “b”, “return”, “left”, etc.), as you might expect. Check out PsychoPy’s reference manual for a complete overview of the package’s modules.Īs you will see, most of PsychoPy’s functionality (like the different components) is implemented in custom classes, so your experience with object-oriented programming as discussed in week 1 will be very useful!Īfter the initialization of the Keyboard object and the call to wait (from the previous ToDo), call the getKeys function and store the result in a variable (e.g., keys) and print this variable. For example, the visual module contains a class to specify and create a window and a large set of visual components (like text, image, and movie components) and the event module contains code to work with “events” such as mouse clicks/movement and keyboard presses. The psychopy package contains different modules for different features. However, as mentioned on the Getting started page, getting the psychopy package to work is not easy, which is why we recommend the “batteries included” standalone version of PsychoPy. If you plan on programming your PsychoPy experiment (so not use the Builder interface), you technically do not need the entire “standalone” PsychoPy package installing the psychopy Python package would suffice and you could just write your experiments in your favorite editor (like Visual Studio Code).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |