Rapunzel Code Editor
Support forum
Python Tutorials
Supported by

Release notes for 4.0.0

OpenSesame 4.0 Melodramatic Milgram is a major new release with many new features and improvements.

Important: Backwards incompatible changes

  • Logging of variables has changed slightly. Specifically, variables that are defined in the user interface, such as columns in a loop table or explicitly selected variables in a logger, are always logged. Variables that are defined in an inline_script or inline_javascript are only logged if they are numbers (int and float), strings (str and bytes), and None values. This is to avoid log files from becoming unreasonably large due to logging of long lists and other large values.
  • The content of <script> tags in inline_html items is not evaluated. This is no longer necessary, because you can simply refer to experimental variables as you would elsewhere in JavaScript (see below).
  • Conditional expressions are only interpreted as OpenSesame script if they contain variable references using the square-bracket notation or the words 'always' or 'never'. Otherwise they are interpreted as Python expressions as described below.

New OpenSesame Python module (no GUI)

For those of you who prefer coding over using a GUI: You can now use OpenSesame as a Python module.

from libopensesame.python_workspace_api import \
  Experiment, Canvas, Keyboard, Text

# Initialize the experiment window using the legacy backend
exp, win, clock, log = Experiment(canvas_backend='legacy')
# Prepare a stimulus canvas and a keyboard
cnv = Canvas()
cnv += Text('Hello world')
kb = Keyboard()
# Show the canvas, wait for a key press, and then end the experiment

See also:

Improved integration with Python and JavaScript

The integration between OpenSesame and Python (on the desktop)/ JavaScript (in the browser) is now more intuitive. Specifically, OpenSesame-specific syntax has partly been replaced by standard Python/ JavaScript syntax, and there is no longer a distinction between experimental variables and global variables in Python/ JavaScript.

{} instead of []: Support for formatted string literals (f-strings)

The preferred notation for referring to variables in the user interface is now using curly braces ({my_var}), rather than square brackets ([my_var]).

You can even include full Python expressions within curly braces. For example, the following text on a sketchpad will include the text 'Well done!' if accuracy is above 70% and the text 'Try harder!' otherwise.

Your accuray is {acc} %. {'Well done!' if acc > 70 else 'Try harder!'}

When running an experiment with OSWeb in a browser, the Python code inside curly braces is automatically converted to JavaScript. This means that you can use the same Python expressions inside curly braces on the desktop and in a browser.

For more information, see:

Support for Python-style conditional expressions

The preferred syntax for run-if, break-if, show-if, and other conditional expressions is Python, rather than OpenSesame script. This means that the following run-if expression results in an item only being run when the variable correct equals 1, that is, after a correct response. (This is also related to the fact that experimental variables are now globals, see below.)

correct == 1

When running an experiment with OSWeb in a browser, Python conditional expressions are automatically converted to JavaScript. This means that you can use the same Python run-if, break-if, show-if, and other conditional expressions on the desktop and in a browser.

Persistent JavaScript workspace

The JavaScript workspace is now persistent. This means that you can define a function or variable in one inline_javascript and then refer to it in another inline_javascript.

Experimental variables are globals

Experimental variables, such as response_time and variables defined in loop items, are now global variables within Python and JavaScript. This means that you no longer have to use the var (Python) or vars object, but can directly refer experimental variables by their name.


# Access an existing experimental variable by its name
print('response = ', response)
# Define a new experimental variable (which can be used also in the GUI)
new_experimental_variable = 'example'


// Access an existing experimental variable by its name
console.log('response = ' + response)
// Define a new experimental variable (which can be used also in the GUI)
// Note: Variables defined using `let` are *not* globally available!
var new_experimental_variable = 'example'

Improved user interface

There have been usability improvements through the user interface:

  • Improved icons: The open and save icons have been redesigned because they were experienced as unclear by some users
  • Run-if, break-if, show-if, and other conditional expressions are annotated for clarity ('Always run')
  • OSWeb now appears as a backend
  • Items that are not compatible with the experiment settings are disabled
  • Items in an experiment can be disabled. This is mostly useful for development purposes, for example to temporarily disable the instructions.
  • Error messages are now much more informative.
  • A new updater extension automatically checks for updates to selected packages. This provides an easy way to keep OpenSesame up to date without having to re-download and re-install the software.

Interleaved Quest staircase

The quest_staircase_init and quest_staircase_next items now accept a name, which allows you to run multiple Quest procedures in parallel. This is mostly useful if you want to run independent, interleaved Quest procedures for different experimental conditions.

Linked sketchpad in mouse_response supported in OSWeb

The mouse_response now supports linked sketchpad items in OSWeb, making it just as easy to work with regions of interest in browser-based experiments as in lab-based experiments!

For developers: Improved plugin and extension API

The plugin and extension API has been simplified and revised to reflect current best practices in Python development:


OpenSesame builds directly and indirectly on the work of many people. But a special thanks to Robbert van der Mijn for building the Mac OS packages, and Elio Sjak-Shie for suggesting a way to implement a persistent JavaScript workspace for OSWeb.

Supported by