Scannerize your E-Prime code: Part 2 - Button Responses

Part 2 Created Sept 27, 2005 by Ryan Lett

Before you begin…

Before you start, you will want to download the example program I have created. Most of the examples will refer to it specifically.

[Get The E-Basic Program Here]

Setting up scanner button responses for fixed interval stimulus presentation

1. Setting up displays

Displays in E-Prime are any object that provide visual output. They are Text Display, Feedback Display, Image Display, and Slide. When using button responses from the scanner, the first thing you need to understand is how these displays work. Firstly and most importantly, they will stay on the screen until replaced by something else regardless of how long the duration is. For example, if you show a stimulus for duration = 100ms, and then the program waits for 5 seconds… that stimulus will be shown for 5.1 seconds instead of 100ms.

So if you want your stimulus to be shown for 2 seconds, and have it terminate when a button is pressed, you need to set the duration to be 0. This way, the display will immediately return to the procedure and start waiting for a button press. If you don’t, the program won’t look for a button response until after the duration is complete.

So…Every display where you expect a button response must have a duration of 0.

2. Setting up in-line code for button response collection

Open the example code and double-click the “SampleProc” procedure (It is contained within the “List1″ list). Note that the first 3 objects are “TimerInit” “Stimulus” and “ButtonsAndTime”.

Double-click “TimerInit”. This in-line script sets up 3 variables and sets the start time to be the current time (startime=Tic). This bit of code stores the beginning of the start time of your stimulus. Close the “TimerInit” object and open “ButtonsAndTime”. There is more code in here, but to keep things simple, there are only 4 lines that you need to be aware of for this situation:

  • (1) button = GetResponse(2000)
  • (2) diff=Toc
  • (3) c.SetAttrib "Stim.REALRT" , diff
  • (4) c.SetAttrib "Stim.BUTTON" , button

Line 1 waits for a button response for 2000 ms

Line 2 sets diff to the time since the starttime=Tic command

Line 3 logs that time

Line 4 logs which button was pressed

This is a complete button reponse code section. Also note that the duration of “Stimulus” is set to 0.

3. Setting up in-line code for blank display

As I mentioned earlier, a display will not go away until something else is shown. So to have a blank screen between stimuli, we need a blank textdisplay object. The trick is that we need the stimuli to be presented at a fixed interval.

If you open “SetupBlank” from the “SampleProc” procedure you will only see 2 lines.

diff=Toc BlankDisplay.duration = 4000 - diff

The first line sets diff to be the length of time since the stimulus started, and the second sets the duration of the Blank display to be the desired stimulus time minus the time that has passed so far. This way, the blank will be just long enough to allow for exact timing of your stimuli.

That is all for setting up button responses. Pretty easy isn’t it?

QED