Skip to content

Commit

Permalink
Merge branch 'feat/psd-update'
Browse files Browse the repository at this point in the history
  • Loading branch information
pwstegman committed Apr 11, 2020
2 parents 7952ec9 + 1cf070b commit e7c63bc
Show file tree
Hide file tree
Showing 76 changed files with 6,680 additions and 3,949 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<br>

BCI.js is a library for EEG-based brain computer interface (BCI) design with JavaScript and Node.js. It allows for the creation of BCI enabled web apps or Node.js applications, with features such as:
- Signal processing and machine learning (LDA, CSP, ICA, PSD, etc.)
- Signal processing and machine learning (Bandpower, PSD, LDA, CSP, ICA, etc.)
- Data manipulation (MATLAB style array subscripting, data windowing, CSV file support, etc.)
- Networking (data collection, streaming via OSC, etc.)

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

```html
<script src="https://cdn.jsdelivr.net/npm/bcijs@1.6.5/dist/bci.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bcijs@1.7.0/dist/bci.min.js"></script>
```

## Tutorials
Expand All @@ -45,7 +45,7 @@ const bci = require('bcijs');
// Generate 1 second of sample data
let sampleRate = 512;
let duration = 1;
let amplitudes = [1, 2, 4, 8];
let amplitudes = [8, 4, 2, 1];
let frequencies = [
1, // 1 Hz, delta range
5, // 5 Hz, theta range
Expand All @@ -55,21 +55,22 @@ let frequencies = [

let signal = bci.generateSignal(amplitudes, frequencies, sampleRate, duration);

// Compute average power in each frequency band
let fftSize = sampleRate * duration;
let bandpowers = bci.signalBandPower(
// Compute relative power in each frequency band
let bandpowers = bci.bandpower(
signal,
sampleRate,
['delta', 'theta', 'alpha', 'beta'],
{fftSize: fftSize} // optional, defaults to next power of 2 larger than or equal to signal length
{relative: true}
);

console.log(bandpowers);
/*
[ 85.33333333333366,
128.00000000000122,
204.80000000000047,
113.77777777777825 ]
[
0.7171876695851037,
0.22444067394892755,
0.04489131763080717,
0.013469490282877555
]
*/
```

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

```html
<script src="https://cdn.jsdelivr.net/npm/bcijs@1.6.5/dist/bci.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bcijs@1.7.0/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 All @@ -186,6 +187,8 @@ BCI.js methods can be found in the [lib/](https://github.com/pwstegman/bci.js/tr

Documentation can be found at [https://bci.js.org/docs](https://bci.js.org/docs) or by viewing [api.md](https://github.com/pwstegman/bci.js/blob/master/docs/docs/api.md)

Deprecated methods can be found at [deprecated.md](https://github.com/pwstegman/bci.js/blob/master/docs/docs/deprecated.md)

## Building

See [dev.md](dev.md) for info on how to modify and build BCI.js
Expand Down
12 changes: 7 additions & 5 deletions browser.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
// This file was auto generated, changes will be overwritten
// Created on Sat Nov 09 2019 13:46:57 GMT-0600 (Central Standard Time)
// Created on Sat Apr 11 2020 09:57:09 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');
module.exports.csp = require('./lib/compat/csp.js');
module.exports.f1score = require('./lib/compat/f1score.js');
module.exports.lda = require('./lib/compat/lda.js');
module.exports.psd = require('./lib/compat/psd.js');
module.exports.psdBandPower = require('./lib/compat/psdBandPower.js');
module.exports.signal = require('./lib/compat/signal.js');
module.exports.signalBandPower = require('./lib/compat/signalBandPower.js');
module.exports.partition = require('./lib/data/partition.js');
module.exports.round = require('./lib/data/round.js');
module.exports.subscript = require('./lib/data/subscript.js');
module.exports.toFixed = require('./lib/data/toFixed.js');
module.exports.toTable = require('./lib/data/toTable.js');
module.exports.windowApply = require('./lib/data/windowApply.js');
module.exports.averageBandPowers = require('./lib/math/averageBandPowers.js');
module.exports.bandpower = require('./lib/math/bandpower.js');
module.exports.cspLearn = require('./lib/math/cspLearn.js');
module.exports.cspProject = require('./lib/math/cspProject.js');
module.exports.fastICA = require('./lib/math/fastICA.js');
Expand All @@ -22,9 +26,7 @@ module.exports.ldaClassify = require('./lib/math/ldaClassify.js');
module.exports.ldaLearn = require('./lib/math/ldaLearn.js');
module.exports.ldaProject = require('./lib/math/ldaProject.js');
module.exports.nextpow2 = require('./lib/math/nextpow2.js');
module.exports.psd = require('./lib/math/psd.js');
module.exports.psdBandPower = require('./lib/math/psdBandPower.js');
module.exports.signalBandPower = require('./lib/math/signalBandPower.js');
module.exports.periodogram = require('./lib/math/periodogram.js');
module.exports.transpose = require('./lib/math/transpose.js');
module.exports.accuracy = require('./lib/metrics/accuracy.js');
module.exports.balancedAccuracy = require('./lib/metrics/balancedAccuracy.js');
Expand Down
Loading

0 comments on commit e7c63bc

Please sign in to comment.