Skip to content

Commit

Permalink
Released v1.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pwstegman committed Apr 19, 2020
1 parent 7c612fb commit 97bdab1
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 59 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ BCI.js is a library for EEG-based brain computer interface (BCI) design with Jav

You can view all available methods in the [docs](https://bci.js.org/docs/)

Latest release is v1.7.0. You can view the release notes at [releases](https://github.com/pwstegman/bci.js/releases)
Latest release is v1.7.1. You can view the release notes at [releases](https://github.com/pwstegman/bci.js/releases)

## Getting Started

Expand All @@ -29,7 +29,7 @@ npm install bcijs
Browser

```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/bci.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/bci.min.js"></script>
```

## Tutorials
Expand Down Expand Up @@ -162,7 +162,7 @@ console.log(subarr);
BCI.js can be loaded from the jsDelivr CDN with

```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/bci.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/bci.min.js"></script>
```

You can also find `bci.js` and `bci.min.js` in the [/dist](https://github.com/pwstegman/bci.js/tree/master/dist) directory.
Expand Down
2 changes: 1 addition & 1 deletion browser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file was auto generated, changes will be overwritten
// Created on Sat Apr 18 2020 22:23:30 GMT-0400 (Eastern Daylight Time)
// Created on Sat Apr 18 2020 22:38:20 GMT-0400 (Eastern Daylight Time)
// This module excludes Node.js specific methods so it can be used in the browser
/** @module bcijs */
module.exports.averageBandPowers = require('./lib/compat/averageBandPowers.js');
Expand Down
47 changes: 25 additions & 22 deletions dist/bci.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/**
* bci.js v1.7.0
* bci.js v1.7.1
* https://github.com/pwstegman/bci.js
*
* License: MIT
* Generated 2020-04-11T13:56:44Z
* Generated 2020-04-19T02:37:48Z
*/

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bci = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";

// This file was auto generated, changes will be overwritten
// Created on Sat Apr 11 2020 09:56:44 GMT-0400 (Eastern Daylight Time)
// Created on Sat Apr 18 2020 22:37:48 GMT-0400 (Eastern Daylight Time)
// This module excludes Node.js specific methods so it can be used in the browser

/** @module bcijs */
Expand Down Expand Up @@ -1060,31 +1060,37 @@ function bandpower(samples, sample_rate, bands, options) {

if (fftSize < samples.length) {
throw new Error('fftSize must be greater than or equal to the length of samples');
} // If matrix with muliple signals, process each signal
} // Clean up 'bands' so it is a number[][] (array of bands where a band is [low, high])


var original_bands = bands;
bands = reduceBands(bands); // If matrix with muliple signals, process each signal

if (Array.isArray(samples[0])) {
var channels = transpose(samples);
var powers = channels.map(function (channel) {
return bandpower(channel, sample_rate, bands, options);
}); // Handle the 2D case (multiple channels and multiple bands)
}); // Return to same row/col format as input (channels are columns)

if (Array.isArray(powers[0])) {
// Return to same row/col format as input (channels are columns)
powers = transpose(powers); // Instead of calculating, for example, alpha power at each channel, calculate the average alpha
// across all channels.
powers = transpose(powers); // Instead of calculating, for example, alpha power at each channel, calculate the average alpha
// across all channels.

if (average) {
for (var i = 0; i < powers.length; i++) {
var sum = 0;

for (var j = 0; j < powers[i].length; j++) {
sum += powers[i][j];
}
if (average) {
for (var i = 0; i < powers.length; i++) {
var sum = 0;

powers[i] = sum / powers[i].length;
for (var j = 0; j < powers[i].length; j++) {
sum += powers[i][j];
}

powers[i] = sum / powers[i].length;
}
} // If they only passed a single band (not an array of bands), then the array of areas will
// have a length of 1. Return the single power value, not an array.


if (typeof original_bands === 'string' || typeof original_bands[0] === 'number') {
return powers[0];
}

return powers;
Expand All @@ -1108,11 +1114,8 @@ function bandpower(samples, sample_rate, bands, options) {
}
} else {
throw new Error('Invalid input type');
} // Clean up 'bands' so it is a number[][] (array of bands where a band is [low, high])

} // Calculate the total power for relative power calculation if selected in options

var original_bands = bands;
bands = reduceBands(bands); // Calculate the total power for relative power calculation if selected in options

var total_power = 1;
var dx = sample_rate / fftSize;
Expand Down Expand Up @@ -1721,7 +1724,7 @@ function hann(signal) {
* @param {Object} [options]
* @param {number} [options.fftSize=Math.pow(2, bci.nextpow2(signal.length))] - Size of the fft to be used. Should be a power of 2.
* @param {number} [options.window='rectangular'] - Window function to apply, either 'hann' or 'rectangular'. Default is 'rectangular'.
* @returns {Object} Object with keys 'estimates' (the psd estimates) and 'frequencies' (the corresponding frequencies)
* @returns {Object} Object with keys 'estimates' (the psd estimates) and 'frequencies' (the corresponding frequencies in Hz)
*/


Expand Down
6 changes: 3 additions & 3 deletions dist/bci.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions docs/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,13 @@ <h3>Classes</h3><ul><li id="oscStream-nav"><a href="module-bcijs.oscStream.html"
<li>Networking (data collection, streaming via OSC, etc.)</li>
</ul>
<p>You can view all available methods in the <a href="https://bci.js.org/docs/">docs</a></p>
<p>Latest release is v1.7.1. You can view the release notes at <a href="https://github.com/pwstegman/bci.js/releases">releases</a></p>
<h2>Getting Started</h2>
<p>Node.js</p>
<pre class="prettyprint source lang-bash"><code>npm install bcijs
</code></pre>
<p>Browser</p>
<pre class="prettyprint source lang-html"><code>&lt;script src=&quot;https://cdn.jsdelivr.net/npm/[email protected].0/dist/bci.min.js&quot;>&lt;/script>
<pre class="prettyprint source lang-html"><code>&lt;script src=&quot;https://cdn.jsdelivr.net/npm/[email protected].1/dist/bci.min.js&quot;>&lt;/script>
</code></pre>
<h2>Tutorials</h2>
<ul>
Expand Down Expand Up @@ -240,7 +241,7 @@ <h3>Data Manipulation and Feature Extraction</h3>
</code></pre>
<h2>Usage in the web</h2>
<p>BCI.js can be loaded from the jsDelivr CDN with</p>
<pre class="prettyprint source lang-html"><code>&lt;script src=&quot;https://cdn.jsdelivr.net/npm/[email protected].0/dist/bci.min.js&quot;>&lt;/script>
<pre class="prettyprint source lang-html"><code>&lt;script src=&quot;https://cdn.jsdelivr.net/npm/[email protected].1/dist/bci.min.js&quot;>&lt;/script>
</code></pre>
<p>You can also find <code>bci.js</code> and <code>bci.min.js</code> in the <a href="https://github.com/pwstegman/bci.js/tree/master/dist">/dist</a> directory.</p>
<p>BCI.js methods are accessible via the global object <code>bci</code>.</p>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h1 class="page-title">
<section>
<article>
<pre class="prettyprint source linenums"><code>// This file was auto generated, changes will be overwritten
// Created on Sat Apr 11 2020 09:57:09 GMT-0400 (Eastern Daylight Time)
// Created on Sat Apr 18 2020 22:38:20 GMT-0400 (Eastern Daylight Time)
/** @module bcijs */
module.exports.averageBandPowers = require('./lib/compat/averageBandPowers.js');
module.exports.csp = require('./lib/compat/csp.js');
Expand Down
39 changes: 21 additions & 18 deletions docs/docs/lib_math_bandpower.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,31 +240,38 @@ <h1 class="page-title">
if(fftSize &lt; samples.length) {
throw new Error('fftSize must be greater than or equal to the length of samples');
}

// Clean up 'bands' so it is a number[][] (array of bands where a band is [low, high])
let original_bands = bands;
bands = reduceBands(bands);

// If matrix with muliple signals, process each signal
if(Array.isArray(samples[0])) {
let channels = transpose(samples);

let powers = channels.map(channel => bandpower(channel, sample_rate, bands, options));

// Handle the 2D case (multiple channels and multiple bands)
if(Array.isArray(powers[0])) {
// Return to same row/col format as input (channels are columns)
powers = transpose(powers);

// Instead of calculating, for example, alpha power at each channel, calculate the average alpha
// across all channels.
if(average) {
for(let i = 0; i &lt; powers.length; i++) {
let sum = 0;
for(let j = 0; j &lt; powers[i].length; j++) {
sum += powers[i][j];
}
powers[i] = sum / powers[i].length;
// Return to same row/col format as input (channels are columns)
powers = transpose(powers);

// Instead of calculating, for example, alpha power at each channel, calculate the average alpha
// across all channels.
if(average) {
for(let i = 0; i &lt; powers.length; i++) {
let sum = 0;
for(let j = 0; j &lt; powers[i].length; j++) {
sum += powers[i][j];
}
powers[i] = sum / powers[i].length;
}
}

// If they only passed a single band (not an array of bands), then the array of areas will
// have a length of 1. Return the single power value, not an array.
if(typeof original_bands === 'string' || typeof original_bands[0] === 'number') {
return powers[0];
}

return powers;
}

Expand All @@ -282,10 +289,6 @@ <h1 class="page-title">
throw new Error('Invalid input type');
}

// Clean up 'bands' so it is a number[][] (array of bands where a band is [low, high])
let original_bands = bands;
bands = reduceBands(bands);

// Calculate the total power for relative power calculation if selected in options
let total_power = 1;
let dx = sample_rate / fftSize;
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/csp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/two.js/0.6.0/two.min.js" integrity="sha256-0qJ0at+6aIXSqYEgj85J5ufSt6+IdiairAk4+OBJLMU=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/bci.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/bci.min.js"></script>
<script src="csp.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion docs/examples/lda/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/two.js/0.6.0/two.min.js" integrity="sha256-0qJ0at+6aIXSqYEgj85J5ufSt6+IdiairAk4+OBJLMU=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/bci.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/bci.min.js"></script>
<script src="lda.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><title>BCI.js</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"><!-- Bootstrap--><link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"><!-- Font Awesome--><link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono"><!-- Main CSS--><link rel="stylesheet" href="css/main.css"><link rel="stylesheet" href="css/navbar.css"><link rel="stylesheet" href="css/prettify.css"></head><body><nav class="navbar navbar-expand-lg navbar-light"><div class="container"><a class="navbar-brand" href="/"><img src="/img/logo.svg" height="30" alt="BCI.js"></a><button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbar"><div class="navbar-nav ml-auto"><a class="nav-item nav-link" href="/docs"><i class="fas fa-book mr-1"></i> Docs</a><a class="nav-item nav-link" href="https://github.com/pwstegman/bci.js#tutorials"><i class="fas fa-drafting-compass mr-1"></i> Tutorials</a><a class="nav-item nav-link" href="/#examples"><i class="fas fa-code mr-1"></i> Examples</a><a class="nav-item nav-link" href="#" data-toggle="tooltip" data-placement="bottom" title="Coming soon"><i class="fas fa-cubes mr-1"></i> Showcase <span class="d-lg-none">(coming soon)</span></a></div></div></div></nav><section class="text-center" id="intro"><div class="container"><div class="py-5"><img id="logo" src="img/logo.svg" height="100"><p class="lead text-muted mt-2 font-weight-normal">Powering brain-computer interfaces with JavaScript</p><p><a class="btn btn-outline-primary my-2 mr-2" href="https://github.com/pwstegman/bci.js"><i class="fab fa-github"></i> GitHub</a><a class="btn btn-outline-success my-2" href="/docs"><i class="fas fa-book"></i> Docs</a></p></div></div></section><section class="blue" id="getstarted"><div class="container"><div class="row"><div class="col-md-4"><h2><i class="fas fa-download fa-sm mr-1"></i> Get Started</h2><p>Perform online and offline processing in Node.js with our NPM package, or get started directly in your browser with the jsDelivr CDN.</p><div class="d-md-none pb-2">&nbsp; </div></div><div class="col-md-8"><h5>Node.js</h5><pre class="prettyprint lang-bash codesnippet mx-auto"><code>npm install bcijs</code></pre><h5>Browser</h5><pre class="prettyprint lang-html codesnippet mx-auto"><code>&lt;script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bci.min.js"&gt;&lt;/script&gt;</code></pre></div></div></div></section><div id="examples"><section class="feature" id="signalProcessing"><div class="container"><div class="row"><div class="col-lg-4"><h4><i class="fas fa-chart-line"></i> Signal Processing</h4><p>Isolate specific brainwaves with methods such as the fast fourier transform, common spatial pattern, FastICA, and more.</p><p>Find more examples in our <a href="https://github.com/pwstegman/bci.js/tree/master/examples">GitHub repo</a> and our <a href="/docs">docs</a>.</p><div class="d-md-none pb-2"></div></div><div class="col-lg-8"><nav><div class="nav nav-tabs" id="nav-tab" role="tablist"><a class="nav-item nav-link active" id="nav-bandpower-tab" data-toggle="tab" href="#nav-bandpower" role="tab" aria-controls="nav-bandpower" aria-selected="true">bandpower.js</a><a class="nav-item nav-link" id="nav-csp-tab" data-toggle="tab" href="#nav-csp" role="tab" aria-controls="nav-csp" aria-selected="true">csp.js</a></div></nav><div class="tab-content" id="nav-tabContent"><div class="tab-pane show active" id="nav-bandpower" role="tabpanel" aria-labelledby="nav-bandpower-tab"><pre class="prettyprint lang-js" style="min-height:31em;"><code>const bci = require('bcijs');
<!DOCTYPE html><html lang="en"><head><title>BCI.js</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"><!-- Bootstrap--><link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"><!-- Font Awesome--><link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono"><!-- Main CSS--><link rel="stylesheet" href="css/main.css"><link rel="stylesheet" href="css/navbar.css"><link rel="stylesheet" href="css/prettify.css"></head><body><nav class="navbar navbar-expand-lg navbar-light"><div class="container"><a class="navbar-brand" href="/"><img src="/img/logo.svg" height="30" alt="BCI.js"></a><button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbar"><div class="navbar-nav ml-auto"><a class="nav-item nav-link" href="/docs"><i class="fas fa-book mr-1"></i> Docs</a><a class="nav-item nav-link" href="https://github.com/pwstegman/bci.js#tutorials"><i class="fas fa-drafting-compass mr-1"></i> Tutorials</a><a class="nav-item nav-link" href="/#examples"><i class="fas fa-code mr-1"></i> Examples</a><a class="nav-item nav-link" href="#" data-toggle="tooltip" data-placement="bottom" title="Coming soon"><i class="fas fa-cubes mr-1"></i> Showcase <span class="d-lg-none">(coming soon)</span></a></div></div></div></nav><section class="text-center" id="intro"><div class="container"><div class="py-5"><img id="logo" src="img/logo.svg" height="100"><p class="lead text-muted mt-2 font-weight-normal">Powering brain-computer interfaces with JavaScript</p><p><a class="btn btn-outline-primary my-2 mr-2" href="https://github.com/pwstegman/bci.js"><i class="fab fa-github"></i> GitHub</a><a class="btn btn-outline-success my-2" href="/docs"><i class="fas fa-book"></i> Docs</a></p></div></div></section><section class="blue" id="getstarted"><div class="container"><div class="row"><div class="col-md-4"><h2><i class="fas fa-download fa-sm mr-1"></i> Get Started</h2><p>Perform online and offline processing in Node.js with our NPM package, or get started directly in your browser with the jsDelivr CDN.</p><div class="d-md-none pb-2">&nbsp; </div></div><div class="col-md-8"><h5>Node.js</h5><pre class="prettyprint lang-bash codesnippet mx-auto"><code>npm install bcijs</code></pre><h5>Browser</h5><pre class="prettyprint lang-html codesnippet mx-auto"><code>&lt;script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bci.min.js"&gt;&lt;/script&gt;</code></pre></div></div></div></section><div id="examples"><section class="feature" id="signalProcessing"><div class="container"><div class="row"><div class="col-lg-4"><h4><i class="fas fa-chart-line"></i> Signal Processing</h4><p>Isolate specific brainwaves with methods such as the fast fourier transform, common spatial pattern, FastICA, and more.</p><p>Find more examples in our <a href="https://github.com/pwstegman/bci.js/tree/master/examples">GitHub repo</a> and our <a href="/docs">docs</a>.</p><div class="d-md-none pb-2"></div></div><div class="col-lg-8"><nav><div class="nav nav-tabs" id="nav-tab" role="tablist"><a class="nav-item nav-link active" id="nav-bandpower-tab" data-toggle="tab" href="#nav-bandpower" role="tab" aria-controls="nav-bandpower" aria-selected="true">bandpower.js</a><a class="nav-item nav-link" id="nav-csp-tab" data-toggle="tab" href="#nav-csp" role="tab" aria-controls="nav-csp" aria-selected="true">csp.js</a></div></nav><div class="tab-content" id="nav-tabContent"><div class="tab-pane show active" id="nav-bandpower" role="tabpanel" aria-labelledby="nav-bandpower-tab"><pre class="prettyprint lang-js" style="min-height:31em;"><code>const bci = require('bcijs');

// Generate 1 second of sample data
let sampleRate = 512;
Expand Down
Loading

0 comments on commit 97bdab1

Please sign in to comment.