Psychology 448A/538A

Advanced Programming for the Behavioral Sciences

psi
Home Library of Functions Lessons Homework Discussion Board

Lessons


Lesson 1: Hello World!

In this lesson we'll learn how to open a 'screen' using the psychtoolbox, put up some text, pause, and close the window. Once you get this working, you're well off the ground for puting up stimuli with the Psychophysics Toolbox.

Functions/Scripts: Lesson_1, OpenWindow

Homework 1


Lesson 2: Moving Dots

Our goal in this lesson is to generate a function that displays a field of moving dots, allowing for parameters such as the number of dots, aperture size, coherence, color and direction.

Functions/Scripts: Lesson_2,secs2frames, angle2pix, pix2angle


Lesson 3: A 2AFC trial

The goal in this lesson is to generate code to run a two-alternative forced-choice trial on a field of partially coherent moving dots. The subject will decide after a stimulus whether the overall motion of the dots was upward or downward.

Functions/Scripts: Lesson_3,movingDots, drawText, waitTill, drawFixationmatlab


Lesson 4: Measuring psychometric functions

In this lesson we'll use the 2AFC paradigm for motion coherence to measure a subject's 'psychometric function' - performance as a function of stimulus strength. We'll cover two ways of choosing the stimulus strength for each trial - the method of 'constant stimuli' and a '3-down 1-up staircase method'.

Functions/Scripts: Lesson_4, logy2raw, logx2raw


Lesson 5: Fitting the psychometric function

In this lesson we'll calculate the coherence threshold from sample psychometric function data. This involves fitting the trial-by-trial results with a parametric function (the Weibul function) using a 'maximum likelihood' procedure and picking off the coherence level that predicts 80% correct performance.

Functions/Scripts/Data:Lesson_5, Weibull,plotPsycho, fit, fitFunction, fitPsychometricFunction, resultsStaircase

Reference: Wichmann, F.A. and N.J. Hill: The psychometric function: I. Fitting, sampling and goodness-of-fit. Perception and Psychophysics 63 (8), 1293-1313 (2001)


Lesson 6: Introduction to the Bootstrap

When we summarize a data set with a statistic, such as when we calcualte a threshold from psychometric function data, we'd also like to know something about the reliability of that statistic. The brute-force way to estimate this reliability is to run the same experiment multiple times and calculate the mean and standard error of our statistic. But this can be time-consuming and expensive. Fortunately, there is a way of estimating the variability of a statistic from a single data set. This 'bootstrapping' method seems like magic, but as we'll demonstrate here it works remarkably well.

Functions/Scripts: Lesson_6, inverseNormalCDF, bootstrap


Lesson 7: Using the bootstap to estimate variability in thresholds

Now that we've introduced the bootstrapping procedure for a general function, we're ready to apply it to estimating the variability in the threshold parameter from the best-fitting Weibull function.

Function/Scripts: Lesson_7, bootstrapWeibullThreshold, plotPsycho

Reference: Wichmann, F.A. and N.J. Hill: The psychometric function: II. Bootstrap-based confidence intervals and sampling. Perception and Psychophysics 63 (8), 1314-1329 (2001)


Lesson 8: Signal Detection Theory and the 'yes/no' experiment

A fundamental theory that can predict a variety of basic detection and discrimination task is 'Signal Detection Theory', or SDT for short. This lesson defines some of the basic principles of SDT and shows how to calculate it from a single 'yes/no' detection experiment.

Functions/Scripts: Lesson_8


Lesson 9: ROC analysis

You can't discuss Signal Detection Theory without talking about the ROC, or 'Receiver Operating Characteristic' curve. In this lession we'll simulate subject's performance on a simple yes/no task for a range of criterion values to generate an ROC curve. We'll then compare the area under this curve to the results from a simulated 2AFC task.

Functions/Scripts: Lesson_9, plotPsycho

 


Lesson 10: ROC analysis of neuronal responses

The general purpose of ROC analysis is to provide a measure of the difference between two distributions. For example, Britten et al. (1992) originally used an ROC analysis to determine how well a neuron can 'discriminate' between two stimuli. In this lesson we'll apply an ROC analysis to example spike data measure a neuron's 'neurometric function'.

Functions/Scripts/Data: Lesson_10, NeuroData

Reference: Britten, K, Shadlen, MN, Newsome, WT and Movshon, JA (1992). The analysis of visual motion: a comparison of neuronal and psychophysical performance. Journal of Neuroscience 12: 4745-4767


Lesson 11: 1-D Fourier Transforms

The Fourier Transform is method for representing a 1-dimensional vector (like a time-series) in terms of 'frequencies'. It is typically used to find periodic signals buried in noise, and to design filters that only pass through a specific range of frequencies.

Functions/Scripts: Lesson_11, plotFFT, complex2real, real2complex


Lesson 12: Linear filters for 1-D time-series

A 1-D 'filter' is a function that takes in a 1-D vector, like a time-series and returns another vector of the same size. Filtering shows up all over the behavioral sciences, from models of physiology including neuronal responses and hemodynamic responses, to methods for analyzing and viewing time-series data.

Functions/Scripts: Lesson_12, leakyIntegrator, gamma, plotResp


Lesson 13: Event-Related fMRI and 'Deconvolution'

Since the expected fMRI response is the convolution of the impulse response with the neuronal response, it's possible work backwards and estimate the hemodynamic response that best predicts a measured fMRI signal. This is essentially undoing the convolution process, or 'deconvolution'.

Functons/Scripts: Lesson 13, mseq

References:

Giedrius T. Buracas and Geoffrey M. Boynton (2002), "Efficient Design of Event-Related fMRI Experiments Using M-Sequences" , NeuroImage 16, 801-813

Dale, A. (1999) "Optimal Experimental Design for Event-Related fMRI", Human Brain Mapping 8:109–114


Lesson 14: The 2-D FFT

This lesson will cover how to use matlab's 'fft2' function to look at the representation of 2-D images in the frequency domain.

Functions/Scripts: Lesson_14, real2complex2, myifft2, myfft2, showImage, plotFFT2, complex2real2

Images: water.JPG, forest.jpg


Lesson 15: Filtering 2-D images

This lesson is all about how convolving an image with a filter transforms an image, and how this transformation can be viewed in the freqency domain using fft2. We finish the lesson by building a filter to find 'Waldo' in a cluttered scene.

Functions/Scripts/Images:Lesson_15, plotResp2, Waldo.bmp


Lesson 16: Auditory Motion

In this lesson, I'll introduce a simple method that converts a sound wave and a vector of x and y spatial position over time into a souund wave that simulates what an observer would hear while standing at the origin.

Functions/Scripts: Lesson_16, makeAuditoryMotion, animateAuditoryMotion