Chapter 13 Lab 5 exercises
The exercises below are not marked and you will not be required to submit them. However, they form the foundation of the skills necessary to complete the summative PsychoPy assignment. Therefore, we would highly recommend that you attempt to complete the exercises and let us know if you run into any problems.
- For each of the three exercises, please create a folder with the name of the exercise (e.g.,
psgy1001/lab5/psychopy/exercises/exercise1
). - If you get stuck, please have a look at Appendix H. If you’re still stuck after this, please ask for help on the PSGY1001 Moodle forum, at the help desk, or in one of the lab sessions, or watch the solution videos available below each exercise.
- When you run PsychoPy, a startup dialogue will come up, asking for a participant ID; you can simply leave this field empty, and click on OK.
I recorded the solutions available below with last year’s PsychoPy version. There are some layout changes when compared to the current version, but the relevant options should still be sufficiently similar for you to be able to replicate the solution (if you weren’t able to find the solution on your own in the first place).
13.1 Exercise 1
Start by creating a new experiment. To do so, click on the “Create a new experiment file” icon in the toolbar. This will open a new Builder window with an empty routine called trial
. After doing this, you should always save your experiment in your experiment folder. Otherwise, PsychoPy tends to have issues when you later tell it to read input files from your hard disk.
Make PsychoPy display the text “Hello world!” for 3 seconds. After this works, change the background colour of the screen to black.
How do I present “Hello world!”?
Use a Text component. See Section 12.1.
How do I make the trial stop after 3 s?
Pay attention to the “Stop” property of the Text component. See Section 12.1.
How do I change the background colour?
Check Experiment Settings → Screen. See Section 11.5.1.
You can watch a video of the solution here (to watch the video, make sure you are logged into Office 365):
13.2 Exercise 2
Please don’t forget to do this in a new folder. You can copy your experiment from Exercise 1 to this folder, and modify it.
Make PsychoPy display the text “Hello world!” 1 second after the start of the experiment. Present the text for an infinite amount of time. End the presentation only when the key “y” or the key “n” is pressed on the keyboard (but not another key).
The timing isn’t right
Pay attention to the “Start” and the “Stop” properties of the Text component. See Section 12.1.
The trial stops for other keys than “y” or “n”
Check “Allowed keys” in your Keyboard component. See Section 12.3.
The trial does not stop
The trial will only end if “Force end of routine” is ticked and a key that is an “Allowed key” is pressed. See Section 12.3.
You can watch a video of the solution here:
13.3 Exercise 3
Download the supporting material for this exercise. This is a zip file containing an image of a cat and a dog. Unzip the file and place the images in your exercise3
folder.
Present the cat in the left half of the screen for 5 seconds. Two seconds after the presentation of the cat started, present the dog for three seconds in the right half of the screen. Both animals should be on screen together for 3 seconds. Present the pictures using their original size.
Once this works, rotate the images so they are presented upside down.
PsychoPy does not run
Are you sure the images are in the same folder as your PsychoPy experiment? Are the file names in your image components identical to the file names in your folder (including capitalisation)?
How do I change the location of the pictures on the screen?
You will need to change the x variable of the Position property. If you use norm
units, a sensible setting for the cat would be [-0.5, 0]
. If you use pixel
units, appropriate settings depend on your screen resolution. A sensible setting for a full HD screen (i.e., 1920 x 1080 pixels) would be [-480, 0]
. In fact, this would be exactly the same location as [-0.5, 0]
in norm
units. Can you work out why? Have a look the PsychoPy documentation for units.
The pictures are squashed or stretched
Simply leave the Size
field of the Image component empty. See Section 12.2.
The rotation does not work
Note that the Orientation
field of an image component requires the number of degrees you would like to rotate the image by.
You can watch a video of the solution here: