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

eeg-pipes

v2.0.3

Published

Lettable RxJS operators for working with EEG data in Node and the Browser

Downloads

27

Readme

EEG Pipes

Pipeable RxJS operators for working with EEG data in Node and the Browser

Usage

Before getting started, you'll need an observable of EEG data.

The following are some libraries that provide exactly that:

Pipes can be added to an EEG observable of EEG data samples with the following data structure:

{
  data: [Number, Number, Number, Number], // channels
  timestamp: Date,
  info?: {
  	samplingRate?: Number,
  	channelNames?: [String, String, String, String],
  	..
  }
};

Individual samples of EEG data contain an array of values for each EEG channel as well as a timestamp. An additional info object containing metadata about the EEG stream such as sampling rate and channel names can also be included or added with the addInfo operator.

We can start by installing the library:

npm install --save eeg-pipes

Then, importing the pipes from the library:

import { bufferFFT, alphaPower } from "eeg-pipes";

And adding them to the RxJS observable pipe operator:

eeg$
  .pipe(bufferFFT({ bins: 256 }), alphaPower())
  .subscribe(buffer => console.log(buffer));

Pipes

Filtering (IIR)

Filter pipes can be applied to both samples or buffers of samples. Filters are linear IIR filters using a digital biquad implementation.

  • lowpassFilter({ nbChannels, cutoffFrequency })
  • highpassFilter({ nbChannels, cutoffFrequency })
  • bandpassFilter({ nbChannels, cutoffFrequencies: [lowBound, highBound] })
  • notchFilter({ nbChannels, cutoffFrequency })

Optional Parameters:
characteristic: 'butterworth' or 'bessel'. Default is butterworth characteristic because of its steeper cutoff
order: the number of 2nd order biquad filters applied to the signal. Default is 2.
samplingRate: should match the samplingRate of your EEG device. Default is 250

Frequency

  • bufferFFT({ bins, window, sampleRate })
  • alphaPower()
  • betaPower()
  • deltaPower()
  • gammaPower()
  • thetaPower()
  • averagePower()
  • sliceFFT([ min, max ])
  • powerByBand()

Unit conversion

  • toMicrovolts({ log })

Utility

  • bufferCount()
  • bufferTime()
  • chunk()
  • pickChannels({ channels: [c1, c2, c3] })
  • removeChannels({ channels: [c1, c2, c3] })
  • addInfo()

Coming soon

Filtering

  • vertScaleFilter()
  • vertAgoFilter()
  • smoothFilter()
  • polarityFilter()
  • maxFrequencyFilter()

Chunking Data

Most pipes will work when applied to streams of individual EEG samples. However, in order to improve performance, especially when working with high sample rates, it is also possible to chunk data so that each emitted event represents a collection of individual EEG samples. Only filter pipes support chunked data currently

Chunks can be created by using a buffer operator such as bufferCount or bufferTime followed by the chunk operator:

eeg$
  .pipe(bufferCount(1000), chunk())
  .subscribe(buffer => console.log(buffer));

Chunks have the following data structure:

{
  data: [
    [Number, Number, ...],
    [Number, Number, ...],
    [Number, Number, ...],
    [Number, Number, ...],
  ], // nbChannels x nbSamples 
  info: {
    samplingRate: Number,
    startTime: Number,
    ...
  }
}

Chunks contain a 2D data array with shape nbChannels x nbSamples. Instead of individual timestamps for each sample, Chunk objects contain samplingRate and startTime information in the info object in order to allow time at any point within the Chunk to be inferred. Info properties present in Sample objects before being pooled into Chunks will be maintained.