An Introductory Example

Most psychological experiments follow the same formal schema: There is a sequence of discrete trials, possibly grouped into blocks, with independent, dependent, and control variables as parameters. Some of the parameters change from one trial to the next, some are constant within a block and some are not changed within one experiment, but may become variable if some other but similar hypothesis is investigated. The library PXL has been developed to increase the efficiency of programming psychological experiments. It implements a general schema for the procedural control of experiments and for managing experimental parameters. A programmer using PXL does not have to write similar pieces of code again and again but can concentrate on those functions which really are special for a single experiment. Usually these are those functions that use the experimental parameters to execute a single trial. The library not only takes over the procedural control of an experiment, it also provides many higher level functions for standard tasks in psychological experiments. This includes graphical output functions, response device handling, timing, adaptive procedures, and data formatting.

A major advantage of using the library is that all programs written with PXL have a rather similar appearance to the user. They all are controlled by parameter files which contain assignments to experimental parameters and a list of blocks and trials. Many experimental parameters are available in every experiment, but each program may add its own special parameters. Good experiments are customizable without the need for recompilation simply by changing parameter values.

To show how PXL programs look like we first present an example program for iconic memory research and show how this program may be used to replicate a published experiment. To see how a typical program using PXL might work we look at an example with some detail. The program is called icon, and has been written to replicate a number of iconic memory experiments (Sperling, 1960; Averbach and Coriell, 1961; von Wright, 1972; Merikle, 1981). The basic question posed by Sperling (1960) was how much can be seen in a single brief exposure. He used a 50 ms display of a matrix of at most 12 letter or digits arranged in up to 4 rows and up to 7 columns. With a stimulus onset asynchrony between 0 and 1000 ms there was an acoustic cue whose pitch told the subject which one of the rows to report. This is called a partial report procedure. The baseline of a subject's ability is provided by the whole report procedure, where there is no acoustic cue and the subject has to report the complete display. In our example we will set up icon such that it replicates one of the main experiments (Exp. 4) of Sperling (1960) as good as possible. To do this we have to set appropriate parameter values for icon. This implicitly demonstrates how PXL programs look like and how they are adapted to specific needs.

Describing a Single Trial

Each trial starts with a short waiting time defined by the parameter intdsptime. Timing values in PXL are given in milliseconds. Thus the parameter file for icon may contain a line like
   intdsptime = 2000
which assigns the value 2000 to intdsptime, telling the program to wait 2000 ms between two successive trials. After this waiting period there appears a small fixation cross on the screen telling the subject that he or she may initiate the character display. This is done by pressing and releasing any one of the response keys. The character display is shown exactly sigwait ms after the key has been released. Display duration is dsptime ms. The assignments
   sigwait = 500
   dsptime = 50
   cuedelay = 0
   cuetime = 200
define a 500 ms intervall between the subject's initialization action and the display and a 50 ms display duration. The stimulus onset asynchrony between the acoustic cue which indicates the subset to be reported in partial report trials and the display start ist cuedelay. It may be negative to indicate that the cue starts before the display. Cue signal duration is cuetime. The type of subset to be reported is task. Setting
   task = 2
defines a partial report procedure for the single rows as subsets to be reported. The number of rows and columns in the display and the character spacing is defined by
   columns = 4
   rows = 3
   rowdist = 250
   coldist = 200
   textsize = 160 
The character size is 160*10^-1 mm, the vertical baseline distance is 250*10^-1 mm and the horizontal character center distance is 200*10^-1 mm. Note that lengths are specified in 10^-1 millimeter units.

Three different sound signals are needed: one for each row. The array soundsigs gives their frequency values:

   soundsigs = [3200.0, 800.0, 200.0]
The character set used for the display is defined by the string targetset. Sperling (1960) used only consonants:
   targetset = "BCDFGHJKLMNPRSTUVWXYZ"
The actual display matrix for each trial is a random sample from targetset. It is stored in the string matrix. The subset to be reported is one of the rows of the display matrix. Its number is target. The target values are set in a later section of the parameter file in order to simultanously guarantee an equal number of target values for each row and a random ordering of all target values.

Sperling's subjects had to write their responses on a piece of paper that contained a reponse grid corresponding to the display. In our experiment the subjects have to type in the requested characters on the keyboard. There appears a cursor on the screen after the display which is automatically restricted to the screen line that corresponds to the requested character subset. The cursor keys may be used to move the cursor, typing a character automatically advances the cursor to the next position. The space bar or the DEL key may be used to erase a character. The subject's response is also recorded in an experimental parameter. Its name is answer and its value is printed into the data output file. The number of correct characters is automatically determined by icon and stored in the variable eval.

Several properties of the program are controlled by flags. These are collected in a flag string. Each flag corresponds to a single character and a flag's state is indicated by the character's case. We use the setting

   flags = "AbcdefgiLmnpqRstUvwz"
with\labelflagExample only the flags A, L, R, and U set. This indicates that an acoustic cue ist used (A), only complete input lines are accepted (L), target lines are selected at random (R), and the subject's input on the keyboard is automatically converted to upper case (U). The feedback message for the subject is defined by the string variable feedbackmsg. Its value is
   feedbackmsg = "%eval% characters correct"
where the substring %eval% is replaced by the actual value of the parameter eval during the experiment.

There are many more parameters available for exactly specifying how a single trial is run. Only those have been presented, which need values that differ from icon's defaults.

Procedural Parameters

Parameter values may either be constant throughout the whole experiment or may be variables that have different values in each trial or in a group of trials. A sequence of consecutive trials that are run without interruption is called a block. Within a single block some parameters may have a constant value in each trial. The same parameter's value in another block may be different. These parameters are called block parameters. Parameters that may change their value in each trial are called trial parameters. In order to tell a program which of the parameters are global, block, or trial parameters, the parameter file has to contain two argument definitions that specify the sets of block and trial parameters. The following example tells the program icon to use training as a block parameter and matrix, target, answer, and eval as trial parameters:
   block(training)
   trial(matrix, target, answer, eval)
The block parameter training is set to ON for practice blocks. These data will not be written into the formatted results file (used for statistical data analysis) although they will be present in the general data file. The meaning of the trial parameters has already been described. matrix, target, answer, and eval have to be trial parameters, since they will change their value from one trial to the next.

Now we may list the blocks and trials with their actual values. Here is an example of the first block:

   block(ON) {
      trial(?, 0, ?, ?)
      trial(?, 1, ?, ?)
      trial(?, 2, ?, ?)
   }
We have only specified three trials, but wish to present each of these ten times. This is accomplished by setting the trial multiplication factor dfactor to 10: We say
   dfactor = 10
in the assignment section of the parameter file and the list of trials in each block is expanded by automatically inserting nine more copies of each trial. The actual parameter values for most of the trial parameters are unknown before data collection. So the question mark appears as a place holder for them in the trial parameter array.

The trial list in a block defines the sequence of trials. Im many cases a random sequence is preferred. Setting the parameter randomize to ONtells PXL to randomize the sequence of displays within each block. Note, however, that randomization is restricted to trial lists within blocks. Sequences of blocks are never randomized automatically.

Controlling Data Output

Each experimental run of a PXL program is controlled by a parameter file and each run generates at least one data file. The main data file has the same structure as a parameter file. The only difference is that the data file contains the complete list of trials as created by the value of dfactor and in the order actually used during the experimental session. The trials of a data file do no longer contain question marks, but contain the actual values of the respective variables. Thus a data file is a complete protocol of the whole session.

Usually the data of an experiment will be used for further data analysis by other programs that are not able to handle PXL's data file structure. For these cases there is a second data file available. This is the result file. While data files have extension dat, result files have extension res. They do not contain the complete information that is available in a data file, but contain only the values of some experimental variables. The actual format of a result file is defined by the variable resformat. Our example parameter file contains the assignment

   resformat = "%subjectcode% %target% %answer% %eval%"
which tells icon to print values of the variables subjectcode, target, answer, and eval into each line of the result file. The values of these variables are computed and printed once for each trial. The parameter subjectcode is automatically set at run time from the command line.

This completes the example description of experimental variables used in the parameter file for the program icon for replicating one of the most simple experiments of Sperling (1960). The program uses many other variables which need not be described here, since their defaults already do what we need. The complete example parameter file is shown below, a detailed description of the program icon is contained in Chapter icon. Note the short-hand notation for three different values of target in the trial arguments of the listing below. The parameter dfactor = 10, two copies of each trial, and three values for target actually lead to 60 trials in each of the second and third data block.

\labelsperlingExample


Parameter file sperling.x from directory \pxl\app\icon

Back to table of contents


Author: Hans Irtel

irtel@psychologie.uni-mannheim.de