The E-Primer: An Introduction To Creating Psychological Experiments in E-Prime (Preview)
The E-Primer: An Introduction To Creating Psychological Experiments in E-Prime (Preview)
The E-Primer: An Introduction To Creating Psychological Experiments in E-Prime (Preview)
An introduction to creating
psychological experiments in E-Prime
Michiel Spap
Rinus Verdonschot
Saskia van Dantzig
Henk van Steenbergen
Cover design: Mulder van Meurs, Amsterdam
Lay-out: V3-Services, Baarn
ISBN 978 90 8728 183 0
E-ISBN 978 94 0060 129 1
NUR 770/980
Michiel Spap, Rinus Verdonschot, Saskia van Dantzig, Henk van Steenbergen
/ Leiden University Press, 2014
All rights reserved. Without limiting the rights under copyright reserved above,
no part of this book may be reproduced, stored in or introduced into a retrieval
system, or transmitted, in any form or by any means (electronic, mechanical,
photocopying, recording or otherwise) without the written permission of both the
copyright owner and the authors of the book.
Acknowledgements
This book is the result of intensive collaboration between people who, at one
time or another, studied or worked at Leiden University. In 2006, we extended a
collection of E-Prime exercises into something resembling a coherent course. In
subsequent years, we initially as a rather dynamic collective of PhD students
have revised the manual in order to help those who want to prepare for creating
their own psychological experiments. Later, we expanded the work so it can now
also serve as a basic introduction to E-Basic coding in E-Prime.
Along the way, many people helped us in the writing of this book. First, we would
like to thank David McFarlane, Michael Richter, Kerstin Brinkmann and the peo-
ple at Psychology Software Tools for providing helpful comments when reviewing
an earlier draft of this book. There were also numerous students who provided
useful feedback during the period when this book was being used for courses at
Leiden University. In particular, we would like to thank Hans Revers and Erwin
Haasnoot for their constructive comments. Many more people have joined our
journey, but at different moments in time. Each of us would like to mention a few:
Michiel Spap: I would like to thank Elkan Akyrek for introducing me to E-
Prime and Jan-Rouke Kuipers for sharing my pain as we first started to teach it
ourselves. Stephan Verschoor for being my favourite unhappy victim for dem-
onstration purposes when no student volunteered the nightmare of any teacher.
Wido la Heij and Gezinus Wolters for providing my mind with many brilliant
exemplars in teaching: easily retrieved from memory, yet so hard to successfully
imitate, and Zania Sovijrvi-Spap, for continuing to put up with a coding geek.
Rinus Verdonschot: I am grateful to the Cognitive Psychology department of Lei-
den University for giving me the chance to teach E-prime to so many enthusiastic
students and also to the people who participate actively in the Google E-Prime
group and, thus, help out researchers all over the world. Lastly, a big thanks to my
family, friends and colleagues.
Saskia van Dantzig: Id like to thank Diane Pecher, who introduced me to E-
Prime and encouraged me to develop the E-Prime course for psychology students
at the Erasmus University. This course supplemented several chapters of this
book. Diane was also one of the reviewers of this book. Thanks to Rolf Zwaan
for challenging me to program complicated experiments, which boosted my pro-
gramming skills and let me explore the endless possibilities of E-Prime. Thanks
to my former colleagues at Leiden University and Erasmus University. To con-
clude, thanks to Alexander for his encouragement and to my kids for enabling me
to do the work I love.
Henk van Steenbergen: I would like to thank the many colleagues at Leiden
University with whom I have been sharing E-Prime problems and solutions on
a daily or weekly basis. Thanks to Guido Band, Bernhard Hommel and Sander
Nieuwenhuis for encouraging me to publish this book. Thanks to Belle Derks
for helping us to set up the revised E-Prime course, and Margot Schel for help-
ing me to thoroughly revise and extend the predecessor of this book, resulting in
the current end product. Anne Bolders provided great help with proof-reading.
Thanks to Thijs Schrama for providing technical help along the way. Finally, I am
grateful to Eveline and my family and friends for encouraging me to get this book
published.
Table of Contents
Introduction 11
What is E-Prime
? 12
Online support 12
Chapter I: E-Prime
at a glance 15
E-Studio, E-DataAid, E-Recovery and E-Merge 15
Object Oriented Programming 17
Conceptualising an experiment 19
E-Studios structure 22
E-Objects 24
Procedures, Lists and TextDisplays 25
TextDisplays 26
Tutorial I: A simple RT experiment 36
Exercises 41
Advanced Exercises 43
Chapter II: Attributes, Slides and more on Lists 45
Experimental design in E-Prime
46
More on lists 47
Showing an image 53
Showing multiple images and layers of texts 56
Feedback 56
Tutorial II: The Simon Task 58
Exercises 62
Tutorial III: Implicit Association Task 62
Exercises 64
Advanced Exercises 65
8 THE E-PRIMER
Chapter III: Sound, movies, hardware, and nested Lists 67
SoundOut objects and digital audio 68
MovieDisplay object 73
Wait object 74
Labels 75
Experiment properties 76
Nested Lists 79
Counterbalancing and between-subject manipulations 80
Tutorial IV: Visual search and distracting sound 81
Exercises 86
Tutorial V: Ego depletion experiment 87
Exercises 88
Advanced excercises 89
Chapter IV: Beginning programming in E-Prime
91
E-Basic in E-Prime
92
Different types of variables 93
Math operators 95
Mathematical functions 98
Combining numbers and text 98
String functions 100
Linking variables to input/output windows 101
Linking variables to attributes 103
Inlines everywhere 105
Tutorial VI: A working memory test 108
Exercises 111
Advanced excercises 111
Chapter V: Decision making in E-Basic 113
The If-Then statement 113
Combining conditional expressions 115
Comparing values 118
How to terminate parts of your experiment 119
Tutorial VII: The Ultimatum game 121
Tutorial VIII: The Cyberball game 128
Exercises 134
Advanced exercises 134
9 TABLE OF CONTENTS
Chapter VI: Loops and Arrays in E-Basic 137
Looping with Labels 137
The For-Next Loop 139
Loops with conditional expressions 141
Lists and arrays 143
Arrays of a user-defined data type 149
Tutorial IX: Quasi-random trial selection 150
Exercises 159
Advanced exercises 159
Chapter VII 161
Interactions between Slide objects and the Mouse 161
The Slide object 162
Accessing the mouse in E-Prime
165
Programming user interactions 166
Tutorial X: A simple questionnaire 169
Tutorial XI: A mouse tracking task 172
Exercises 175
Advanced exercises 176
Chapter VIII: Various Input/Output devices 179
The Serial-Response box 180
Voice-key experiments 182
Sending signals using the parallel port 185
Reading and writing text files 190
Tutorial XII: Making a Voicekey (VK) test program 192
Exercises 194
Advanced Exercises 194
Reference List 197
Appendix: Overview of available E-Objects 199
About the authors 201
Index 203
11
Introduction
The E-Primer is written with a reader in mind who is eager to learn, but knows lit-
tle, if anything, about programming, computer science and the actual implemen-
tation of all those wonderful scientific experiments that make up the body of the
reading list of psychologists and cognitive scientists. This is not to say, however,
that more experienced readers will not find it interesting as many chapters also
deal with advanced E-Prime
?
There are a number of reasons to learn E-Prime
programming skills.
Second, learning to program is more than just learning a specific programming
language. Programming involves mostly logical thinking. Once you have learned
to program in E-Prime
: http://step.psy.cmu.edu/.
This website includes ample examples of common paradigms in experimental
psychology. It should be noted that these experiments are programmed in the
previous version of E-Prime
support. Or, perhaps you have a more design-related question, or just want to
let everyone know how much you love designing experiments in E-Prime
:
http://groups.google.com/group/e-prime.
15
Chapter I
E-Prime
at a glance
In this chapter, you will learn
About: E-Studio, E-DataAid, E-Recovery and E-Merge
Object Oriented Programming
E-Studios structure
Procedures
Lists
TextDisplays
How to: Create your first experiment
Pimp your experiment
Save and analyse your data
This chapter will introduce you to the E-Prime
,
or even E-Prime
output. Whenever an E-
Prime
crashes during an experiment, no .edat2 file is generated. However, when the ex-
periment is running (aka. runtime), a .txt file is created to which data from each
trial are appended. This .txt file contains the same data as the .edat2 file, but it
is rather inconvenient to analyse. So, should E-Prime
.
Conceptualising an experiment
When you are designing an experiment you might be tempted to run to your com-
puter and start programming straight away. However, before you start program-
ming, you should try to visualise what your experiment will look like. This may
sound self-evident, but it remains an important step that is easily omitted, with
nasty, if not fatal, consequences ensuing. So, try to conceptualise the experiment
by asking yourself the following questions:
What kind of design do you need? A between-subjects design or a within-
subjects design?
Which variables do you manipulate? In other words, what are the independ-
ent variables? How many levels do these variables have? How many condi-
tions does the experiment have?
What are the dependent variables that you will measure? For example, do you
aquire data regarding reaction time, error rates, and so on?
Does your experiment contain blocks of trials ? If yes, what is the order of
presentation of these blocks?
Does your experiment have a practice block ?
How do you instruct the participant?
What happens during a trial? What kind of stimulus is presented? How long
is the stimulus presented for? How should the participant respond? What
happens if the participant responds too slowly?
20 THE E-PRIMER
What happens between trials ? Does the participant get feedback? How long is
the interval between trials (we call this the inter-trial interval, ITI)?
In which order are trials presented? In random order? In a fixed order? Or in
a semi-random order?
To facilitate programming, it can be useful to draw a flow chart that displays
the structure of the experiment. An experiment typically contains a hierarchy of
Procedures. The main Procedure (called SessionProc in E-Prime
) determines
the global order of events in the experiment. This one is depicted on the left. Sub-
Procedures are depicted to the right of the main Procedure. A flow chart contains
different elements:
A flow chart contains different elements:
Event : Refers to a specific event during the experiment, for
example the presentation of a picture, text or sound. Indi-
cates what happens, the duration of the event, and how the
event is terminated (e.g. by pressing the space bar).
Sub procedure: Refers to a Procedure at a lower level of the
hierarchy. Indicates the name of the Procedure, the num-
ber of repetitions of the Procedure and the order of the
repetitions (e.g. random).
Decision: The Procedure branches into two options. The di-
amond indicates a criterion (e.g. response = correct, or re-
action time < 1000). If the criterion is met, the Yes-branch
is followed; if the condition is not met, the No-branch is
followed.
Arrow: Indicates the flow of the events.
On the next page is a flow chart of a simple reaction time experiment with one
practice block and one experimental block.
Note that if this way of visualising an experiment immediately strikes you as a
great way to organise your thoughts into a workable design, then that is won-
derful. However, if you feel it is a tedious amount of work that constrains your
creativity by needlessly imposing order, then you might do best to save yourself
the amount of paper involved. After all, some people prefer to work at a messy
office desk. However, even if this is the case, we hope you will try to understand
21 E-PRIME AT A GLANCE
the endeavour as we will be illustrating various aspects of E-Prime
using these
flowcharts.
Now, lets get back to the more practical work and have a look at E-Studio!
22 THE E-PRIMER
E-Studios structure
Heres an example of what an experiment looks like when we open it in E-Studio.
A B C D E F G H
A. In the Menu you can perform a number of typical Windows operations,
such as opening and saving your experiment. In addition, by clicking on
View, you can open the other areas (B G and a few other ones). By clicking
the Run icon
p
or pressing F7, you can compile and run the experi-
ment. Use the E-Run Test icon
gggggggggggg
to run a quick test of your experiment (E-
Prime 2 only; E-Prime 1 users may consider the Clock.Scale code described
in Chapter IV).
.
To use one of them, drag it onto either the Structure area (D) or a Procedure
object (G). Here is a favourite trick: right-click on them, unselect Large icons
and voil: more screen real estate!
C. The Properties window displays the properties of the currently selected in-
stance. By selecting the TextDisplay, for example (see below), one can quickly
change certain properties (such as the background colour) from within the
properties area. Typically, you can also use the working area (E) for that, by
clicking on the hand (see right), which tends to be easier.
D. The Structure window shows the hierarchy of the experiment. Most experi-
ments are organised into blocks and trials . For example, you may want an
experiment to have two blocks: one for training your participants, followed by
one for testing them.
E. This area which covers almost half the screen is called the Workspace .
This is where you can edit elements of the experiment in a visual, easy way.
When you double click on an object in the Structure window, it appears in the
Working Area.
F. The Output window appears when you click the Generate button in order
to compile the experiment. If there is an error in your experiment, the out-
put window will show a message describing that error. In E-Prime 2 Profes-
sional an Experiment Advisor is available for detecting design and timing
errors.
G. The Procedure object called SessionProc displays a timeline with the main
Procedure of the experiment.
H. The Browser window shows all objects (instances) that you have created for
the experiment. In the Browser window you can copy objects. E-Prime
then
creates a new instance with the same properties as the original object. You can
also copy objects by dragging the object with your mouse while holding down
your ctrl key. If you simply want to reuse the same object at a different location
of the experiment hold down ctrl+shift while dragging.
24 THE E-PRIMER
E-Objects
E-Prime
contains different objects, each with its own characteristic features and
purposes. Here is an overview of the objects that are used most often.
A Procedure is used to determine the order of events in an experiment.
A List contains rows of items with specific properties (attributes).
An ImageDisplay displays a picture.
A TextDisplay displays one or more lines of text.
A MovieDisplay displays a short movie clip.
A Slide is a container type of object which can simultaneously present
text, images, sound and so on.
A FeedbackDisplay gives specific feedback on the participants response
to a stimulus.
A SoundIn is used to record sounds.
A SoundOut presents a sound file (.wav/.mp3/.wma).
An InLine is used to add E-Basic script.
A Label indicates a particular location on the timeline. The program can
jump backwards or forwards to a Label, in order to repeat or skip a part
of the Procedure.
A PackageCall contains reusable blocks of E-Basic script written by us-
ers of E-Prime 2 (often used in Procedures, which are used repeatedly
or, for instance, in connecting equipment such as an eye-tracker to an
E-Prime
. It is used to specify
the sequence of events in the experiment.
A Procedure is depicted as a timeline. The green
ball on the left indicates the start of the Proce-
dure and the red ball on the right depicts the end
of the Procedure. In this example, the Procedure
called TestProc presents two TextDisplays. First,
it shows the Wait1000ms TextDisplay, followed
by the PressSpace TextDisplay.
When you open a new experiment, it already contains a Procedure, specifying the
order of events in an experimental session. This Procedure is called SessionProc
by default.
Lists are extremely useful objects. They repeat and reorder Procedures. Conse-
quently, they determine the way in which Procedures are repeated, for instance,
randomising certain variables that are contained in the List.
When you create a new List, you will see this win-
dow:
The rows contain different items, the columns
indicate the properties (called attributes ) of these
items.
By clicking on the Add Level icon or the Add Multple Levels icon , you can
add one or more rows, respectively.
By clicking on the Add Attribute icon or the Add Multiple Attributes icon ,
you can add one or more columns, respectively.
Each list has a column named Procedure. By filling
in the name of a Procedure in a particular row, you
specify which Procedure is used by that row. If the
Procedure name doesnt yet exist in the experiment,
the following pop-up window appears, telling you
that the Procedure doesnt yet exist and asking you
whether the Procedure should be created. Click Yes.
26 THE E-PRIMER
Subsequently, E-Prime
will simply
cut off the text where the screen ends.
29 E-PRIME AT A GLANCE
Display Name: E-Prime 2 Professional adds the feature to use multiple displays
independently. Here, you can select the display to use for this specific Stimulus.
Frame tab
In the Frame tab, you can specify a rec-
tangular area of the screen in which the
object is presented. This area is called
the Frame.
Under Size you can specify the Width
and Height of the frame. You can either
specify the size relatively (in percentage
of the total screen size) or absolutely (in
pixels). Note that this is 75% by default
as in the Production Release version of
E-Prime
(2.0.10.242).
If the Frame is smaller than the screen, you can specify its position on the screen
under Position. You can set four different parameters. XAlign and YAlign specify
which point of the frame is used as a reference for placing the frame on the
screen. X and Y specify the horizontal and vertical position of the frames refer-
ence point on the screen. You can compare it to putting a piece of paper on a
pinboard. The parameters XAlign and YAlign specify the position of the pin rela-
tive to the paper, the parameters X and Y specify the position of the pin on the
pinboard (see examples below).
XAlign : Center XAlign: Center XAlign: Right
Align: Bottom YAlign : Center YAlign: Top
X : Center X : Left X : Right
Y : Center Y : Center Y : Top
BorderColor : Shows the color of the border, if BorderWidth is greater than 0.
BorderWidth : With this property, you can set the width of the border around the
TextDisplay in number of pixels.
30 THE E-PRIMER
Font tab
Name: The type of font to use in this
TextDisplay .
Point Size: The size of the font in points.
This is the standard unit of font that is
used in all Windows applications, but be
careful: most experiments run in a lower
resolution than normal, so fonts tend to
look bigger when running the experi-
ment.
Bold: Shows the word in a thicker typeface, which is pretty self-evident, but please
note that E-Primes default for Bold is on.
Duration tab
This is probably the single-most impor-
tant tab. Here, you adjust the timing part
of the stimulus, stimulus duration ad-
justments being crucial (some might say:
tantamount) to classic cognitive experi-
ments. In addition, it is where you select
which input devices (such as keyboard,
mouse, Serial Response Box) are used to
record responses. The tab also deals with
most other aspects of responding: what
should happen after a response?, what
was the correct answer?, etc.
Duration : With this property , you can manipulate how long the TextDisplay is
presented on the screen. When you set this to -1, it acts the same as when you
select the infinite duration.
Timing Mode: E-Prime
.
More on timing issues later, but for now, here is the basic story. It takes time
(mere milliseconds, or even less) between the moment when E-Primes clock no-
tices that an event should be triggered and when that object is actually presented.
Because of this, events may not synchronise with time, which E-Prime
calls
cumulative drift. To prevent this, you can change the TimingMode to Cumula-
tive, which changes the duration of this TextDisplay to adjust for this drift. Which
TimingMode you should use depends on your experiment. If your experiment
consists of relatively long inter-stimulus intervals (say, a few seconds) and timing
is not crucial, using the Event Mode may suffice. However, if your experiment de-
pends critically on timing, such as when presenting subliminal stimuli with a du-
ration of 20 ms, you may need to use the Cumulative Mode. However, Procedures
using objects in this mode can behave oddly and unpredictably, especially when
they include Terminate End actions (see description below) or scripts. When tim-
ing is critical, you should refer to the chapter on Critical Timing in the Users
Guide.
The other way to cope with a certain type of timing error is the PreRelease. Sup-
pose you wish to present high-resolution images, perhaps even in a rapid serial
visual presentation task. In this case, E-Prime
puts on your
processor, you can use TextDisplays prior to the pictures you want to use and
set some PreRelease to that TextDisplay . This PreRelease time is used to load
the oncoming picture, sound or other heavy object into memory while the cur-
rent TextDisplay is still shown. Then, when it is show-time, E-Prime
has already
loaded the object, thereby decreasing onset errors in the next stimulus. If timing
is critical in your experiment, we recommended that you study the Critical Tim-
ing chapter in the E-Prime
Users Guide.
generally logs far too much if you allow it to. However, we once observed the
reaction of someone who had logged everything BUT the critical response
times and came up with a convenient rule of thumb: it is better to log too
much than too little.
If you want the participant to respond to the TextDisplay , you will have to add an
InputDevice. To do so, click on Add and select Keyboard or Mouse . More devices
(such as the Serial Response Box) can be available, but you will need to add them
first by clicking on Edit > Experiment > Devices > Add.
After an InputDevice is selected, you can edit which keys are Allowable. Nor-
mally, you enter a range of characters here, for example: Allowable: abcd. Then,
all four keys (a, b, c, d) are seen as valid responses. Pressing e or A (shift+a),
for example, will not do anything. If you want to use the space bar or other
special keys, you will have to use the round brackets and capitalised letters: Al-
lowable: {SPACE} for example. The default ({ANY}) is not recommended for a
serious experiment, since accidental key-presses should not be counted as real
responses.
Whereas the Allowable part generally has several options, usually only one of
them is Correct. It is important to understand the fundamental difference be-
tween the allowable and the correct response. As a rule of thumb, then: the al-
lowable set of responses covers the range of possible responses and is generally
the same for each trial; the correct response is typically only the one response
that the participant should have made and is generally different for each trial (al-
though one can, in E-Prime 2 Professional, have multiple correct responses). It
is probably best to think of correct response in terms of accuracy, rather than
appropriateness. Both in the case of {ANY} response being allowable, and if
only one key is allowed, the accuracy of the response becomes pretty meaning-
less.
The correct response doesnt have to be specified. For example, a welcome
screen doesnt have a correct response. It can simply be closed after pressing a
specific key. On the other hand, the allowable response should always be speci-
fied. If you have failed to do so, and the duration is set to infinite, your experi-
ment will get stuck, since the participant cant press any key to close the Text-
Display .
33 E-PRIME AT A GLANCE
By adjusting the Time Limit property , you can increase or decrease the amount
of time, following the onset of the stimulus, in which a response is logged. Often,
this will be the same as the Duration of the stimulus, which is the selected option
by default. That way, if the duration of a stimulus is 2000 ms, a response will still
be logged when it follows 1999 ms after the onset of the stimulus. However, it is
possible to ignore extremely late responses (outliers), by setting the Time Limit to
1000 ms. A response that follows 1100 ms after the onset will then not be logged.
It is also possible to log responses even longer than the duration of the stimulus.
If, for example, you use a subliminal priming paradigm, you could set the Dura-
tion of the stimulus at 20 ms, but the Time Limit at 1000 ms. Then, responses
are logged relative to the onset of the subliminal stimulus, even if it is no longer
being shown.
End Action specifies which action to undertake when the participant responds.
By setting this to Terminate (default), for example, the TextDisplay is immediately
wiped off the screen when an allowable response is given. The Jump option will
be discussed in a later chapter.
Sync tab
The Sync tab enables
you to switch on on-
and offset synchroni-
sation. To understand
what synchronisation is
about, you must grasp
a basic fact about both
cathode ray tube (CRT or, the old type) and liquid crystal display (LCD or, the
flat type) computer monitors: each dot (pixel) you see on the screen is updated
sequentially: that is, from up to down. Although it may look as if the pixels you
see on the screen are static (especially with LCD monitors), in fact they are up-
dated at a rate of at least 60 times each second: 60 Hz (or about 100 Hz when
using ancient CRT monitors, which are actually better for doing experiments).
Crucially for psychologists, especially those working with perception and (sub-
liminal) priming, the presentation of visual stimuli is constrained by the timing
characteristics of the monitor.
Consider, for example, a psychologist who wants to show a subliminal prime, say,
a smiling face, 10 milliseconds before the onset of a word to which the participant
is required to react. When Onset Sync and Offset Sync are turned off, and the ex-
periment is running on a 60 Hz monitor (still a standard especially in LCD), the
34 THE E-PRIMER
screen is updated every (1000 / 60 = ) 17 ms. When E-Prime
is programmed to
show the smiley, it sends commands to the screen, but there is no way to know
exactly how and what it shows: it may show everything 17 ms later, for 17 ms, be-
cause it just finished updating the screen; but it may also show only half a smiley
because the updating cycle just got round to half the screen on its up to down
route. This phenonomenon is called screen tearing . The same may then happen
with the word to be responded to. However, if we enable Onset Sync for both the
prime and the word, E-Prime
is the
thing for you. Not only does
it let you collect standard out-
come measures, such as re-
sponse, accuracy and reaction
time, but it also provides an
arsenal of auditing weaponry
to bedazzle even the most
number-crazed statisticians.
For example, if you wish to
check whether E-Prime
re-
ally presents your stimuli for
t milliseconds, you can log
the duration error.
35 E-PRIME AT A GLANCE
You can select as many values to log as you like, but try to be somewhat pragmatic:
you may want to log the time it took for a participant to read the introduction-
screen, so you can log RT for this display. On the other hand, we have yet to hear
from a psychologist who is interested in the timing accuracy of this introduction-
screen, so you dont generally log OnsetDelay, for instance.
Often, a psychological experiment requires only one response for each single
trial. For example, in a Stroop task, each displayed word requires one reaction.
This translates, e-wise, in that the text display, which displays the word WHITE,
collects responses (such as the correct answer: black). For this object, favourite
logging properties would then be:
CRESP : Correct response. As stated above, typically depends on the condition
and trial.
RESP : The actual response.
ACC : The accuracy, defined as 1 if the RESP and CRESP are equal and other-
wise 0.
RT : Reaction, or response time (ms), which is RTTime OnsetTime.
OnsetDelay : Difference between programmed time the stimulus was to be
presented (in the case of visual stimuli: on the screen) and the actual time its
presentation started.
DurationError : Difference between the prescribed duration the stimulus was
to be shown on screen and the actual time. Or strictly speaking: OffsetTime +
PreRelease OnsetTime Duration.
Which logging properties you should use, depends on your experiment. Three
other valuable logging properties are:
RTTime : Time stamp of the reaction relative to the beginnig of the experi-
ment (ms).
OnsetTime : Time stamp of stimulus onset relative to the beginning of the
experiment (ms).
OffsetTime : Time stamp of the end of the presentation of the stimulus (ms)
relative to the beginning of the experiment. Notice, however, that this is not
necessarily when the stimulus ends: a visual stimulus remains on the screen
as long as no other stimulus overwrites it, and an audio file of 4 seconds long
may contain 2 seconds of silence.
36 THE E-PRIMER
Tutorial I: A simple RT experiment
Do you, like Michiels cat (right), have
lightning reflexes? Believe it or not,
many first-time participants who are
unfamiliar with psychological experi-
ments want to know how well they did
and considering that your first priority
is most likely not pinning someone on
a kind of normal (vs abnormal!) distri-
bution, it is always good to tell them
they were quite fast. Lets find out
how to do this!
It can be hard to start programming an experiment from scratch, so you may find
it easier to follow a certain process schema. First, and crucially, what is it that you
want your participants to see during an experiment what do you know from your
own experiences with psychological research in the lab? Imagine examples, rath-
er than defining everything beforehand: instead of trying, for example, to show
Stroop-like stimuli, ask yourself: so what is a Stroop-like stimulus? Well, you
answer, something like the word red written in blue. Then, define the Procedure
of a trial as the sequential presentation of such stimuli.
Common elements of an experiment include:
Trials: Typically, this includes:
A fixation: This stimulus that is often shaped like a crosshair or addition sign
warns the participant that the interesting stimulus is approaching.
The target: The interesting stimulus itself, to which the participant is to re-
spond.
Some form of feedback (occasionally).
Blocks: Are defined by the number and variant of trials they contain. For in-
stance ,
A training block may contain some 20 trials and is used to get the participant
accustomed to the experiment.
A testing block contains more trials , depending on the variability of the out-
come measures, the number of conditions, etc.
37 E-PRIME AT A GLANCE
Step 1: Building the basic hierarchy
Open E-Studio , select Blank experiment.
Save your experiment in a location where you can find it again easily (e.g. a
USB stick, your personal drive, etc.). Give the experiment a unique name that
doesnt contain weird characters (slashes, dots, etc.).
Make sure you always save your work. Keep your file structure well-organised!
Subsequent chapters may ask you to re-use part of your earlier work. There is
an additional advantage: by saving your work you also start a personal collec-
tion of experiments that may serve as a source for future reference.
In the Structure view, double-click on SessionProc ; you will see a timeline pop-
ping up:
Drag a List from the Toolbox to the SessionProc to the timeline and call it
BlockList (this is a conventional name; you can also use any other name as
long as it doesnt contain strange characters or spaces).
Double -click on the BlockList and add one row by clicking on the icon of the
arrow pointing down.
Change the name of the Procedure column of the first row to TrainingProc
by editing the text. Please note that it is also possible to click on the down
triangle next to the name and change the Procedure to an existing one: Ses-
sionProc . DO NOT DO THIS! For some reason, this seems the most intuitive
action and we have seen many students astonished at how fatally E-Prime
crashes when this seemingly minor mistake is made.
E-Prime
will ask you whether you really want to create this new Procedure
TrainingProc and here you select Yes. If E-Prime
You could also consider dropping the BlockList and simply running the
TrainingList and TestingList consecutively in your SessionProc . However, we
think that the BlockList solution has many advantages. For example, while test-
ing whether your experiment runs correctly, you can easily skip parts of it by
setting the weights of the respective rows to 0. Moreover, if you want to abort
your experiment with Inline scripts, you can do so by simply terminating the
BlockList (see Chapter V). The BlockList is also a proper place to nest Lists used
for counterbalance /between-subject manipulation purposes (see Chapter III).
The attributes of these nested Lists are then automatically inherited by Lists
lower in the experimental hierarchy.
Step 2: Programming the trial
The trial is perhaps the most important unit in your programming experi-
ments. Here, you will be showing your participant a fixation for 500 ms, and
a target for an infinite or until key-press amount of time.
Double -click on the TrialProc and drag two TextDisplays to the timeline. Name
the first Fixation and the second TargetStimulus.
Edit the Fixation to show a single + sign and to have a duration of 500 ms.
This is our inter-trial interval (ITI).
Edit the TargetStimulus to show the command Press space! and to have an
infinite duration. Then, add an input-device by clicking on Add in the Dura-
tion /Input tab, and choose keyboard. Set , as the only Allowable key, {SPACE}.
Mind the capitals, they are important here. Also, set the spacebar as the only
correct key (this is generally not the case!) and accept the standard type of
logging .
Your experiment should run now, so try this. It is good practice to run your
experiment frequently, because this makes it easier for you to diagnose, or de-
bug, problems. Run your experiment with any subject number but 0, or else
nothing is logged. Remember: if you want to abort the experiment quickly,
you can always press control+alt+shift (or perhaps control+shift+backspace).
When starting your experiment, the resolution of your screen may change. In
Chapter III we will discuss how to change these screen settings.
40 THE E-PRIMER
Step 3: Analyse the data
When you have finished testing the experiment, start E-DataAid and open the
data you generated. These can be found in the same folder where your experi-
ment was last saved.
Scroll through your data and note the various columns. For example, notice
how the trial number starts at 1 and goes on to 10, because the first block (the
TrainingList) is finished after 10 trials ; then starts at 1 again but now goes to
20, because the second block (the TestingList) is finished after 20 trials.
Since we want to know what your participants average basic reaction time
was, the TargetStimulus.RT is most important to us. Notice how several val-
ues will be well below (approaching an unlikely 0) and above (in case you were
distracted) the average. Apparently, a bit of filtering needs to happen to get a
clear picture of your RT in comparison to your neighbours.
Click on Tools, select Analyze and click on Filter. In the dropdown box, select
TargetStimulus.RT (in alphabetical order here) and click on Checklist. Now,
click once on the first value that is higher or equal to 100, then scroll down,
and shift+click on the last value that is lower than 1000. Only then, with all the
values you want to include selected, press spacebar and click on OK. In this
way you prevent outlying RT values from distorting your mean RT values.
Consider what would happen if you save this analysis and apply it to an-
other dataset later. In this case, it is quite likely that there are new unique RT
values in your dataset not yet included in your checklist. In other words, you
have to reselect the relevant RTs. In those cases it might be preferable to use
the Range alternative. Click Range and set the first range to Greater than or
equal 100, combined with the second range being Less than 1000. Dont forget
to select the AND operator , since our inclusion criterion is that each single RT
needs to meet both conditions.
So now that we have deleted the outliers from further analysis, close the filter
and drag TargetStimulus.RT from the list of variables to Data. Click on Run
and get ready to be astounded by your reaction time! Michiels was 191 ms.
One of the reasons why many people use E-DataAid in conjunction with E-Prime
is the ease with which you can make crosstabs. Here is how we do it:
41 E-PRIME AT A GLANCE
Close the analysis results and, without changing anything else, drag the
Procedure [Block] variable from the list to either the row or the columns (try
both). Again, click on Run.
This is what it should look like:
So, Michiel was about 43 ms faster after training a bit.
Exercises
Add an introduction screen to the start of your experiment, with infinite dura-
tion, terminating when the participant presses a certain unique key (press C
to continue).
Add a goodbye screen and a thank you screen to your experiment.
Use the mouse instead of the keyboard as InputDevice for the TargetStimulus.
To do this, you basically do the same as you did with the keyboard as an input
device, except that the response keys are defined as 1 (left mouse-button) and
42 THE E-PRIMER
2 (right mouse-button). Therefore, if you enter 12 as allowable both buttons
are allowable responses.
Pimp your experiment: adjust it to your taste or to what you think would be
wise; just experiment with all the options.
Design an experiment to test the following hypothesis: it is easier to respond
to green than to red. The idea is clear: typically, we need to stop doing some-
thing when a red light appears, so a psychologist could hypothesise that be-
cause we internalised this rule and thus suppress all action when a red light
appears. It is time to find out whether this is true.
You can base this experiment on the one you made in the tutorial. First, the trial
needs to be changed: the fixation should now have a gray background; the target
should have no word anymore, but just be a coloured background. The Training-
List should now have white targets. The TestingList should now have green and red
targets. Therefore, the TestingList should get one extra row, so that there are two
different procedures. Instead of having the TestingList call TrialProc, let it refer
to RedProc and GreenProc:
At this point, you might think: would it not be much easier to reuse the
same Procedure but only change one aspect or variable of the trial? In the
next chapter, you will find out that this is indeed the case and you will learn
how to do this using attributes .
43 E-PRIME AT A GLANCE
Also, randomise the selection between these two Procedures (see the List proper-
ties) so that the participant cant know in advance what colour the target will be.
Edit both the RedProc and GreenProc equally so that they are exactly the same
in terms of look, duration and response, except that the background of the target
differs.
Test your experiment: is it easier to respond to green than to red?
Advanced Exercises
Instead of analysing all data separately for each participant or cutting and
pasting data into Excel from various edat (.edat/.edat2) files, one can simply
use E-Merge to merge edat datafiles together into one big file.
Make sure you have more than one edat datafile (run your experiment with
different subject numbers) and put them in a directory. Start E-Merge , go to
the directory containing the files using the folder tree and first filter that di-
rectory so you can only see the edat files and not anything else (press the Filter
button) and use *.edat or *.edat2 (the * wildcard means everything).
Select the .edat or .edat2 files and press the Merge button (use the standard
merge). Now you will see that an .emrg or .emrg2 file has been created con-
taining all the information from the two separate files.
Now use E-DataAid to analyse all your participants/sessions at once.
161
Chapter VII
Interactions between Slide objects and the Mouse
In this chapter, you will learn
About: Common properties and methods of the Slide object
Accessing the mouse in E-Prime
and, finally,
how to do fun stuff with the mouse.
The Slide object
Slide objects are extremely useful because they allow you to combine text, images,
sounds and movies in one and the same object. In this chapter we will learn to
access the Slide, including its SlideStates and sub-objects using InLine codes.
Remember that E-Basic is an object-oriented programming language, and that
you can refer to properties and methods of particular objects using the dot opera-
tor . Likewise, you can also read or change properties, and call methods of Slides
and their sub-objects.
Lets first consider the hierarchical structure of a Slide object. The figure below
shows a Slide object (Slide1) with a particular SlideState (Default) including
two sub-objects: a SlideText (Text1) and a SlideImage (Image1).
When a Slide is created, E-Basic automatically declares a hierarchical object con-
sisting of the following elements:
163 INTERACTIONS BETWEEN SLIDE OBJECTS AND THE MOUSE
Slide1 As Slide
Default As SlideState
Text1 As SlideText
Image1 As SlideImage
For each level in the hierarchy we can access particular properties and methods in
E-Basic. A full Listing of all properties and methods can be found in the E-Basic
help file. In the subsequent sections we will describe some common examples for
each level in the hierarchy.
Slide object : Properties and methods
To read or change the ActiveState we simply refer to the property:
Slide1.ActiveState
Similarly, if we want to call up the Procedure that manually draws the Slide1 ob-
ject on the screen (application to be discussed shortly), we may use the method.
Slide1.Draw
SlideState object : Properties and methods
At the SlideState level, we can control several settings defining its display frame,
colours and border. For example, to change the BackColor in the state Default
of the Slide object Slide1 to red (using a CColour conversion function), we can
use this code:
Slide1.States("Default").BackColour = CColour("Red")
Note that we refer here to the subordinate SlideState Default via the property
States of the Slide object. The code demonstrates how to access the nested object
in E-Basic.
The method HitTest is typically used in conjunction with mouse input. If you pro-
vide some coordinates in pixels, the HitTest method will return the String name
of a sub-object of Slide (e.g. a SlideImage or a SlideText) at the specified coordi-
nates. If no SlideImage or SlideText object exists at the specified coordinates, an
empty String is returned.
Debug.print Slide1.States("Default").HitTest(400, 300)
164 THE E-PRIMER
So, if we run this line of code in an experiment with a screen resolution of 800 x
600 pixels and an object called Image2 is presented in Slide1 at the centre of the
screen, the String Image2 would appear in the debugging window.
Sub-objects within a SlideState : Properties and methods
In order to access SlideText and SlideImage sub-objects in a particular SlideState,
you can refer to them via the objects property of a given SlideState. However,
before you can read or change properties of a sub-object, you need a temporary
variable which references the sub-object.
Dim theSlideText As SlideText
Set theSlideText = CSlideText(Slide1.States("Default").Objects("Text1"))
So, in the first line we declare our temporary variable of the type SlideText. Then,
in the second line we use Set to make a reference to the particular SlideText and
use the CSlideText casting function to interpret the Text1 object as having the
data type SlideText (if you want to learn more about casting functions, check the
E-Basic help file).
Now, we can change, for instance, the BorderWidth of the just referenced Slide-
Text (so in this example SlideText Text1 in the Default state of Slide1) by
adding the following line of code:
theSlideText.BorderWidth = 3
Similarly, you can also cast a SlideImage, by simply adapting the variable declara-
tion and casting part. Here is an example:
Dim theSlideImage As SlideImage
Set theSlideImage = CSlideImage(Slide1.States("Default").Objects("Image1"))
Then, you may change, for instance, the filename associated with the image (so
in this example SlideImage Image1 in the Default state of Slide1), using this
line of code:
theSlideImage.FileName = "newfile.bmp"
As you can imagine, a similar Procedure is available for other sub-objects such
as Sounds and Movies. For more information about all properties and methods
available for Slide sub-objects, please refer to the E-Basic Help file.
165 INTERACTIONS BETWEEN SLIDE OBJECTS AND THE MOUSE
Accessing the mouse in E-Prime
The mouse is an interesting device as soon as you would like to add complicated
hand movements or include questionnaires in E-Prime
. In the Properties of
your Experiment, the mouse is activated by default, but its cursor is usually not
shown. To change this, simply set the Show Cursor property to Yes, as indicated
in the figure below:
However, showing a mouse cursor is often annoying when you run an experiment
that depends on manual responses. So might it not be better to toggle the cursor
on and off, depending on the particular time point in the experiment? Well, that
is a good idea and pretty easy to do.
To show the mouse cursor on the screen, use the ShowCursor method, like this:
Mouse.ShowCursor True
And to hide it, use this code:
Mouse.ShowCursor False
166 THE E-PRIMER
Another useful property you may often need is to read the mouse coordinates in
pixels. Simply use its CursorX and CursorY properties, as is shown in the exam-
ple below:
Debug.Print Mouse.CursorX
Debug.Print Mouse.CursorY
Programming user interactions
There are a number of situations where we may feel the need to combine mouse
input and Slide objects. These basically boil down to two major possibilities:
1. You would like to show feedback immediately after a button or mouse click. Unless
an exit criterion is met, feedback should be continuously presented on the screen.
2. You would like to have instant (not only following a button or mouse click) and
continuous online control over your Slide.
The sections below describe both basic setups and their principles. Use them as
templates; they can easily be adapted to suit your own needs.
Continuous feedback after mouse clicks
Refreshing a Slide object after a mouse click is something you may want to do
when programming questionnaires, visual analogue scales, or other types of
mouse pointing-and-clicking tasks.
Imagine you would like to show some visual feedback immediately after a user
makes a left-button mouse click in a Slide object, and this Procedure should be
repeated again and again until the user clicks with the other (right) mouse but-
ton. As feedback, the SlideText position should move to the position of the mouse
cursor after each mouse click.
To implement this, we need three objects: a Label, a Slide object, and an InLine
object. In addition, add a SlideText sub-object to the default Slide state. See the
examples below.
Make sure to set the Slide Duration to Infinite and Terminate after the user made
a mouse click. Also set ShowCursor to Yes in the experimental properties.
167 INTERACTIONS BETWEEN SLIDE OBJECTS AND THE MOUSE
This is the code we need in the ProcessSlideResp Inline object:
If Slide1.InputMasks.Responses.Count > 0 Then
'Get the mouse response
Dim theMouseResponseData As MouseResponseData
Set theMouseResponseData = _
CMouseResponseData(Slide1.InputMasks.Responses(1))
If theMouseResponseData.RESP = "1" Then
Dim theSlideText As SlideText
Set theSlideText = _
CSlideText(Slide1.States("Default").Objects("Text1"))
theSlideText.X = theMouseResponseData.CursorX
theSlideText.Y = theMouseResponseData.CursorY
Else
'Exit criterion, stop the experiment
End
End If
End If
GoTo ShowSlide
In this case, the Goto command at the bottom of the code creates a loop, which
triggers a continuous refreshing of the content of the Slide object each time the
user makes a mouse click.
168 THE E-PRIMER
The script introduces a MouseResponseData object, which can be used to read
the mouse position and responses. The MouseResponseData refers to the object
InputMasks.Responses(1), which does the actual response logging of the Slide
object. If you would like to learn more about the InputMask object, please study
its complicated details in the E-Basic Help file.
Continous online control
Some situations require you to have online access to a device and instantly refresh
the Slide object. For example, if you would like to program an approach / avoid-
ance task where you can pull towards (enlarge) or push away (shrink) images
with a joystick, you need to sample mouse or joystick data as fast as possible and
instantly refresh the screen according to the new cursor position. Other examples
are mouse tracking tasks and implicit learning tasks that read complicated hand
movements using the mouse or other devices.
The code below shows the basic programming flow you need when you would like
to update a SlideTexts position instantly. In this case, the position is matched to
the position of the mouse cursor instantly (i.e. whenever the mouse is moved, the
display is updated immediately). This Procedure described below runs in a Slide
object for 10 seconds.
To have continuous online control, we use the InLine object again. To show the
display we use the Slide1 object, which is constantly redrawn by our script. See
the example below:
169 INTERACTIONS BETWEEN SLIDE OBJECTS AND THE MOUSE
Make sure you set the Slide Duration to 0! Note that there is still the pos-
sibility to log responses: simply set the Time Limit to the value you prefer (i.e.
a value >0).
Also set ShowCursor to Yes in the experimental properties.
This is the content of the ProcessSlideResp InLine object you need:
Dim theSlideText As SlideText
Do While (Clock.Read - Slide1.OnsetTime) < 10000
Set theSlideText = CSlideText(Slide1.States("Default").Objects("Text1"))
theSlideText.X = Mouse.CursorX
theSlideText.Y = Mouse.CursorY
Slide1.Draw
Display.WaitForVerticalBlank
Sleep 10
Loop
The Do-While Loop structure here repeats drawing Slide1 again and again, un-
til 10,000 ms (10 seconds) since the Slide1.OnsetTime has passed. However,
given that it is useless having faster loops than the screen refresh rate, we de-
cided to add a Display.WaitForVerticalBlank statement and a sleep command to
create a loop that is simply as fast as (but not faster than) the refresh rate of the
monitor.
In case you also want to terminate the loop whenever the user makes a
button press, simply changing the devices End Action to Terminate will not
work. Instead, you have to add an additional criterion to the loop checking
whether StimSlide.InputMasks.IsPending() is True. As soon as IsPending()
gets the value False, you know that a response was made or the Time Limit was
exceeded.
Tutorial X : A simple questionnaire
Lets program a simple Questionnaire in E-Prime
works appropriately.
Tutorial XI: A mouse tracking task
As a young student you are likely to have efficient motor control over your mouse,
but what happens when you become older? Well, it is likely that your motor per-
formance will become impaired. In this tutorial we are going to program a mouse
tracking task that may be useful for calculating indices of motor (dis)ability.
This mouse tracking task is an adapted version of the one-dimensional task
described by Riviere & Thakor (1996). As shown in the figure on the next page,
173 INTERACTIONS BETWEEN SLIDE OBJECTS AND THE MOUSE
a stationary vertical line segment (100 pixels) is displayed on the computer
screen (1024 x 768 pixels). A small square target oscillates along the right side
of the line segment in sinusoidal fashion. The participant tracks the targets
motion with a small round mouse cursor, which moves along the left side of the
line. The experiment should be programmed such that the X component of the
mouse signal is ignored and only the Y component is sampled. In this way, the
mouse cursor is constrained to move vertically and is not sensitive to sideways
mouse movement. The trial should stop after a mouse click, or in case of omis-
sion after 10 seconds.
Note that we basically need to adapt the continuous online control design pro-
posed in this chapter.
Step 1: The basic design
Create an E-Prime
Note: the variable Duration in the example above has a fixed value
throughout the experiment. In such cases you might consider to declare a con-
stant instead, using the Const statement. See the E-Basic help file for more
information about the Const statement.
Exercises
Add extra trials to the List of the questionnaire in Tutorial X. Add an InLine
script to the beginning of the TrialProc to make sure that each question al-
ways starts showing all options deselected.
Disable the possibility of selecting option1 and option2 at the same time, so
that the participant is forced to choose one out of two. Draw a flowchart before
programming.
Now adapt the questionnaire in such a way that the participant has to choose
one out of eight options. Draw a flowchart before programming.
1
0.5
0
-0.5
-1
434
409
384
359
334
0 0.5 1 0 0.5 1
176 THE E-PRIMER
The questionnaire you created can be useful as a manipulation check. Add
the questionnaire to the end of the Ego depletion experiment (Tutorial V,
Chapter III). Ask participants to rate on an 8-points scale how tired, thought-
ful, excited, happy, worn out, sad/depressed, angry, and calm they feel at the
end of the film viewing task. Make sure the response is stored in the edat
file.
Download the file E-primeQuestionnaire.es2 from www.e-primer.com.This pro-
gram shows how you can present one or more sheets of ten questionnaire
items on a screen in E-Prime
support page.
Icon Name Description Chapter
Procedure Used to determine the order of events in
an experiment.
I
List Contains rows of items with specific pro-
perties (attributes) . Lists usually call Pro-
cedures.
I,II,III
TextDisplay Displays one or more lines of text. I
ImageDisplay Displays pictures. II
Slide Presents a combination of text, images,
movies and sound.
II
FeedbackDisplay Provides specific feedback based on the
participants response to objects presen-
ted earlier in the experiment flow.
II
MovieDisplay Displays a movie clip. III
SoundOut Presents a sound file (.wav/ .mp3/.wma). III
SoundIn Records sounds. Not in this
book
Wait Waits for a specified time without chan-
ging the visual output.
III
200 THE E-PRIMER
Icon Name Description Chapter
InLine Used to add E-Basic script at a specific
location of the experiment flow.
IV
Label Indicates a particular location on the
timeline (Procedure ) . The program can
jump backward or forward to a Label , in
order to repeat or skip a part of the Pro-
cedure.
III
PackageCall Contains reusable blocks of E-Basic
script written by users of E-Prime 2 (of-
ten used in Procedures which are used
repeatedly or for instance in connecting
equipment such as an eye-tracker to an
E-Prime