Implicit Association Test (IAT) experiment for oTree
This project is currently not maintained.
Trial block introduction:
Features and limitations
- stimuli and trial blocks easily adjustable (see configuration)
- precise measurement of responses in milliseconds
- progress bar showing advancement of trials for each participant
- each measurement is stored individually in the database
- requires keyboard for responses but may be extended to work on mobile devices as well
- results are transferred to server at the end of each round (each round or block consists of several trials), not after each trial
- optional: live view of measurements during experiment in oTree's data view
- tested with Python 3.7 and Python 3.8
- tested with otree 3.3.0 to otree 3.3.11
oTree IAT may work with higher versions than specified here, but this is untested.
You can install the exact requirements using pip:
pip install -r requirements.txt
If you want to see live view of measurements during the experiment in the "data" view of oTree's admin panel, you additional need to install otreeutils version 0.10.0 or newer:
pip install otreeutils[admin].
If you want to use oTree IAT with an older version of oTree, you may try a previous release as listed under Releases on the right side. To know which version of oTree IAT works with which version of oTree, see the Changes section below.
Stimuli and trial blocks
For your own experiment, you probably want to exchange the stimuli and adjust the trials. You can do so in
iat/models.py by editing
Further configuration via
Constants class in
iat/models.py contains further configuration settings such as the number of blocks (
num_rounds) and the keys on the keyboard that are used for input.
Code structure and page sequence
Trial class is defined in
iat/models.py that stores information for each trial per player such as displayed stimulus and participant's response. The trials are set up in
creating_session() in class
Subsession where the stimuli are loaded depending on the block definition and their order is randomized.
Pages and templates
The page sequence consists of three classes in
The test is then implemented in
Trial objects are loaded for the participant for the given round and passed to the template where they are displayed. During the test, the response times and keys are recorded and submitted when the next block is loaded or all blocks are finished. The submitted trial responses are handled and stored to the database in the method
You can export the data from the "Data" page (
https://<yourserver>/export) via the iat (custom) links. If you have otreeutils installed, you can also use the
data_exporter.py script by executing
python data_exporter.py my_data.json in the terminal, which will store all collected data in JSON format to
For later processing of the JSON data, you may use the
jsonlite package for R or the built-in
json module in Python.
Automated tests are implemented in
iat/tests.py and can be run via
otree test iat.
Testing multiple combinations of Python and oTree versions is done using tox. You can install the package tox via pip and then run
tox on the command line.
2021-03-03: v1.1.1 (oTree 3.3.x)
- dependency to otreeutils is now optional (brings back session data live view via otreeutils 0.10.0)
2021-02-18: v1.1.0 (oTree 3.3.x)
- added compatibility with oTree 3.3.x (PR #3 – thanks to Christoph Semken)
- added tox integration for testing multiple Python/oTree versions
2019-11-05: v1.0.0 (oTree 2.1.x)
- initial release
Apache License 2.0. See LICENSE file.