This repository provides a Verbal N-back task, a continuous performance task commonly used to assess working memory capacity. The task is implemented using the jsPsych library.
- Original Concept: Kirchner, W. K. (1954)
- jsPsych Framework: de Leeuw, J. R. (2015)
To launch the task, simply open the `index.html` file located in either the `offline` or `online` folder.
| Folder | Subject ID & Session | Use Case |
|---|---|---|
offline |
Subject and session numbers can be customized upon startup. | Local testing, lab settings. |
online |
A 15-character long random subject ID is automatically generated. | Online data collection. |
The task is compatible with most modern browsers. Chrome is recommended.
Incompatible Browsers: Safari and Internet Explorer.
In this task, single letters are presented consecutively on the screen. Participants are required to press the "J" key for target elements and the "F" key for non-target elements. The definition of a target stimulus varies depending on the N-back level.
- Written instructions are displayed at the start.
- A 10-trial practice block is performed. During practice, immediate feedback ("Correct", "Wrong", "You did not respond") is provided.
- The main task consists of two 50-trial blocks (100 trials total).
- A self-paced rest period is inserted between the two main blocks.
- Upon completion, participants receive debriefing feedback on their overall success rate and reaction time.
The task level is controlled by the `level` variable, configurable in `parameters.js`. Available levels are 0-back, 1-back, 2-back, and 3-back.
-
0-back: The target element is the fixed letter "X" (
$n=\text{X}$ ). -
1-back: The target is any letter that is the same as the letter presented immediately prior (
$n=n-1$ ). -
2-back: The target is any letter that is the same as the letter presented 2 trials earlier (
$n=n-2$ ). -
3-back: The target is any letter that is the same as the letter presented 3 trials earlier (
$n=n-3$ ).
Ten phonologically distinct letters are used as stimuli: B, K, Q, T, H, M, N, P, X, R. The stimuli are presented in a fixed pseudo-random order.
| Parameter | Value | Details |
|---|---|---|
| Stimulus Duration | 500 ms | How long the letter is on screen. |
| Interstimulus Interval (ISI) | 1500 ms | Time from stimulus offset to the next onset. |
| Total Trials | 100 trials | 2 blocks of 50 trials per level. |
| Target Ratio | 20% | Maintained across all levels (20 target trials vs. 80 non-target trials). |
For the 0-back version, the fixed target "X" appears 20 times. For the 1-back, 2-back, and 3-back versions, each of the 10 letters is presented 10 times, serving as a target twice (once per block).
Example for stimulus presentation in the 2-back task.After the task concludes, a .csv output file containing trial-by-trial data and descriptive statistics is saved to the local machine.
| Variable | Description |
|---|---|
subject |
15-char random ID (online) or custom number (offline). |
session |
Custom session number (offline version only). |
rt |
Reaction time (in ms). |
test\_part |
The part of the task (e.g., fixation, test, feedback, debrief). |
correct\_response |
The expected key press ("j" or "f"). |
block |
The block number (0: practice, 1: first block, 2: second block). |
trial\_number |
The trial number within the block. |
target |
Whether the stimulus was a target (Boolean). |
letter |
The letter presented. |
hit |
Target correctly identified as target (1 = Yes, 0 = No). |
miss |
Target incorrectly identified as non-target (1 = Yes, 0 = No). |
false\_alarm |
Non-target incorrectly identified as target (1 = Yes, 0 = No). |
correct\_rejection |
Non-target correctly identified as non-target (1 = Yes, 0 = No). |
| Other jsPsych: | success, trial\_type, trial\_index, time\_elapsed, internal\_code\_id, browser\_events, view\_history, stimulus, key\_press. |
Columns prefixed with `STAT\_` provide descriptive statistics, excluding practice trials.
| Statistic Variable | Description |
|---|---|
STAT_nr_hit |
Number of hits. |
STAT_nr_miss |
Number of misses. |
STAT_nr_false_alarm |
Number of false alarms. |
STAT_nr_correct_rejection |
Number of correct rejections. |
STAT_nr_response |
Number of trials with a response. |
STAT_nr_no_response |
Number of trials with no response. |
STAT_accuracy |
Overall accuracy (Correct responses / Total responses, in percentage). |
STAT_dprime |
D-prime ( |
STAT_rt_mean / STAT_rt_median |
Overall mean/median Reaction Time (RT) in ms. |
STAT_hit_mean / STAT_hit_median |
Mean/median RT for hit trials in ms. |
STAT_false_alarm_mean / STAT_false_alarm_median |
Mean/median RT for false alarm trials in ms. |
STAT_correct_rejection_mean / STAT_correct_rejection_median |
Mean/median RT for correct rejection trials in ms. |
STAT_miss_mean / STAT_miss_median |
Mean/median RT for miss trials in ms. |
The following key experimental parameters can be adjusted by modifying the `parameters.js` file:
- `level` Sets the N-back difficulty (0, 1, 2, or 3).
- `trial_duration`: Presentation time of the fixation cross.
- `stimulus_duration`: Presentation time of the letters.
- `feedback_duration`: Presentation time of feedback during the practice block.
- `language`: Sets the program language (available: `english (en)`, `hungarian (hu)`).
If you utilize this script in your research, please include the following citation in your manuscript:
Vékony, T. (2021). Verbal N-back task created with jsPsych (Version 1.0.0) [Computer software]. https://doi.org/10.5281/zenodo.7100178
