Revised:
The following sections from Denis Schluppeck (denis.schluppeck@nottingham.ac.uk) describe sample programs that illustrate ways to use Expo for Psychophysics.
Expo can easily be used to construct psychophysical experiments, including those that require simultaneous eye movement recording (See also Appendix E for a related discussion). Expo keeps very exact timing, handles display calibration and visual angle calculations automatically and has several other features that make setting up new psychophysics experiments very quick.
The most relevant routines for constructing psychophysics experiments are the Display Routines (Surface, Surface Element, Surface Overlay, Surface Matrix, Dot Field, DKL Texture, LMS Texture, Image Texture, RGB Screen), as well as several I/O Routines (Read Key, Read Mouse, Read Wheel, Sound) and Methods (2AFC, If… Else…, Op Variable, Quest, Random, Resolve, Unresolve, Waveform, Staircase, Statistics).
The following sections illustrate how to set up simple versions of the following standard psychophysical methods, in the hope that they will provide a useful starting point for more complex tasks:
In some experiments you may want to ask subjects to make adjustments to a test pattern until its appearance matches that of another pattern. There are many papers in the color vision literature that use this super-threshold matching to look at the effects of adaptation on appearance.
To construct the Expo program, we specify one state which contains three DKL Textures which are attached to one Surface each. I will refer to the DKL Textures by their 'Texture ID' and the Surfaces by which Texture ID they are attached to; indexing starts at 0, so they IDs will be [0, 1, 2]. Surface 0 will be used to create a fixation point at the center of the screen. The Surfaces 1 & 2 will be presented left and right of the fixation point. We can use the ReadKey routine to drive the value of the contrast parameter in the DKL Texture attached to Surface 2, such that pressing the keys '1' will increase and '2' will decrease the contrast.
Insert three DKL Texture routines. The DKL Texture 0 specifies the Fixation point. Set its Type to 'Uniform' and leave its ID 0. DKL Texture 1 specifies the standard stimulus on the left of fixation. Let's use a Sine texture with Spatial Frequency 2. The ID for this texture should be set to '1', and its contrast to 0.5. DKL Texture 2 specifies the macthing stimulus whose contrast we will manipulate by pressing keys. Set it up as DKL Texture 1, but rather than fixing its contrast 'contrast' into the field specifying its contast. When you click OK, confirm that you want to create the new global variable 'contrast'.
Now insert the three Surface routines to go along. Surface 0 is our fixation spot. It should be Oval, with width and height 0.25 Degrees at X=Y=0, which is the center of the screen. The Texture ID is 0, to keep things consistent. Surface 1 is the stimulus to which we want to match. Make it Oval with width and height 4 Degrees, at X = -3, Y = 0 Degrees. Surface 2 is the matching stimulus. Set it up as Surface 1, but with X = 3, to place it on the right of fixation.
All that's left is to insert a 'ReadKey' routine which will change the value of the variable 'contrast' as we press '1' and '2'. Set the routine up as follows. Note that 'stepSize' is a new variable, with which we can specify how much each key press should change the value of contrast. Also note that pressing '2' will send 'Source 1' + 'Source 2' to the routine's destination, pressing '1' will send 'Source 1' - 'Source 2'. Tick Assert STOP.
To set up the schedule, drag the new state into the Schedule window and set up 'Until' and 'Go To' appropriately.
In the Variables window (Command-B, if it is not visible already), set contrast to 0.4 and 'stepSize' to something small, say, 0.01. Press Command-R to run the program, Command-K to capture the key presses and you should see two patches on your Display. Pressing '1' will decrease the contrast of the right patch by 'stepSize', pressing '2' will increase it by the same amount.
This section describes how to set up a simple (adaptive) threshold experiment using the Staircase routine in Expo. The stimuli are patches of Sine gratings, for which the contrast is changed, depending on yes/no responses by the subject. If the subject reports 'yes', the contrast is decreased, if 'no' the contrast is increased. This way of estimating thresholds (roughly) is sometimes called the Method of Limits.
The Staircase routine should be the first item in the definition of the slot.
You can see in the screen capture above how the schedule was set up. The important points are that the duration of the cue state should not be '0', so the Sound routine can actually play the cue, and that the response state waits until either key '1' or '2' is pressed before gonig back to the start state.
Save the experiment definition, press Command-R to run the experiment. Command-B brings up the Variables window, double click the green square (or press Command-K) to start catching mouse and key events, and the detection experiment should start after a button press. Press '1' if you saw a grating pattern shortly after the tone. The contrast of the stimulus is adjusted with your yes/no responses over 50 trials. You can see the final value of contrast in the Variables window, but you can also plot the progression of the value of 'contrast' during the staircase.
You analyze data in Expo or export it in tab-delimited format and read it into e.g. Matlab for further analysis. See the section on Analyzing Data for details on how to do this.
This section describes how to set up a simple (adaptive) two alternative forced-choice (2AFC) experiment using QUEST in Expo. The stimuli are patches of gratings whose contrast varies following the QUEST rule, depending on correct/incorrect responses by the subject. The level of complexity of this program is a little higher than the previous one, as it involves the 2afc routine, randomizing the order of events and calculating whether responses were correct or incorrect.
The flowchart shows the design of the experiment. At the heart of the program is the Quest routine which calculates (like Staircase) the next intensity level that should be chosen. On first pass through the routine, this is just set to an initial value, for later passes, the history of correct and incorrect responses is taken into account. Quest also has a rule to decide whether the pattern of correct and incorrect responses indicate that subjects are close to threshold, and therefore to stop the experiment.
The parameter coding intensity is passed to the display routine, which presents the stimulus of that level in one of two intervals. Whether this is the first or second interval is determined by the output of a Random routine. Once the stimuli have been displayed, the program waits for a response from the subject, calculates whether the response was correct or not and passes the result back to Quest. Another cycle starts.
The screen shot below illustrates the Expo definition of the states and event schedule.
The Sound routines provide the auditory cues for the 2 intervals. Set
The 2afc procedure control the presentation of the textured surfaces. The values here need to be set for each substate in the MATRIX independenly (see also setup of Read Key below). Set the values in the 2afc routine as follows. in the "Show" drop down menu select '2AFC [2]' - the states window will now show up the two substates of the MATRIX.
In AFC [0], set:
In AFC [1], set:
Set the view back to "All States", then the change the following parameters, which will be applied to both of the substates at the same time:
DKL Texture provides the texture for the Surface. Set the values for e.g. a sawtooth grating:
The Surface routine displays the grating. It can have any shape, size, location you like, as long as the Texture ID matches the DKL Texture ID.
Read Key reads key presses, records their timing and assigns a value to an output variable, depending on a specified binary operation. As for the 2afc routine, we need to specify two different outcomes for the two MATRIX substates
In AFC [0], set:
In AFC [1], set:
Back in the "Show All States" view, set:
The Quest routine is a simple filter that reads a response and (depending on whether that response is positive or negative) decreases or increases the value of its output according to the Watson & Pelli QUEST procedure. Set the following values:
Make sure to tick the "Assert DONE" box. This will enable Quest to finish after 10 up/down reversals.
After a key is pressed in questInit, control is turned over to questUpdate. On first pass, it sets contrast to the appropriate value, then goes to the MATRIX labelled 'display'. The display state should be active for 1.2s (two intervals + isi). Then it will wait until a key is pressed, change the value of correctR, depending on which substate was active and which button was pressed. Make sure that "Randomly within Dimensions" is selected in the "Go To" tab, otherwise the program will alternate between the substates and the presentation interval will be predictable. Once
Save the experiment definition, press Command-R to run the experiment. Command-B brings up the Variables window, double click the green square to start catching Mouse and Key Events, and the 2AFC experiment should start. Press '1' if you saw the pattern in the first interval, '2' if you thought it was in the second. Difficulty of the task is adjusted with your correct and incorrect responses over the 2afc trials.
Below is a plot of the Destination parameter of the Quest routine against trial number. In this particular run of the experiment, Quest determined that threshold was reached after 26 repeats of the 2afc task.