npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ssvep-stimuli

v0.1.2

Published

A library for generating SSVEP stimuli on the browser

Downloads

134

Readme

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.length)
   // const manager = new stimuli.CSS('approximation', elements.length)

   // ----------- WebGL Methods -----------
   // const canvas = document.body.querySelector('canvas')
   // const manager = new stimuli.WebGL('periodic', elements.length, canvas)
   // const manager = new stimuli.WebGL('approximation', elements.length, 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

Dr Chris Porter

Department of Computer Information Systems, Faculty of ICT

Dr Tracey Camilleri

Department of Systems & Control Engineering, Faculty of Engineering

Other Contributors

Garrett Flynn

Founding Partner at Brains@Play

  • Refactored the libraries for publication (April 2022)