Template: Manipulating Variables with Python Functions without Custom Class
Manipulating Variables with Python Functions without Custom Class

Required Experiment Builder Version: 2.1.140 or higher
EyeLink Required: Yes
Type: Complete Example
Difficulty Level: Easy / Intermediate

This example demonstrates:
  • How to use Python functions append(), remove(), and random.shuffle() within Update Attribute nodes to alter the contents of list items
  • How to use mouse-contingent Image Resource to serve as a mouse cursor
  • How to reference Interest Areas to determine participant item selection on mouse click response
  • How to present correct / incorrect feedback based on participant accuracy
**Additional detailed information about the project is given in the notes section for most nodes. To see notes for a given node, either mouse over that node or click on it to display the notes window. If the notes window is not visible, go to the "View" drop down menu in Experiment Builder, select "Properties", and check "Note".


In this example, the participant sees a centrally presented square of a given colour for 50 ms, immediately followed by a screen displaying four coloured squares. The participant is to move a mouse cursor object onto the square of the same colour as initially seen, then click the mouse button, as quickly as possible. A feedback screen stating whether the response was correct or incorrect is displayed after response.

The example pulls a list of stimuli from the Data Source, as well as what the target for that trial will be. In an update attribute node, the target's filename is removed from this list, and added to another list, using the remove() and append() functions, respectively. Another list, containing the four possible presentation locations for the stimuli, is shuffled via random.shuffle() in order to randomize the target and distractor image locations. Each image resource has an interest area with its location fixed to the image resource's location, so when the image position changes through this randomization, the interest area moves with it (this allows us to always use the same interest area to tell if the target image was selected).

Calling the remove(), append(), and random.shuffle() Python functions requires the use of one dummy variable. This variable is never actually modified, but rather used as a sort of scratch paper to enable calling the functions to act on the variables we do wish to modify. Please see the Notes section of the UPDATE_ATTRIBUTE node in the TRIAL sequence for more information.

At the start of the experiment, a screen appears asking whether or not to show debug information. Responding via keypress, if (y)es is selected, an extra screen will be displayed at the start of each trial, displaying specific variable contents. This can be used to note whether or not the intended variable manipulations are executing properly. This screen also shows one way to strip characters from a string variable for presentation (see the Notes section of the DEBUG_SCREEN in the RECORDING sequence for more information on this).

Note that this example is purposefully not set up in the most straightforward way to handle the task itself, as its primary function is to highlight how to use the aforementioned Python function calls without requiring Custom Class objects.

See also: Instructions:
  1. Download the Remove_Append_Example.ebz example from this message.
  2. Launch the Experiment Builder application.
  3. Unpack the Remove_Append_Example.ebz file to a location on your Experiment Builder PC with "File menu -> Unpack".
  4. Open the project in Experiment Builder.
  5. Deploy the project to a new folder.
  6. Run the Remove_Append_Example.exe from the deployed directory.

.ebz   Remove_Append_Example.ebz (Size: 60.24 KB / Downloads: 31)