This page is very much a work in progress
PsychoPy has been designed to handle things like your screen calibrations for you. It is also designed to operate (if possible) in the final experimental units that you like to use, like degrees of visual angle.
In order to do this it needs to know a little about your monitor. There is a little application to help you with this called MonitorCenter. On win32 it has (by default) been installed as a shortcut in >Start>Programs>PsychoPy>MonitorCenter. On other machines you need to go and run python MonitorCenter.py from with the python's /site-packages/monitors directory.
In the MonitorCenter application you can create a new monitor name, insert values that describe your monitor and run calibrations like gamma corrections. For now you can just stick to the testMonitor but give it correct values for your screen size in number of pixels and width in cm.
Now, when you create a window on your monitor you can give it the name 'testMonitor' and stimuli will know how they should be scaled appropriately.
Building stimuli is extremely easy. All you need to do is create a Window, then some stimuli, then draw those stimuli, then update the window. PsychoPy has various other useful commands to help with timing too. Here's a full example:
from psychopy import visual, core #import some libraries from PsychoPy mywin = visual.Window([800,600],monitor="testMonitor", units="deg") #create a window #create some stimuli grating = visual.AlphaStim(win=mywin, mask="circle", size=3, pos=[-4,0], sf=3) fixation = visual.AlphaStim(win=mywin, size=0.5, pos=[0,0], sf=0, rgb=-1) #draw the stimuli and update the window grating.draw() fixation.draw() mywin.update() #pause, so you get a chance to see it! core.wait(5.0)
For those new to Python: Did you notice that the grating and the fixation stimuli call the same function (actually its a python class, but don't worry!) but had different arguments? One of the nice features about python is that you can give arguments with names and not use them all. AlphaStim has over 15 arguments that can be set, but the others just take on default values if they aren't needed.
That's a bit easy though. Let's make the stimulus move at least! To do that we need to create a loop where we change the phase (or orientation, or position...) of the stimulus and then redraw. Add this code in place of the drawing code above:
for frameN in range(200):
grating.setPhase(0.05, '+')#advance phase by 0.05 of a cycle
grating.draw()
fixation.draw()
mywin.update()
That ran for 200 frames (and then waited 5 seconds as well). Maybe it would be nicer to keep updating until the user hits a key instead. Thats easy to add too. In the first line add event to the list of modules you'll import. Then replace the line
for frameN in range(200)
with the line
while True: #this creates a never-ending loop
Then, within the loop (make sure it has the same indentation as the other lines) add the lines
if len(event.getKeys())>0: break
event.clearEvents()
The first line counts how many keys have been pressed since the last frame. If there were any then it issues a break command to get out of the loop. The second line clears the event buffer (otherwise it gets full of events that we don't care about like the mouse moving around etc...)