PsychoPy编程指导手册-英文
PsychoPy是一款完全开源的,基于Python语言的,专门为编制心理学实验程序而设计的一款免费软件,于2003年由英国诺丁汉大学Jonathan Peirce教授等人主持开发。CONTENTS1 About psychopy2 General issues3 nstallation4 Manual install5 Getting Started6 Builder7 Coder8 Running studies online939 Reference Manual (API)9510 Troubleshooting313II Recipes(“How-tos)31712 Frequently Asked Questions(FAQs32913 Resources(e. g. for teaching)33114 For Developers33515 PsychoPy Experiment file format(-psyexp)349Python Module Index353Index355CHAPTERONEABOUT PSYCHOPY1.1 Citing PsychoPyIf you use this software, please cite one of the papers that describe it1. Peirce, JW(2007)PsychoPy-Psychophysics software in Python. J Neurosci Methods, 162(1-2): 8-132. Peirce JW(2009) Generating stimuli for neuroscience using PsychoPy. Front. Neuroinform. 2: 10doi:10.3389/ neuro.ll.010.2008Citing these papers gives the reviewer/reader of your study information about how the system works, it also attributessome credit for its original creation, and it means provides a way to justify the continued development of the packagePsychoPy -Psychology software for Python, Release 3.0.0b8Chapter 1. About PsychoPyCHAPTERTWOGENERAL ISSUESThese are issues that users should be aware of, whether they are using Builder or Coder views.2.1 Monitor CentelPsychoPy provides a simple and intuitive way for you to calibrate your monitor and provide other information aboutit and then import that information into your experimentInformation is inserted in the Monitor Center (Tools menu), which allows you to store information about multiplemonitors and keep track of multiple calibrations for the same monitor.For experiments written in the Builder view, you can then import this information by simply specifying the name ofthe monitor that you wish to use in the Experiment settings dialog. For experiments created as scripts you can retrievethe information when creating the Window by simply naming the monitor that you created in Monitor Center. e. g:fr。 m psych。 py import visua1win- visual Window([1024,768], mon-'SonyG500'f course, the name of the monitor in the script needs to match perfectly the name given in the Monitor Center2. 1. 1 Real world unitsOne of the particular features of PsychoPy is that you can specify the size and location of stimuli in units that areindependent of your particular setup, such as degrees of visual angle(see Units for the window and stimuli. In ordefor this to be possible you need to inform PsychoPy of some characteristics of your monitor. Your choice of unitsdetermines the information you need to provideUnitsRequiresnorm'(normalised to width/height)I n/apix'(pixels)Screen width in pixelscm'(centimeters on the screen)Screen width in pixels and screen width in cmdeg'(degrees of visual angle)Screen width(pixels), screen width(cm) and distance(cm)2.1.2 Calibrating your monitorPsychoPy can also store and use information about the gamma correction required for your monitor. If you havea Spectrascan PR650(other devices will hopefully be added) you can perform an automated calibration in whichPsychoPy will measure the necessary gamma value to be applied to your monitor. Alternatively this can be added3PsychoPy -Psychology software for Python, Release 3.0.0b8manually into the grid to the right of the Monitor Center. To run a calibration, connect the Pr650 via the serial portand, immediately after turning it on press the Find Pr650 button in the Monitor CenterNote that, if you dont have a photometer to hand then there is a method for determining the necessary gamma valuepsychophysically included in PsychoPy(see gammaMotion Null and gammaMotion Analysis in the demos menu)The two additional tables in the calibration box of the monitor Center provide conversion from DKL and Ms colourspaces to RGB2.2 Units for the window and stimuliOne of the key advantages of PsychoPy over many other experiment-building software packages is that stimuli can bedescribed in a wide variety of real-world, device-independent units. In most other systems you provide the stimuli ata fixed size and location in pixels, or percentage of the screen, and then have to calculate how many cm or degrees ofvisual angle that wasIn PsychoPy, after providing information about your monitor, via the Monitor Center, you can simply specify yourstimulus in the unit of your choice and allow psychoPy to calculate the appropriate pixel size for youYour choice of unit depends on the circumstances. For conducting demos, the two normalised units (normandheight)are often handy because the stimulus scales naturally with the window size. For running an experiment it'susually best to use something like'cm'or'deg' so that the stimulus is a fixed size irrespective of the monitor/windowFor all units, the centre of the screen is represented by coordinates (0,0), negative values mean down/left, positivealues mean up/right2.2.1 Height unitsWith units everything is specified relative to the height of the window(note the window, not the screenAs a result, the dimensions of a screen with standard 4: 3 aspect ratio will range(0.6667, 0.5) in the bottom left to(0.6667, +0.5) in the top right. For a standard widescreen(16: 10 aspect ratio) the bottom left of the screen is(-08,0.5)and top-right is(+0.8, +0.5). This type of unit can be useful in that it scales with window size, unlike Degrees ofvisual angle or Centimeters on screen, but stimuli remain square, unlike Normalised units units. Obviously it has thedisadvantage that the location of the right and left edges of the screen have to be determined from a knowledge of thescreen dimensions. (These can be determined at any point by the window size attribute)patial frequency: cycles per stimulus(so will scale with the size of the stimulusRequires: No monitor information2.2.2 Normalised unitsIn normalised (norm)units the window ranges in both x and y from-1 to +l. That is, the top right of the windowhas coordinates(l, 1), the bottom left is(-l, -1). Note that, in this scheme, setting the height of the stimulus to be 1.0,will make it half the height of the window, not the full height(because the window has a total height of 1: -1= 2Also note that specifying the width and height to be equal will not result in a square stimulus if your window is notsquare -the image will have the same aspect ratio as your window. e. g on a 1024x768 window the size=(0. 75, 1)wille square.Spatial frequency: cycles per stimulus(so will scale with the size of the stimulus)Requires: No monitor informationChapter 2. General issuesPsychoPy -Psychology software for Python, Release 3.0.0b82.2.3 Centimeters on screenSet the size and location of the stimulus in centimeters on the screenSpatial frequency: cycles per cmRequires: information about the screen width in cm and size in pixelsAssumes: pixels are square Can be verified by drawing a stimulus with matching width and height and verifying thatit is in fact square. For a CRT this can be controlled by setting the size of the viewable screen( settings on the monitor2.2.4 Degrees of visual angleUse degrees of visual angle to set the size and location of the stimulus. This is, of course, dependent on the distancethat the participant sits from the screen as well as the screen itself, so make sure that this is controlled, and rememberto change the setting in Monitor Center if the viewing distance changesSpatial frequency: cycles per degreeRequires information about the screen width in cm and pixels and the viewing distance in cmThere are actually three variants: ',, 'deg Flat, and 'deg FlatPosdeg: Most people using degrees of visual angle choose Lo make the assumption that a degree of visual angle spansthe same number of pixels at all parts of the screen. This isnt actually true for standard flat screens-a degree of visualangle at the edge of the screen spans more pixels because it is further from the eye. For moderate eccentricities theerror is small(a.2% error in size calculation at 3 deg eccentricity)but grows as stimuli are placed further from thecentre of the screen(a 2 o error at 10 deg). For most studies this form of calculation is preferred, as it does not resultin a warped appearance of visual stimuli, but if you need greater precision at far eccentricities then choose one of thealternatives belowdeg FlatPos': This accounts for flat screens in calculating position coordinates of visual stimuli but leaves size andspatial frequency uncorrected. This means that an evenly spaced grid of visual stimuli will appear warped in positionbut will' deg Flat: This corrects the calculations of degrees for flatness of the screen for each vertex of your stimuli. Squarestimuli in the periphery will, therefore, become more spaced apart but they will also get larger and rhomboid in thepixels that they occupy.2.2.5 Pixels on screenYou can also specify the size and location of your stimulus in pixels. Obviously this has the disadvantage that sizesare specific to your monitor(because all monitors differ in pixel size)Spatial frequency: cycles per pixel(this catches people out but is used to be in keeping with the other unitsIf using pixels as your units you probably want a spatial frequency in the range 0.2-0.001(i.e. from I cycle every 5pixels to one every 100 pixels)Requires: information about the size of the screen(not window in pixels, although this can often be deduce from theoperating system if it has been set correctly thereAssumes: nothing2.2. Units for the window and stimuliPsychoPy -Psychology software for Python, Release 3.0.0b82.3 Color spacesThe color of stimuli can be specified when creating a stimulus and when using set Color( in a variety of ways. Thereare three basic color spaces that PsychoPy can use, RGB, DKL and LMS but colors can also be specified by a name(e. g 'Dark Salmon)or by a hexadecimal string(e. g. #OOFFOO')examplessual. GraLingStin(win, color=[1,-1,-], colorSpace='rgb')#will be redstim setcolor('Firebrick')#one of the web/X11 color namesstim. setcolor('FFFAF0)#an off-whitestim setcolor([0, 90, ll, colorspace='akl )#modulate along s-ccne axis in isoluminantstim setColor([l,0,01, color Space='lms')*modulate only on the L conestim setColor([l,1, 1], colorSpace='rgb')*alI guns to maxstim setcolor([1,0,01)#this is ambiguous you need to specify a color space2.3.1 Colors by nameAny of the web/X1l color names can be used to specify a color. These are then converted into rgB space by PsychoPyThese are not case sensitive, but should not include any spaces2.3.2 Colors by hex valueThis is really just another way of specifying the r,g, b values of a color, where each gun's value is given by twohexadecimal characters. For some examples see this chart. To use these in PsychoPy they should be formatted as astring, beginning with and with no spaces. (NB on a British Mac keyboard the key is hidden-you need to pressAlt-3)2.3.3 RGB color spaceThis is the simplest color space, in which colors are represented by a triplet of values that specify the red green andblue intensities. These three values each range between-l and 1Examples:[1, 1, 1] is white.10,0,0] is grey[1, -1, -1] is black[1.0.-1,-1] is red°[1.0.0.6,0.6] is pinkThe reason that these colors are expressed ranging between 1 and -l(rather than 0: 1 or 0: 255)is that many experimentsparticularly invisual science where PsychoPy has its roots, express colors as deviations from a grey screen. Underthat scheme a value of-1 is the maximum decrement from grey and l is the maximum increment above greyNote that PsychoPy will use your monitor calibration to linearize this for each gun. E. g, o will be halfway betweenthe minimum luminance and maximum luminance for each gun, if your monitor gamma Grid is set correctlyChapter 2. General issues
用户评论