Git Product home page Git Product logo

hci-lab-um / web-ssvep-stimuli-generators Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 320 KB

CSS and WebGL were adopted to implement four cross-platform Steady State Visually Evoked Potential (SSVEP) stimuli-generator libraries, whose stimuli are produced via constant-period and square wave approximation techniques, for use in a Brain-Computer Interface (BCI) context. These libraries are configured to run as spellers, yet can easily be altered to cater for a wide range of use cases.

License: GNU General Public License v3.0

HTML 15.12% JavaScript 81.44% CSS 3.44%
ssvep ssvep-bci css3 webgl javascript

web-ssvep-stimuli-generators's Introduction

SSVEP Stimuli-Generator Libraries

CSS and WebGL were adopted to implement four cross-platform Steady State Visually Evoked Potential (SSVEP) stimuli-generator libraries, whose stimuli are produced via constant-period and square wave approximation techniques, for use in a Brain-Computer Interface (BCI) context. These libraries are configured to run as spellers, yet can easily be altered to cater for a wide range of use cases.

More information about these libraries can be found in this peer reviewed publication by the same authors: Towards Accurate Browser-based SSVEP Stimuli Generation.

In alignment with existing documentation, it was found that CSS animations are more stable and performant than their WebGL counterparts.

Generating on-page stimuli

There are 4 stimuli generators in this repository, CSS+Square Wave Approximation, CSS+Constant Period, WebGL+Square Wave Approximation and WebGL+Constant Period.

After importing the library, you can create any number of stimuli on the page using the following data-* attributes:

  1. data-frequency: specifying the SSVEP stimulus frequency
  2. data-light-color: specifying the color of the SSVEP stimulus (N.B. data-dark-color currently defaults to transparent) in RGBA format (e.g. 1,1,1,1 for white)
  3. data-phase-shift: specifying the phase shift (frames delay) for the SSVEP stimulus

Stimuli can be defined as follows:

   <button data-frequency="6.67" data-dark-color="0,0,0,1" data-light-color="1,1,1,1" data-phase-shift="0">Content</button>
   <button data-frequency="7" data-dark-color="0,0,0,1" data-light-color="1,1,1,1" data-phase-shift="0">Content</button>
   <button data-frequency="8.57" data-dark-color="0,0,0,1" data-light-color="1,1,1,1" data-phase-shift="0">Content</button>

Begin Stimuli Generation

To begin stimuli generation, you must select your HTML elements and add to the manager

<script type="module">

  import * as stimuli from "./src/index.js"

   const elements = document.querySelectorAll('button')

   // ----------- CSS Methods -----------
   const manager = new stimuli.CSS('periodic', elements)
   // const manager = new stimuli.CSS('approximation', elements)

   // ----------- WebGL Methods -----------
   // const canvas = document.body.querySelector('canvas')
   // const manager = new stimuli.WebGL('periodic', elements, canvas)
   // const manager = new stimuli.WebGL('approximation', elements, canvas)

   elements.forEach(el => manager.set(el)) // Add Elements
   manager.start() // Start Stimuli Generation

</script>

You can add more stimuli by passing one or more elements to the start() method:

  manager.start(document.getElementById('new_element'))
   //  manager.start(document.body.querySelectorAll('.other'))

This technique also allows you to selectively start a subset of elements.

Cancel Stimuli Generation

You can cancel all ongoing stimuli generation by calling the stop() method:

  manager.stop()

Or stop a subset by passing one or more elements as the first argument:

  manager.stop(document.getElementById('new_element'))
//  manager.stop(document.body.querySelectorAll('.other'))

Roadmap

  • Add and remove elements based on visibility in the window.
  • Dynamically change the frequency values applied to an element
    • Automatically assign for maximum discriminability.
  • Position WebGL Canvas behind arbitrary elements across an entire a webpage with scrolling.
  • Implement CSS data-dark-color attribute changes
  • Expose a way to assign your own CSS rules and/or WebGL intensities

Known Issues

WebGL

  1. Dynamically adding elements using WebGL techniques will create too many contexts and halt execution.

Acknowledgments

These libraries were developed by Alison Camilleri to fulfill part of the requirements for the award of a Master of Science in Computer Information Systems degree.

Supervisory Team

Department of Computer Information Systems, Faculty of ICT

Department of Systems & Control Engineering, Faculty of Engineering

Other Contributors

Founding Partner at Brains@Play

  • Refactored the libraries for publication (April 2022)

web-ssvep-stimuli-generators's People

Contributors

chrisporter-um avatar garrettmflynn avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.