Guide to OpenSesame

From Phonlab
Jump to navigationJump to search

OpenSesame is an open-source software package for building and running psychology experiments. It's written in Python and is available for Windows, OS X, and Linux systems.

Using a button box with OpenSesame

If you just need to refresh your memory, these are the three steps needed when integrating a button box into an OpenSesame experiment:

  1. Provide a stimulus that does not wait indefinitely for subject keyboard input.
  2. Follow the stimulus with an srbox item.
  3. Introduce a delay to allow sufficient time for the subject to release the button before continuing to the next item.

Continue reading for more detail on these steps, as provided in the SRBoxexample sample script (File:SRBoxexample.opensesame.tar.gz). For the official documentation on the use of button boxes see the SRBox plugin.

In this example the basic pattern of presenting a stimulus and waiting for a response proceeds in three steps. Take a look at the experiment overview:

Error creating thumbnail: Unable to save thumbnail to destination

First, text is displayed to the subject by the 'intro' text display item. By default items of this type wait for a keypress, but we change the default 'keypress' value of the 'Duration' property to '0' to cause the script to immediately execute the following item.

Error creating thumbnail: Unable to save thumbnail to destination

The next item is the 'intro_response' srbox item, which is the interface to the button box. The script will wait here until one of the buttons identified by the 'Allowed responses' property is pressed. In this case only button 3 (the middle button) is allowed. The semicolon-separated list '1;3;5' in the 'Turn on lights' property indicates that button lights 1, 3, and 5 will illuminate. The 'Allowed responses' property can also contain a semicolon-separated list.

The 'autodetect' value of the 'Device name' property identifies that OpenSesame should attempt to find the button box automatically.

The 'infinite' value of the 'Timeout' property means that the script will wait on this item until one of the allowed responses is received. During our script the intro text display therefore remains on the screen until an allowed response is received.

Error creating thumbnail: Unable to save thumbnail to destination

Finally, the 'delay500' advanced delay item is added to prevent the script from continuing to the next item before the button is released. The SRBox plugin does not provide event handling for button-down/button-up events. What this means is that the button box continuously sends button press data as long as the button is held down. If the next stimulus in a loop is presented while a button is still being held down in response to the previous stimulus, then the next stimulus will record an incorrect response. The delay500 item causes the script to wait 500ms before executing the next item, as shown by the value of the 'Duration' property, and we have to hope the subject will not hold down the button for a longer time. A longer delay may be necessary for subjects with heavy fingers.

Error creating thumbnail: Unable to save thumbnail to destination

These steps are repeated in the 'mainloop' sequence of the sample script, and a 'logger' item is also introduced to log subject responses. You will also see that the properties of the 'stimulus' and 'srbox_input' items are provided by variables defined in the 'mainloop' item rather than being hardcoded, as they are in the 'intro' and 'intro_response' items shown above.