MATLAB for
the Behavioral
Sciences:
How to program your own experiment
2007 course notes
Ione Fine
Suitable for graduate students and advanced undergraduates considering
graduate school in the behavioral sciences
Description: This class will be a tutorial for programming techniques
in Matlab that are particularly relevant to researchers in behavioral
sciences. The class will give a researcher with no or little experience
in programming the tools they need to design and program their own
experiment, do basic analysis, and plot their results. For example, we
will include classes on experimental design, stimulus presentation,
experimental timing, graphical user interfaces, curve fitting,
randomization techniques, basic statistics, and customized data
plotting, debugging and code optimization techniques.
Almost all experiments in the behavioral sciences have a certain
structure.
Some sort of stimulus is displayed, the subject makes some sort of
response, a new stimulus is presented that may or may not depend on the
subjects' response. At the end of the experiment the data needs to be
saved and analyzed. This class will step through these various stages
of a typical program. By the end of the class, the student will not
only have the programming knowledge she needs to develop a working
program, she will have already written several working programs typical
of a wide variety of behavioral science experiments.
In each class, I will explain basic techniques and commands and provide
code examples. Homeworks will practice and build on these skills.
Optional homeworks will include more advanced topics and techniques.
Each class will build on the core material of the class before.
The class is based on a book that Ione Fine and Geoffrey Boynton are
writing, and the notes for the class is the manuscript draft for the
book.
The
EPOST discussion group is HERE
Introduction (3/28/2007)
Chapter 1
(strings & vectors, 3/28/2007)
Chapter 2
(matrices & calculations, 4/6/2007)
Chapter 3
(basic graphics, 4/9/2007)
scaleif.m
Chapter 4
(beginning FaceAdaptation experiment, 4/3/2007)
folder for
male images
folder
for female images
folder for morph images
Chapter 5
(functions, 4/7/2007)
Chapter 6
(Psychtoolbox, , 4/10/2007)
NOTES for Chapter 6.
Getting started with PsychToolbox
Screen.m command
1. Start with just 1 monitor
2. See if
>ScreenTest
works. If it does then the screen command works. If not, then
Psychtoolbox isn't working right on your computer and you should let me
know.
3. Try DarkScreen
4. Try FunkyScreen
If you do it in this order it will be much easier to work out any
problems.
Dealing
with frozen blank screens
If you display stimuli on the main screen, as we often do,
then the Screen window will hide the main menu bar and obscure Matlab’s
command window. That can be a problem if your program stops (perhaps
due to an error) before closing the window. The keyboard will seem to
be dead because its output is directed to the front most window, which
belongs to Screen not Matlab, so Matlab won’t be aware of your typing.
Remain calm.
Typing Ctrl-C will stop your program if hasn't
stopped already. Typing:
command-zero (on the Mac)
Alt-Tab (on
Windows)
Will bring Matlab’s command window forward. That will restore
keyboard input. The screen might still be hard to make out, if you’ve
been playing with the lookup table. Typing:
(hit Return key)
clear Screen
will then cause Matlab to flush Screen.mex. Screen.mex, as part of its
exit
procedure, cleans up everything it did, closing all its windows and
restoring the lookup table of all its displays. And everything will be
hunky dory again.
Chapter 7 (more
FaceAdaptation experiment, 4/10/2007)
Chapter 8
(finishing FaceAdapt experiment, 4/15/2007)
Chapter 9 (keyboard
input, RTs, 4/22/2007)
Chapter 10 (basic
plotting, 4/22/2007)
Chapter 11 (more
plotting, 4/29/2007 ***added Geoff's color illusion and notes on
view***)
logx2raw.m
logy2raw.m
Chapter 12 (analyzing
fake fmri data, 4/26/2007)
Chapter 13 (Data
in, data out. reading and writing to excel and text files, 4/27/2007)
Chapter 14 (CosmoQuiz,
example of using PT windows and key press commands to collect subject
data, 4/29/2007)
Chapter 15 (Optimization,
5/7/2007)
You will also need the following functions:
fit.m
params2var.m
var2params.m
fitFun.m
updateUI.m
fitUI.m
Chapter 16 (sound,
5/17/2007)
Chapter 17 (calibration,
5/22/2007)
I'll bring copies of Chapter 11 to
class