Several Python programming books feature tools designed for experimental psychologists. What sets this book apart is its focus on eye-tracking.
Eye-tracking is a widely used research technique in psychology and neuroscience labs. Research grade eye-trackers are typically faster, more accurate, and of course, more expensive than the ones seen in consumer goods or usability labs. Not surprisingly, a successful eye-tracking study usually requires sophisticated computer programming. Easy syntax and flexibility make Python a perfect choice for this task, especially for psychology researchers with little or no computer programming experience.
This book offers detailed coverage of the Pylink library, a Python interface for the gold standard EyeLink ® eye-trackers, with many step-by-step example scripts. This book is a useful reference for eye-tracking researchers, but you can also use it as a textbook for graduate-level programming courses.
Autorentext
Dr. Zhiguo Wang is a research professor at Zhejiang University. He received his Ph.D. from the Graduate University of Chinese Academy of Sciences and had his post-doctoral training at Vrije Universiteit (the Netherlands) and Macquarie University (Australia). He was a senior scientist at SR Research Ltd. (Canada) before joining the Center for Psychological Sciences at Zhejiang University.
Dr. Zhiguo Wang was a recipient of the prestigious Australian Research Council Discovery Early Career Researcher Award. His current research work focuses on issues in engineering psychology, but he is also interested in research topics in vision, eye movements, visual working memory, spatial attention, and developmental disorders
Inhalt
Preface 5
Chapter 1 A gentle introduction to Python 7
Install Python 7
Python modules 8
Python shell 9
Script editors 11
Data types 12
Numbers 12Strings 12
List 14
Tuple 15
Sets 16
Dictionary 16
Booleans 17
Operators 17
Data type conversion 18
Control flow 19
if statement 19
for statement 20
while statement 21
More on looping 22
List comprehension 22
Functions 23
Output 25
Output formatting 25
Files 26
Modules 28
Choose a library to create your "video games" 29
Where to go from here 29
Chapter 2 Building experiments with PsychoPy 31
Install PsychoPy 31
PsychoPy Coder 321
Open a window 34
Screen units 34
Monitor 36
Window types 37
Gamma 37
Vertical blanking 38
Call on flip 39
Screen capture 39
Visual stimuli 40
Shapes 40
GratingStim 42
TextStim 43
Font and font files 44
Right-to-left text 44
Wrap width 45
Non-ASCII characters 45
Aperture 45
Mouse and keyboard 47
Mouse 47
Keyboard 48
Register keyboard events with the event module 49
Register keyboard events with the ioHub module 49
Register keyboard events with PsychHID 50Trial control 51
A real example: Simon effect 54
Chapter 3 Building experiments with Pygame 59
Install Pygame 60
Display 61
Events 63
Draw 65
Text 66
Image and sound 68
A real example: Posner cueing task 69
Chapter 4 Getting to know Pylink 76
A brief introduction to eye-tracking 76
Install Pylink 78
An overview of an eye-tracking experiment 78
Connect to the tracker 80Open a camera setup / calibration screen 81
2
Configure the tracker 81
Open an EDF file 82
Calibration 82
Data recording 82
Retrieve the EDF data file 83
Disconnect from the tracker 83
A real example: Free viewing 83
Calibration graphics 86
Idle mode 86
EyeLink Host commands 86
Preamble text in EDF 87
Record status message 87
Drift-check/drift-correction 87
Logging messages 88
Chapter 5 Preparing scripts for analysis and visualization in Data Viewer 90
Trial segmentation 91
Trial variables 93
Interest Areas 95
Background graphics 97
Size of the screen 97
Image 97
Video 98
Simple drawing 99
Draw list file 101
Target position 102
Examples in PsychoPy 102
The Stroop task 102
Custom graphics for calibration 106
The DISPLAY_COORDS message 107
The TRIALID and TRIAL_RESULT messages 107
Record status message 107
Background graphics: the IMGLOAD message 107
Trial variables messages 107
Messages marking critical trial events 108
Video playback 108
Pursuit task 113
Chapter 6 Retrieving gaze data over the link 119
Samples and events 119
Retrieving sample data 121
3
Commands for sample retrieval 121
Example in PsychoPy: Gaze-contingent window 124
Retrieving eye events 127Commands for event retrieval 127
Example in PsychoPy: Fixation trigger 133
Recording playback 136
Chapter 7 Advanced Pylink Functions 141
Drawing to the Host PC 141
Option 1: Using the draw commands 141
Option 2: Sending images to the Host 142Option 3: The bitmapBackdrop command 143
Send TTL via the Host PC 145
Broadcasting 148
Calibration and custom CoreGraphics 151
Chapter 8 Data analysis and visualization in Python 163
EyeLink EDF data file 163
Samples 163Events 164
Other useful information in the EDF data file 165
EDF2ASC Converter 166
Extract data from the ASC files 169
Parse the ASC file with the string function split() 169
Parse ASC files with regular expressions 174
Data visualization 176Gaze trace plots 177
Heat maps 180
Scan path 183
Interest area-based visualization 183
Chapter 9 Miscellaneous 185
Predefined constants in Pylink 185
Frequently used EyeLink Host commands 185
References 187