jsPsych Scripts

Overview

jsPsych is an excellent JavaScript library, created by Josh de Leeuw, for designing behavioral experiments that run in a web browser. jsPsych provides a framework for defining experiments using a set of flexible plugins that create different kinds of tasks a subject could complete during an experiment. By assembling these different plugins together it is possible to create many different types of experiments.

You are welcome to use any of the jsPsych scripts on this page. Most of the scripts reflect my research background and assess cognitive and perceptual processes.


Scripts

Backward Digit Span

Backward digit span is a classic assessment of working memory. Participants are given a string of digits and must recall them in reverse order. This script is quite flexible. Users are easily able to modify the modality (spoken or printed digits), the number of trials, the starting digit span etc. The script is also adaptive, using a 1:2 staircase procedure. This means that the span increases by one whenever a participant is correct, and the span decreases by one whenever a participant is incorrect two trials in a row. Typical administration takes 8-10 minutes.

Forward Digit Span

Forward digit span (often just called digit span) is a common assessment of short-term memory. Participants are given a string of digits and must recall them in the same order in which they were presented. This script is quite flexible. Users are easily able to modify the modality (spoken or printed digits), the number of trials, the starting digit span etc. The script is also adaptive, using a 1:2 staircase procedure. This means that the span increases by one whenever a participant is correct, and the span decreases by one whenever a participant is incorrect two trials in a row. Typical administration takes 8-10 minutes.

Auditory N-Back

In the Auditory N-Back, participants are presented a sequence of auditory stimuli one-by-one. For each stimulus, they need to decide if the current stimulus is the same as the one presented N trials ago. The N can be 1 trials, 2 trials, 3 trials, etc. The higher the number, the more difficult the task. The factors that seem to influence the performance are not only the N, but also the speed of presentation and the size of the set of stimuli. This script is highly customizable; you can change the levels of N, the types of sounds used, the number of trials, the relative ratio of target and non targets etc. Typical administration takes 10-15 minutes.

Reading Span

In this Automated Reading Span Task, participants must perform two interleaved tasks. The first is reading a sentence and determining whether or not it makes sense (e.g., "He takes his coffee with sugar and [cream / concrete]."). The second is a letter memorization task. On each trial, participants complete anywhere between three and seven iterations of this sentence judgment/letter memorization script. At the end of each trial, participants must report the letters in the exact order in which they appeared. Typical administration takes 15-20 minutes.

Matrix Reasoning

This is a matrix reasoning task, similar to the popular Raven's Progressive Matrices. This version, however, is not proprietary. The stimuli are taken from Matzen et al. (2010) (Behavioral Research Methods). On each trial, participants see a matrix pattern with the bottom right portion missing. Participants then must decide which of eight provided options best completes the pattern. There are 42 items. You can change a single variable (shortForm in matrices.js) to make a "short form" version (21 items) if desired. There are several different subtypes of stimuli (e.g., logical relation, one-dimension, two-dimension, three-dimension). Typical administration takes 40-60 minutes for the full version and 20-30 minutes for the short form version.

Pitch Adjustment

The pitch adjustment task is a sound reproduction task that has been used as an assessment of auditory working memory precision (e.g., Van Hedger et al., 2015 Cognition). On each trial, participants hear a brief target tone, which is immediately masked by noise. Participant are then given a starting tone - higher or lower than the initial target tone. Participants must adjust this starting tone, using arrows provided on the screen, to try and recreate the initial targert tone to the best of their ability. Full administration takes 20-30 minutes. The quick assessment (simply swtich quickAssessment in pitchadjust.js to 1) takes 10-20 minutes.

Multiple Object Tracking

This multiple object tracking (MOT) study assesses visual attention. On each trial, participants see an array of eight dots. Depending on the trial, two or three of these dots briefly flash, and then all eight dots start moving. Participants must track the dots that flashed to the best of their ability and identify them at the end of the trial. The task also includes an interactive instructions / practice, and takes 15-20 minutes.

Simon Memory Game

This is a jsPsych version of the popular "Simon" memory game. Each game begins with a single button that lights up, accompanied by a sound. If participants correctly repeat this button, the next trial adds an additional button/tone. Items are continually appended to the end of the sequence until a participant makes a mistake. At this point, the game is over and a new game begins. The script is easily customizable (e.g., changing the number of games, swapping the sounds used in the sequences). At the end of the script, participants are given feedback about their performance. Note: I am extremely indebted to freeCodeCamp for providing the foundations of this project - in particular, the CSS for creating the Simon board.

cos
google-scholar
RG

© Stephen Van Hedger. Website template adapted from from W3Schools.com. Updated June 2020.