Monday, November 30, 2026
Science
No Result
View All Result
  • Login
  • HOME
  • SCIENCE NEWS
  • CONTACT US
  • HOME
  • SCIENCE NEWS
  • CONTACT US
No Result
View All Result
Scienmag
No Result
View All Result
Home Science News Psychology & Psychiatry

Tutorial Shows How Browser-Based jsPsych Software Runs Offline fMRI Experiments

November 30, 2026
in Psychology & Psychiatry
Colin Clarke
By Colin Clarke Scienmag Editorial Profile - Neuroimaging
Reading Time: 6 mins read
0
Tutorial Shows How Browser-Based jsPsych Software Runs Offline fMRI Experiments

Tutorial Shows How Browser-Based jsPsych Software Runs Offline fMRI Experiments

65
SHARES
587
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

A methodological tutorial published in Behavior Research Methods demonstrates how the open-source behavioral experiment library jsPsych, initially designed for online psychological studies, can be adapted to run functional magnetic resonance imaging experiments in local laboratory environments. Investigators Xiong Hu, Yen-Wen Chen, Josue Garcia-Arch, Gabriela Rosenblau, and Christoph W. Korn show that the browser-based software can satisfy the core technical requirements of scanner-based research without requiring internet connectivity or content delivery networks. The framework operates offline directly from local files across standard desktop browsers such as Chrome, Firefox, Safari, and Edge. By leveraging widespread web standards, including HTML5, JavaScript, and CSS3, the system allows experimental paradigms to run on scanner-site computers without requiring specialized runtime environments, extensive package installations, or complex version management protocols.

Behavioral tasks deployed in neuroimaging have historically relied on a restricted selection of platforms, including commercial packages such as E-Prime and Presentation, as well as programming environments such as Psychtoolbox within MATLAB and PsychoPy within Python. Commercial software tools involve substantial financial investments and recurring licensing fees that limit accessibility and complicate the sharing of experimental protocols across collaborating institutions. While open-source frameworks such as PsychoPy provide an accessible alternative, running Python-based experiments typically requires establishing and maintaining matching software environments and package versions across both development and data-collection computers. Because scanner-site computers are frequently shared among diverse research groups and governed by strict institutional administrative permissions, installing dependencies and resolving package conflicts can present persistent logistical hurdles. The authors highlight that jsPsych provides a zero-install or easy-install execution model that sidesteps these runtime conflicts through self-contained directory structures.

The physical separation between task development and data collection represents a central workflow challenge in magnetic resonance imaging facilities. Investigators routinely spend weeks building and testing paradigms on personal workstations before deploying the finished code to data-collection computers located in scanner control rooms. When tasks rely on complex language interpreters and specific library versions, differences between operating systems or inadvertent updates to shared packages can cause code execution failures during scheduled scanning sessions. With jsPsych, the entire experimental setup—including the core library, plugins, visual stimuli, custom scripts, and styling sheets—can be compressed into a single portable directory of approximately 4.9 megabytes. Researchers can transfer this self-contained directory to the data-collection computer in a simple copy-and-run manner, opening the primary HTML document directly in any modern browser without configuring specialized local interpreters.

To function reliably within a neuroimaging environment, behavioral software must satisfy three core technical demands: synchronizing task timing with scanner image acquisition, recording participant responses through scanner-compatible input hardware, and maintaining adequate temporal control over stimulus display and event logging. In functional magnetic resonance imaging, the scanner repeatedly acquires image volumes and emits regular synchronization pulses, or triggers, typically at the start of each repetition time. Scanner-compatible input hardware and trigger interfaces emulate standard keyboards or human interface devices, transmitting pulses and button presses as regular keystrokes at the operating-system level. The tutorial demonstrates that because jsPsych natively captures keyboard inputs through standard browser event listeners, it can receive scanner triggers and register participant responses without requiring external synchronization frameworks or custom hardware drivers.

The authors provide a step-by-step implementation guide based on jsPsych version 7.3.4, noting that the architectural principles apply equally across other releases. In the reference configuration, an experiment directory named fmri_project is structured with dedicated folders for previous drafts, exported behavioral data, image assets, and extracted library plugins. The primary task entry point, task.html, loads the required library modules and experiment scripts using relative file paths rather than external internet links. By avoiding remote content delivery networks, the task runs in complete isolation from the web, preventing network interruptions or browser security restrictions from interfering with experimental execution. The guide outlines a complete trial progression, including participant identification logging, full-screen initialization, trigger waiting intervals, visual countdown displays, experimental trials, full-screen termination, and local data export.

Scanner synchronization is achieved by incorporating dedicated trigger-wait trials directly into the experimental timeline using the standard jsPsychHtmlKeyboardResponse plugin. Encapsulated in a reusable function, each trigger trial displays an on-screen message, such as waiting for trigger notification, and restricts valid keyboard input strictly to the designated trigger character, commonly mapped to the number five or the letter t. The experimental timeline advances only when the expected trigger pulse is received from the scanner control system. In the tutorial example, three consecutive trigger trials are pushed to the timeline, allowing the system to wait for three initial dummy volumes before initiating task trials. This explicit arrangement ensures that the number, sequence, and labels of incoming scanner triggers are transparently logged in both the procedural code and the exported comma-separated values file.

Temporal alignment between behavioral events and functional neuroimaging data depends on establishing a precise time zero. In the exported dataset, each trial record includes a time_elapsed column indicating the number of milliseconds that have passed since the web page was initialized. When the third trigger trial completes, its recorded elapsed time—exemplified in the paper as 14,987 milliseconds—serves as the behavioral baseline. Subsequent trial completion times and stimulus onsets are aligned to scanner acquisition by subtracting this baseline value from their respective time_elapsed timestamps. On the neuroimaging side, investigators align the functional images by discarding the corresponding initial volumes, ensuring that behavioral event logs and blood-oxygen-level-dependent signal time series share an identical temporal reference point across subsequent statistical analyses.

Collecting participant responses inside the magnet bore requires translating button-box inputs into experimental choices. For discrete multiple-choice tasks, such as categorization or decision paradigms, native keyboard-response plugins handle button presses directly. The authors illustrate a five-trial judgment task where participants indicate yes or no using left and right buttons mapped to keys one and two. To preserve consistent experimental timing across participants and prevent variations in trial length from distorting hemodynamic modeling, the response window is fixed at 5,000 milliseconds using trial duration parameters that keep the trial active even after a selection has been made. Stimulus presentation, fixation crosses, and randomized presentation sequences are assembled through standard timeline variables, demonstrating that multiple-choice scanner tasks require minimal modifications beyond defining key mappings and fixed intervals.

Continuous rating scales present a distinct technical obstacle because standard slider plugins rely on mouse interaction, which cannot be operated through discrete button boxes. To bridge this functional gap, the researchers developed a custom JavaScript function that adapts the native jsPsychHtmlSliderResponse plugin for button-box control via the trial loading callback. The adapted slider initializes at the midpoint of fifty on a zero-to-one-hundred scale and allows participants to move the indicator leftward, move it rightward, and confirm their final selection using three configurable keys. To prevent premature accidental inputs, confirmation is accepted only after at least one movement key has been registered. Upon confirmation, the slider marker changes color to provide visual feedback, further movement is locked, and the final value is saved to the data file, while unconfirmed values are logged if the response window expires.

Beyond recording the final selected rating, the adapted continuous slider captures high-resolution behavioral dynamics throughout the trial duration. The function logs a comprehensive keyEvents array that records every key press and release along with millisecond-level elapsed timestamps, preserving the detailed temporal profile of motor responses for potential inclusion as nuisance regressors or quality-control metrics in general linear models. Additionally, the software logs a sliderSamples array that records the evolving trajectory of the slider position at user-defined intervals, set by default to every fifty milliseconds. This continuous kinematic record allows researchers to reconstruct the full decision-making trajectory over time rather than relying solely on static outcome measures, extending analytic possibilities within cognitive and affective neuroscience paradigms.

Local data management represents an essential component of offline scanner workflows, where automated cloud saving is unavailable. The tutorial details an initial survey trial that prompts the experimenter to input the participant identification code before full-screen mode begins. At the conclusion of the experimental run, a dedicated button-response trial invokes native local saving routines to export the accumulated dataset directly to the computer storage drive as a structured comma-separated values file. The exported filename programmatically combines the task name, participant identifier, and testing date, reducing the risk of file overwriting or manual renaming errors. The authors emphasize that collecting session numbers, run indices, and study-specific variables during initial setup facilitates robust record keeping and prevents confusion when participants complete multiple runs on the same day.

The authors outline practical operational recommendations and compatibility checks to ensure experimental stability during data collection. Instructions, comprehension assessments, and extensive task training should be conducted outside the magnet bore on separate machines, avoiding costly scanner usage and minimizing participant fatigue. Hardware testing protocols, such as verifying trigger inputs and button-box character mappings in basic text editors before scanning, prevent configuration errors during imaging runs. While browser-based presentation does not achieve the extreme millisecond precision of dedicated low-level software, the authors note that conventional functional magnetic resonance imaging operates at repetition times of one to two seconds to track the sluggish hemodynamic response. Consequently, the temporal control offered by jsPsych remains well suited for standard experimental designs, offering an accessible, transparent, and reproducible methodology across diverse neuroimaging laboratories.

Subject of Research: Methodological tutorial for implementing offline fMRI experiments using jsPsych

Article Title: A practical tutorial for implementing fMRI experiments with jsPsych

Article References: Hu, X., Chen, Y.-W., García-Arch, J., Rosenblau, G., & Korn, C. W. (2026). A practical tutorial for implementing fMRI experiments with jsPsych. Behavior Research Methods, 59(1), Article 5. https://doi.org/10.3758/s13428-026-03245-0

Image Credits: AI Generated

DOI: 10.3758/s13428-026-03245-0

Keywords: jsPsych, fMRI, neuroimaging, behavioral software, open science, scanner synchronization, button box, continuous slider, stimulus presentation, reproducibility, offline experimentation, event logging, PsychoPy, Psychtoolbox, Behavior Research Methods, data collection

Cite Scienmag News

Colin Clarke. (November 30, 2026). Tutorial Shows How Browser-Based jsPsych Software Runs Offline fMRI Experiments. Scienmag. https://scienmag.com/tutorial-shows-how-browser-based-jspsych-software-runs-offline-fmri-experiments/

Colin Clarke. "Tutorial Shows How Browser-Based jsPsych Software Runs Offline fMRI Experiments." Scienmag, 30 November 2026, https://scienmag.com/tutorial-shows-how-browser-based-jspsych-software-runs-offline-fmri-experiments/. Accessed 30 November 2026.

Colin Clarke. "Tutorial Shows How Browser-Based jsPsych Software Runs Offline fMRI Experiments." Scienmag. November 30, 2026. https://scienmag.com/tutorial-shows-how-browser-based-jspsych-software-runs-offline-fmri-experiments/

Tags: Behavior Research Methodsbehavioral softwarebutton boxcontinuous sliderdata collectionevent loggingfMRIjsPsychneuroimagingoffline experimentationopen sciencePsychoPyPsychtoolboxreproducibilityscanner synchronizationstimulus presentation
Share26Tweet16
Previous Post

Low Glycemic Diet Linked to Reduced Seizures in Pediatric SLC6A1 Study

Next Post

Combined Red and Blue LED Lighting Shifts Kiwifruit Seedling Growth and Photosynthesis

Related Posts

Visual Methods in Physical Education Research Enrich Student Expression Alongside Verbal Dialogue
Psychology & Psychiatry

Visual Methods in Physical Education Research Enrich Student Expression Alongside Verbal Dialogue

November 30, 2026
Workplace Violence Linked to Higher Depression and Anxiety in Medical Staff
Psychology & Psychiatry

Workplace Violence Linked to Higher Depression and Anxiety in Medical Staff

November 30, 2026
Computational psychiatry models link cognitive mechanisms and symptom networks across psychiatric conditions
Psychology & Psychiatry

Computational psychiatry models link cognitive mechanisms and symptom networks across psychiatric conditions

November 30, 2026
Review Frames Adolescent Adaptation in India as a Dynamic Life Skill
Psychology & Psychiatry

Review Frames Adolescent Adaptation in India as a Dynamic Life Skill

November 30, 2026
Perceived Organizational Support Linked to Lower Shame Among South Korean Leaders
Psychology & Psychiatry

Perceived Organizational Support Linked to Lower Shame Among South Korean Leaders

November 30, 2026
Adolescent Self-Injury Prevention Research Predominantly Focuses on Universal In-Person School Interventions
Psychology & Psychiatry

Adolescent Self-Injury Prevention Research Predominantly Focuses on Universal In-Person School Interventions

November 30, 2026
Next Post
Combined Red and Blue LED Lighting Shifts Kiwifruit Seedling Growth and Photosynthesis

Combined Red and Blue LED Lighting Shifts Kiwifruit Seedling Growth and Photosynthesis

  • Mothers who receive childcare support from maternal grandparents show more optimized

    Mothers who receive childcare support from maternal grandparents show more parental warmth, finds NTU Singapore study

    27657 shares
    Share 11059 Tweet 6912
  • University of Seville Breaks 120-Year-Old Mystery, Revises a Key Einstein Concept

    1061 shares
    Share 424 Tweet 265
  • Bee body mass, pathogens and local climate influence heat tolerance

    682 shares
    Share 273 Tweet 171
  • Researchers record first-ever images and data of a shark experiencing a boat strike

    546 shares
    Share 218 Tweet 137
  • Groundbreaking Clinical Trial Reveals Lubiprostone Enhances Kidney Function

    531 shares
    Share 212 Tweet 133
Science

Embark on a thrilling journey of discovery with Scienmag.com—your ultimate source for cutting-edge breakthroughs. Immerse yourself in a world where curiosity knows no limits and tomorrow’s possibilities become today’s reality!

RECENT NEWS

  • Familiarity and Personal Preference Drive Children’s School Lunch Decisions in England
  • Better Nursing Work Environments Tied to Stronger Commitment in Makkah Hospitals
  • Simulations Identify Optimal Equipment Configuration for High Arch Dam Concrete Construction
  • Open Digital Technologies Scale Teacher Professional Development in Indian Public Education

Categories

  • Agriculture
  • Anthropology
  • Archaeology
  • Athmospheric
  • Biology
  • Biotechnology
  • Blog
  • Bussines
  • Cancer
  • Chemistry
  • Climate
  • Earth Science
  • Editorial Policy
  • Marine
  • Mathematics
  • Medicine
  • Pediatry
  • Policy
  • Psychology & Psychiatry
  • Science Education
  • Science News
  • Social Science
  • Space
  • Technology and Engineering

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 5,152 other subscribers

© 2026 Scienmag - Science Magazine

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • HOME
  • SCIENCE NEWS
  • CONTACT US

© 2026 Scienmag - Science Magazine

Discover more from Science

Subscribe now to keep reading and get access to the full archive.

Continue reading