Skip to content

vekteo/Nback_jsPsych

Repository files navigation

Verbal N-back task created with jsPsych

Created by the MEMO Team of Lyon Neuroscience Research Center (CRNL) (PI: Dezso Nemeth)

A verbal n-back task (Kirchner, W. K., 1954) created with the jsPsych library (de Leeuw, J. R., 2015).

Citation

If you use the script, please include this 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

DOI

Structure of the task

In the task, letters are presented on the screen consecutively. The users' task is to press the "J" key on the keyboard for the target elements, and the "F" for the non-target elements. The target stimulus differs between the different level of the task. The task begins with written instructions. Before the two blocks, a 10-trial practice is implemented. During the practice, the users receive feedback about their answer ("Correct", "Wrong", "You did not respond"). After the practice, the two 50-trial long blocks begin. Between blocks, a self-paced rest period is inserted. After the end of the second block, the users receive feedback about there overall success rate and reaction time.

The levels of the task

Depending on the value of the level variable (can be modified in parameters.js), 0-back, 1-back, 2-back and 3-back will be performed.
  • 0-back: The target element is the letter "X".
  • 1-back: The target is any letters which were preceeded by the same letter (n is target if n=n-1, where n is the current stimulus on the screen).
  • 2-back: The target is any letters which were preceeded by the same letter 2 trials earlier (n is target if n=n-2, where n is the current stimulus on the screen).
  • 3-back: The target is any letters which were preceeded by the same letter 3 trials earlier (n is target if n=n-3, where n is the current stimulus on the screen).

Stimulus presentation parameters

Ten, phonologically distint letters are used as stimuli (B, K, Q, T, H, M, N, P, X, R). The letters are presented in a fixed pseudo-random order. Each letter is presented for 500 ms with an interstimulus interval of 1500 ms. Stimuli are presented in two 50-trial blocks (100 trials altogether at each level). In the 0-back version, the target X is presented 20 times. Therefore, the target-ratio is set to 20% at each level (20 target trials vs. 80 non-target trials).In the 1-back, 2-back, and 3-back versions, each letter is presented 10 times, and all of them serves as target 2 times (once in each block). After then end of the task, an output file is saved to the local machine in .csv format.

Example for stimulus presentation in the 2-back task.

Output file

  • success: whether fullscreen mode was successfully started/ended (true or false)
  • trial_type: jsPsych trialtype of the given trial (fullscreen, instructions or html-keyboard-response)
  • trial_index: the number of the given trial (all events considered, even instructions, feedbacks!)
  • time_elapsed: the time elapsed from the start of the program in ms
  • internal_code_id: internal node id of the trial
  • subject: A 15-character long random subject ID for the online version, and customized subject number for the offline version
  • session: customized session number (for offline version only)
  • browser_events: browser events during the task (fullscreenenter, fullscreenexit, blur or focus)
  • view_history: viewing history during the instruction trials
  • rt: the reaction times in ms
  • stimulus: stimulus on the screen in HTML
  • key_press: the JS code of the key pressed
  • test_part: the test part (fixation, test, feedback, debrief)
  • correct_response: the key that should have been pressed ("j" or "f")
  • block: the number of the block (0: practice, 1: first block, 2: second block)
  • trial_number: the number of the trial within the block (1-10 in practice, 1-50 in the two blocks)
  • target: whether the stimulus was a hit target (depends on the level of the task)
  • letter: the letter presented
  • correct_rejection: 1 if stimulus was a non-target and it was correctly recognized as a non-target, 0 otherwise
  • miss: 1 if stimulus was a target and it was incorretly recognized as a non-target, 0 otherwise
  • hit: 1 if stimulus was a target and it was correctly recognized as a target, 0 otherwise
  • false_alarm: 1 if stimulus was a non-target and it was incorrectly recognized as a target, 0 otherwise

In the columns start with STAT, basic descriptive statistics are calculated. All of the reported statistics exclude the practice trials.

  • STAT_nr_hit: the number of hits
  • STAT_nr_miss: the number of misses
  • STAT_nr_false_alarm: the number of false alarms
  • STAT_nr_correct_rejection the number of correct rejections
  • STAT_nr_response: the number of trials when the user gave and answer
  • STAT_nr_no_response: the number of trials when the user did not give an answer
  • STAT_accuracy: the overall accuracy in the task in percentage (number of correct trials/number of trials with responses)
  • STAT_rt_mean: the overall mean reaction time in the task in ms
  • STAT_rt_median: the overall median reaction time in the task in ms
  • STAT_hit_mean: the mean reaction time for hit trials in ms
  • STAT_hit_median: the median reaction time for hit trials in ms
  • STAT_false_alarm_mean: the mean reaction time for false alarm trials trials in ms
  • STAT_false_alarm_median: the median reaction time for false alarm trials in ms
  • STAT_correct_rejection_mean: the mean reaction time for correct rejection trials trials in ms
  • STAT_correct_rejection_median: the median reaction time for correct rejection trials in ms
  • STAT_miss_mean: the mean reaction time for miss trials trials in ms
  • STAT_miss_median: the median reaction time for miss trials in ms
  • STAT_dprime: d-prime calculated as the different between the normalized hit rate and false alarm rate

Setting options

You can set the following parameters by modifying the parameters.js file:

  • level of the n-back: the level of the n-back task as described above (0, 1, 2, or 3 for the four levels)
  • trial duration: the presentation time of the fixation cross
  • stimulus duration: the presentation time of the letters
  • feedback duration: the presentation time of feedback during practice
  • language: the language of the program; available languages: english (en), hungarian (hu)

How to start the task

Open the index.html file in either the offline or online folder. When the offline version is started, you can customize the subject and session numbers (any number is accepted). If you start the offline version, a random subject ID will be allocated.

Browser requirements

Any browser except Safari and Internet Explorer. Recommended: Chrome