Pulled this out and will merge with PTB version.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>