Programming with PsychoPy, Final assignment

It is time for the grande finale: the final assignment. We prepared for you a template with example functions, code snippets and useful comments. It contains the examples from this course and much more. You can use these functions from the template directly or you can copy them into your own experiment and change them. It often makes sense to change the name of the function if you change it's behaviour. Look in lesson 6 to see how to use the functions directly.

The experiment

As final assignment you will write an experiment.

We present a text which serves as prime. Then we show an action picture. The participant must indicate wether the prime matches the action or not. There are both plausible and implausible actions. Will there be a faster reaction for plausible actions? Will there be a faster reaction for matching primes?

You will need these files:

image.zip
all 24 action pictures
stimuli.csv
all 48 different conditions
my.py
a few useful functions, from lesson 6
template.py
a well structured dummy experiment
template_stimuli.csv
conditions for the dummy experiment

Trial specifications:

A single trial should consist of the following parts. Please do not start programming yet. Read till the end of the tutorial first

  1. Present fixation, Wait (1000 ms)
  2. Present prime for 800 ms ("to taste", "to smell", "to listen", "to look")
  3. Empty screen Wait (jitter 500 - 1500 ms),
  4. Present action picture for for a maximum of (2000 ms) waiting for response
  5. Give feedback on wether the response was "correct" or "incorrect" to the action picture stimulus and wait a bit.
  6. Give a feedback sound that is different for correct and incorrect responses.
  7. Show an empty screen for 700 ms

Final assignment

Let us now write an entire experiment from scratch. Feel free to do this any way that works for you. The experiment need not do exactly what is described here. Feel free to add additional fancy things or make it do things that you can use for your own work. Just make sure that at least all the elements described here are present

The way I am going to describe how to build this experiment is called bottom up. We are going to start from a minimum running experiment and add things from there. After each line in this instruction your experiment should be able to run. Use this. Test your experiment after each feature that you add. Finding a bug is easy if you added it two minutes ago, it is hard if you added it half an hour ago.

First look at the example in template.py and make it run. Do not use it as a starting point to wrote your own experiment. Just keep it as a reference on how to do things.

You need not follow the detailed steps below, but it may be handy.

  1. Copy the very simple hello world file from assignment 2. Run it.
  2. Change the stimulus to a fixation cross that stays on the screen for 1000 ms. Run it.
  3. Present the word "Hello" after the fixation cross. Make sure the stimulus is made in the preparation phase of the experiment. Check how long the fixation cross was actually on the screen. This is the time between the two calls to win.flip in your experiment. Make sure it is exactly 1000 ms.
  4. Present an empty screen after the word "Hello". Present it for a time between 500 and 1500 ms. Are the chances of all waiting times uniformly distributed? Can you make it a triangular distribution? A triangular distribution with 1100 ms as mode? (This is a pretty useless extra, don't waste to much time on it)
  5. Present an image from the image file after this. Again make sure the stimulus is made in the preparation phase of the experiment.
  6. Wait for 2000 ms for a 'y' or 'n' reaction while showing the image
  7. Show the text "thank you for responding" along with the image for a while.
  8. Show an empty screen for 700 ms
  9. Now we can show a single stimulus en get the response. Use the openDataFile function from my.py to make a data file. Use the csv writer to put the response in it. Make a header line before the start of the experiment. Make a data line after the respons is giving by the participant. What information do you want to store? What times?
  10. Use the getStimulusInputFile function from my.py or the csv reader to read the stimulus input file and put it in a list.
  11. Make loop around the trial sequence to show 48 different trials. Change to word "Hello" to the prime of the trial. Change the image to the image that goes with the trial.
  12. Adjust the "thank you for responding" text to show wether the response was correct or incorrect.
  13. Shuffle the trials. Look in the Python api documentation of the random module to see how.
  14. Add some kindness. Welcome the participant and say goodbye.
  15. Let the participant enter a participant number at the start. Store this in the data file.

You can add a lot more. Feel free to make the experiment more realistic. Feel free to add things that you would use yourself in an experiment. Feel free to go home if you have had enough Python. The following suggestions are just suggestions.

Add a pause option, a feedback sound. Prevent consecutive trials with the same image, the same prime. Add instructions. Psychopy has a nice way to let people enter the participant number. It is in the gui module. Did you use it?

This was the final assignment. I hope you liked this introduction to Python and found it useful.