Comparar commits
86 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| c0913f5bc2 | |||
| 079e70ceda | |||
| 087ca941d5 | |||
| 2e0b8a4b65 | |||
| f0f67422fc | |||
| 07ec09dc1e | |||
| 0d330b8ebe | |||
| 1bcc2fec76 | |||
| cce6f472e6 | |||
| 833d453b60 | |||
| 2028e6f0cc | |||
| 1b32803837 | |||
| b2cb3df80d | |||
| 23cc89be29 | |||
| dea0e9e404 | |||
| c95f4390f0 | |||
| 0d7d63e1d5 | |||
| b6e6060f03 | |||
| 967c58edf8 | |||
| 9742153cce | |||
| 03bce529e6 | |||
| 296b139232 | |||
| 474d4e75a4 | |||
| d38459e2ef | |||
| 42666822eb | |||
| 6b064396fd | |||
| 1ca04f7a85 | |||
| 99ef8ca8bb | |||
| b992530b9d | |||
| 2b0c9a427c | |||
| fb8ac1e5c8 | |||
| e198c818e5 | |||
| a59f733b8a | |||
| 9769748a99 | |||
| 2b89671f97 | |||
| 152c24f897 | |||
| 690b1a819c | |||
| 91d19e7b95 | |||
| e0c03b9fb0 | |||
| 4e44945aa3 | |||
| c839e13b7b | |||
| 5f595d6371 | |||
| 89cbd6dc5d | |||
| 56204c9745 | |||
| 2c11531abc | |||
| c939bb0aca | |||
| 31af57069a | |||
| eb45f4a467 | |||
| f7a0b06775 | |||
| 3c14295333 | |||
| 8ac7003a9e | |||
| 1c3efbacd9 | |||
| e6a799e94f | |||
| 82a1327b76 | |||
| aa1271d571 | |||
| ca0e2eb223 | |||
| fa91e84967 | |||
| 5448015bee | |||
| 0b2ae4178c | |||
| 83597cc26e | |||
| 7813baaa75 | |||
| 108885dc20 | |||
| c775ba3d7f | |||
| 896b463112 | |||
| ffcef9b5ee | |||
| 52ef5e8c37 | |||
| 6fc8be819a | |||
| ca5a23c6d2 | |||
| f7215078fa | |||
| 362ef7dc1e | |||
| 4a81cde138 | |||
| 13f51acb22 | |||
| 6ec94bac01 | |||
| 77261e95c4 | |||
| 32acb8b443 | |||
| 08f22161d9 | |||
| f953b615d7 | |||
| 4af8d568ac | |||
| 17f7447f36 | |||
| 4620e70414 | |||
| 62063f9373 | |||
| 1f52a0e4d6 | |||
| b0bf5de8f1 | |||
| 09b1a0e70c | |||
| 308ec2a48e | |||
| 0d52f9019e |
+10
-1
@@ -58,4 +58,13 @@ typings/
|
||||
.env
|
||||
|
||||
# visual studio
|
||||
.vs/
|
||||
.vs/
|
||||
|
||||
# build files
|
||||
build/
|
||||
|
||||
# dist files
|
||||
dist/
|
||||
|
||||
# data files
|
||||
examples/data/
|
||||
+110
-15
@@ -3,17 +3,24 @@ JavaScript based EEG signal processing
|
||||
|
||||
**Goal:** Build portable/modern framework for web-based BCI applications
|
||||
|
||||
Deploying BCI applications in a more portable language such as JavaScript can be difficult as many BCI specific methods have yet to be implemented. WebBCI aims to help bridge this gap by implementing BCI specific methods, building on existing libraries such as Math.js and Numeric Javascript. It also implements MATLAB specific methods, such as colon notation for array subscripting, to make data manipulation in JavaScript easier.
|
||||
|
||||
## Dev
|
||||
|
||||
This is the dev branch of webbci. Documentation may be lacking and the API can change at any time.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install webbci
|
||||
npm install webbci@dev
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Signal Processing
|
||||
|
||||
```javascript
|
||||
var wbci = require('webbci');
|
||||
var ws = wbci.signal;
|
||||
var bci = require('webbci');
|
||||
|
||||
// Generate 1 second of sample data
|
||||
var sampleRate = 512;
|
||||
@@ -26,23 +33,111 @@ var frequencies = [
|
||||
17 // 17 Hz, beta range
|
||||
];
|
||||
|
||||
var signal = ws.generate(amplitudes, frequencies, sampleRate, duration);
|
||||
|
||||
// Get frequency powers in signal
|
||||
var length = sampleRate * duration;
|
||||
var psd = ws.getPSD(length, signal);
|
||||
var signal = bci.generateSignal(amplitudes, frequencies, sampleRate, duration);
|
||||
|
||||
// Compute average power in each frequency band
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'delta')); // 85
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'theta')); // 128
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'alpha')); // 205
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'beta')); // 114
|
||||
var fftSize = sampleRate * duration;
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'delta', fftSize)); // 85
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'theta', fftSize)); // 128
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'alpha', fftSize)); // 205
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'beta', fftSize)); // 114
|
||||
```
|
||||
|
||||
## Examples
|
||||
### Machine Learning
|
||||
|
||||
More examples can be found in the [examples](examples/) directory
|
||||
```javascript
|
||||
var bci = require('webbci');
|
||||
|
||||
// Training set
|
||||
var class1 = [
|
||||
[0, 0],
|
||||
[1, 2],
|
||||
[2, 2],
|
||||
[1.5, 0.5]
|
||||
];
|
||||
var class2 = [
|
||||
[8, 8],
|
||||
[9, 10],
|
||||
[7, 8],
|
||||
[9, 9]
|
||||
];
|
||||
|
||||
// Testing set
|
||||
var unknownPoints = [
|
||||
[-1, 0],
|
||||
[1.5, 2],
|
||||
[3, 3],
|
||||
[5, 5],
|
||||
[7, 9],
|
||||
[10, 12]
|
||||
];
|
||||
|
||||
// Learn an LDA classifier
|
||||
var ldaParams = bci.ldaLearn(class1, class2);
|
||||
|
||||
// Test classifier
|
||||
var predictions = unknownPoints.map(point => {
|
||||
return Math.sign(bci.ldaProject(ldaParams, point))
|
||||
});
|
||||
|
||||
console.log(predictions); // [ -1, -1, -1, 1, 1, 1 ]
|
||||
```
|
||||
|
||||
### Data Manipulation and Feature Extraction
|
||||
|
||||
```javascript
|
||||
var bci = require('webbci');
|
||||
|
||||
// Some random numbers
|
||||
var data = [3, 2, 3, 0, 4, 0, 0, 5, 4, 0];
|
||||
|
||||
// Partition into training and testing sets
|
||||
var [training, testing] = bci.partition(data, 0.6, 0.4);
|
||||
|
||||
console.log(training); // [3, 2, 3, 0, 4, 0]
|
||||
console.log(testing); // [0, 5, 4, 0]
|
||||
|
||||
// Traverse the data array with windows of size 3 and a step of 2 (overlap of 1 item per window)
|
||||
bci.windowApply(data, window => console.log(window), 3, 2);
|
||||
/*
|
||||
[ 3, 2, 3 ]
|
||||
[ 3, 0, 4 ]
|
||||
[ 4, 0, 0 ]
|
||||
[ 0, 5, 4 ]
|
||||
*/
|
||||
|
||||
// Find the log of the variance of these windows (feature extraction)
|
||||
var features = bci.windowApply(data, bci.features.logvar, 3, 2);
|
||||
console.log(features); // [-1.099, 1.466, 1.674, 1.946]
|
||||
|
||||
// Colon notation for array subscripting
|
||||
var arr = [
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7, 8, 9]
|
||||
];
|
||||
var subarr = bci.subscript(arr, '1 3', '2:3'); // rows 1 and 3, columns 2 through 3
|
||||
console.log(subarr);
|
||||
/*
|
||||
[[2, 3],
|
||||
[8, 9]]
|
||||
*/
|
||||
```
|
||||
|
||||
## Usage in the web
|
||||
|
||||
```bash
|
||||
npm run dist
|
||||
```
|
||||
|
||||
This will generate `dist/bci.js` and `dist/bci.min.js`. WebBCI methods can be accessed via the global object *bci*.
|
||||
|
||||
OSC methods will not work in the web.
|
||||
|
||||
## Documentation
|
||||
|
||||
Documentation can be found at [http://pwstegman.me/WebBCI/](http://pwstegman.me/WebBCI/)
|
||||
For a complete list of methods and documentation check out [docs/api.md](https://github.com/pwstegman/WebBCI/blob/dev/docs/api.md)
|
||||
|
||||
## Examples
|
||||
|
||||
More examples can be found in the [examples](https://github.com/pwstegman/WebBCI/tree/dev/examples) directory
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
// Additional backwards compatibility
|
||||
exports.LDA = exports.lda;
|
||||
exports.csp = exports.signal.CSP;
|
||||
@@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?js= title ?> - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<?js= this.nav ?>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
<?js if (title != 'Home') { ?>
|
||||
<h1 class="page-title"><?js= title ?></h1>
|
||||
<?js } ?>
|
||||
|
||||
<?js= content ?>
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc <?js= env.version.number ?></a><?js if(env.conf.templates && env.conf.templates.default && env.conf.templates.default.includeDate !== false) { ?> on <?js= (new Date()) ?><?js } ?> using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+406
@@ -0,0 +1,406 @@
|
||||
<a name="module_webbci"></a>
|
||||
|
||||
## webbci
|
||||
|
||||
* [webbci](#module_webbci)
|
||||
* [.oscStream](#module_webbci.oscStream)
|
||||
* [new oscStream(address, port)](#new_module_webbci.oscStream_new)
|
||||
* [.start()](#module_webbci.oscStream+start)
|
||||
* [.stop()](#module_webbci.oscStream+stop)
|
||||
* [.on(header, callback)](#module_webbci.oscStream+on)
|
||||
* [.features](#module_webbci.features) : <code>object</code>
|
||||
* [.logvar(window, [dimension])](#module_webbci.features.logvar)
|
||||
* [.rootMeanSquare(window, [dimension])](#module_webbci.features.rootMeanSquare)
|
||||
* [.cspLearn(class1, class2)](#module_webbci.cspLearn) ⇒ <code>Object</code>
|
||||
* [.cspProject(cspParams, data, [dimensions])](#module_webbci.cspProject) ⇒ <code>Array.<Array.<number>></code>
|
||||
* [.generateSignal(amplitudes, frequencies, sampleRate, duration)](#module_webbci.generateSignal) ⇒ <code>Array.<number></code>
|
||||
* [.ldaLearn(class1, class2)](#module_webbci.ldaLearn) ⇒ <code>Object</code>
|
||||
* [.ldaProject(ldaParams, point)](#module_webbci.ldaProject) ⇒ <code>number</code>
|
||||
* [.nextpow2(num)](#module_webbci.nextpow2)
|
||||
* [.psd(signal, [options])](#module_webbci.psd) ⇒ <code>Array.<number></code>
|
||||
* [.psdBandPower(psd, sampleRate, band, [fftSize])](#module_webbci.psdBandPower) ⇒ <code>number</code>
|
||||
* [.signalBandPower(signal, sampleRate, band, [fftSize])](#module_webbci.signalBandPower) ⇒ <code>number</code>
|
||||
* [.loadCSV(filePath)](#module_webbci.loadCSV) ⇒ <code>Promise</code>
|
||||
* [.partition(array, ...divisions)](#module_webbci.partition) ⇒ <code>Array.<Array></code>
|
||||
* [.round(array, places)](#module_webbci.round) ⇒ <code>Array.<number></code>
|
||||
* [.saveCSV(array, filename)](#module_webbci.saveCSV) ⇒ <code>Promise</code>
|
||||
* [.subscript(array, ...params)](#module_webbci.subscript) ⇒ <code>Array</code>
|
||||
* [.toFixed(array, places)](#module_webbci.toFixed) ⇒ <code>Array.<string></code>
|
||||
* [.toTable(array)](#module_webbci.toTable) ⇒ <code>string</code>
|
||||
* [.windowApply(array, func, length, step, tail)](#module_webbci.windowApply) ⇒ <code>Array</code>
|
||||
* [.oscCollect(address, port, header, samples)](#module_webbci.oscCollect) ⇒ <code>Promise</code>
|
||||
* [.oscHeaderScan(address, port, duration)](#module_webbci.oscHeaderScan) ⇒ <code>Promise</code>
|
||||
* [.wait(ms)](#module_webbci.wait)
|
||||
|
||||
<a name="module_webbci.oscStream"></a>
|
||||
|
||||
### webbci.oscStream
|
||||
Listen for messages over OSC
|
||||
|
||||
**Kind**: static class of [<code>webbci</code>](#module_webbci)
|
||||
|
||||
* [.oscStream](#module_webbci.oscStream)
|
||||
* [new oscStream(address, port)](#new_module_webbci.oscStream_new)
|
||||
* [.start()](#module_webbci.oscStream+start)
|
||||
* [.stop()](#module_webbci.oscStream+stop)
|
||||
* [.on(header, callback)](#module_webbci.oscStream+on)
|
||||
|
||||
<a name="new_module_webbci.oscStream_new"></a>
|
||||
|
||||
#### new oscStream(address, port)
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| address | <code>string</code> | Address to listen on |
|
||||
| port | <code>number</code> | Port to listen on |
|
||||
|
||||
<a name="module_webbci.oscStream+start"></a>
|
||||
|
||||
#### oscStream.start()
|
||||
Start listening for OSC messages
|
||||
|
||||
**Kind**: instance method of [<code>oscStream</code>](#module_webbci.oscStream)
|
||||
<a name="module_webbci.oscStream+stop"></a>
|
||||
|
||||
#### oscStream.stop()
|
||||
Stop listening for OSC messages
|
||||
|
||||
**Kind**: instance method of [<code>oscStream</code>](#module_webbci.oscStream)
|
||||
<a name="module_webbci.oscStream+on"></a>
|
||||
|
||||
#### oscStream.on(header, callback)
|
||||
Call a callback function when data containing a specified OSC header is seen
|
||||
|
||||
**Kind**: instance method of [<code>oscStream</code>](#module_webbci.oscStream)
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| header | <code>string</code> | The OSC header |
|
||||
| callback | <code>requestCallback</code> | Called with the OSC data passed as the parameter |
|
||||
|
||||
<a name="module_webbci.features"></a>
|
||||
|
||||
### webbci.features : <code>object</code>
|
||||
Feature extraction methods
|
||||
|
||||
**Kind**: static namespace of [<code>webbci</code>](#module_webbci)
|
||||
|
||||
* [.features](#module_webbci.features) : <code>object</code>
|
||||
* [.logvar(window, [dimension])](#module_webbci.features.logvar)
|
||||
* [.rootMeanSquare(window, [dimension])](#module_webbci.features.rootMeanSquare)
|
||||
|
||||
<a name="module_webbci.features.logvar"></a>
|
||||
|
||||
#### features.logvar(window, [dimension])
|
||||
Computes the log of the variance along the specified dimension
|
||||
|
||||
**Kind**: static method of [<code>features</code>](#module_webbci.features)
|
||||
|
||||
| Param | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| window | <code>Array.<number></code> \| <code>Array.<Array.<number>></code> | | The data |
|
||||
| [dimension] | <code>string</code> | <code>null</code> | If 'rows' or 'columns' passed, the features are calculated along that dimension |
|
||||
|
||||
<a name="module_webbci.features.rootMeanSquare"></a>
|
||||
|
||||
#### features.rootMeanSquare(window, [dimension])
|
||||
Computes the root mean square along the specified dimension
|
||||
|
||||
**Kind**: static method of [<code>features</code>](#module_webbci.features)
|
||||
|
||||
| Param | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| window | <code>Array.<number></code> \| <code>Array.<Array.<number>></code> | | The data |
|
||||
| [dimension] | <code>string</code> | <code>null</code> | If 'rows' or 'columns' passed, the features are calculated along that dimension |
|
||||
|
||||
<a name="module_webbci.cspLearn"></a>
|
||||
|
||||
### webbci.cspLearn(class1, class2) ⇒ <code>Object</code>
|
||||
Learn common spatial pattern for two datasets
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Object</code> - Learned CSP parameters
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| class1 | <code>Array.<Array.<number>></code> | Data samples for class 1. Rows should be samples, columns should be signals. |
|
||||
| class2 | <code>Array.<Array.<number>></code> | Data samples for class 2. Rows should be samples, columns should be signals. |
|
||||
|
||||
<a name="module_webbci.cspProject"></a>
|
||||
|
||||
### webbci.cspProject(cspParams, data, [dimensions]) ⇒ <code>Array.<Array.<number>></code>
|
||||
Projects data and reduces to given number of dimensions
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Array.<Array.<number>></code> - Projected data. Rows are samples, columns are dimensions sorted by descending importance.
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| cspParams | <code>object</code> | CSP parameters computed using the cspLearn function |
|
||||
| data | <code>Array.<Array.<number>></code> | Data points to be projected. Rows should be samples, columns should be signals. |
|
||||
| [dimensions] | <code>number</code> | Number of dimensions to be returned. Can range from 1 to number of signals. Defaults to number of signals. |
|
||||
|
||||
<a name="module_webbci.generateSignal"></a>
|
||||
|
||||
### webbci.generateSignal(amplitudes, frequencies, sampleRate, duration) ⇒ <code>Array.<number></code>
|
||||
Generate a signal with the given frequencies and their amplitudes.
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Array.<number></code> - The generated signal.
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| amplitudes | <code>Array.<number></code> | The amplitudes of each frequency. |
|
||||
| frequencies | <code>Array.<number></code> | The frequencies. |
|
||||
| sampleRate | <code>number</code> | Sample rate of the signal in Hz. |
|
||||
| duration | <code>number</code> | Duration of the signal in seconds. |
|
||||
|
||||
<a name="module_webbci.ldaLearn"></a>
|
||||
|
||||
### webbci.ldaLearn(class1, class2) ⇒ <code>Object</code>
|
||||
Perform linear discriminant analysis between two datasets
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Object</code> - Computed LDA parameters
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| class1 | <code>Array.<Array.<number>></code> | Data set for class 1, rows are samples, columns are variables |
|
||||
| class2 | <code>Array.<Array.<number>></code> | Data set for class 2, rows are samples, columns are variables |
|
||||
|
||||
<a name="module_webbci.ldaProject"></a>
|
||||
|
||||
### webbci.ldaProject(ldaParams, point) ⇒ <code>number</code>
|
||||
Predict the class of an unknown data point.
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>number</code> - value less than 0 if predicted to be in class 1, 0 if exactly inbetween, greater than 0 if class 2
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| ldaParams | <code>object</code> | The parameters for the LDA, computed with the function ldaLearn |
|
||||
| point | <code>Array.<number></code> | The data point to be classified. |
|
||||
|
||||
<a name="module_webbci.nextpow2"></a>
|
||||
|
||||
### webbci.nextpow2(num)
|
||||
Returns the ceil of the log2 of the absolute value of the passed number
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
|
||||
| Param | Type |
|
||||
| --- | --- |
|
||||
| num | <code>number</code> |
|
||||
|
||||
**Example**
|
||||
```js
|
||||
nextpow2(8); // 3
|
||||
nextpow2(9); // 4
|
||||
nextpow2(16); // 4
|
||||
nextpow2(30); // 5
|
||||
nextpow2(0); // -Infinity
|
||||
```
|
||||
<a name="module_webbci.psd"></a>
|
||||
|
||||
### webbci.psd(signal, [options]) ⇒ <code>Array.<number></code>
|
||||
Compute the power spectral density of a given signal.
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Array.<number></code> - The PSD.
|
||||
|
||||
| Param | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| signal | <code>Array.<number></code> | | The signal. |
|
||||
| [options] | <code>Object</code> | | |
|
||||
| [options.fftSize] | <code>number</code> | <code>Math.pow(2, bci.nextpow2(signal.length))</code> | Size of the fft to be used. Should be a power of 2. |
|
||||
| [options.truncate] | <code>boolean</code> | <code>false</code> | If true, only the first half of the PSD array is returned |
|
||||
|
||||
<a name="module_webbci.psdBandPower"></a>
|
||||
|
||||
### webbci.psdBandPower(psd, sampleRate, band, [fftSize]) ⇒ <code>number</code>
|
||||
Compute the average power across a given frequency band given the PSD.
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>number</code> - The average power in the frequency band.
|
||||
|
||||
| Param | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| psd | <code>Array.<number></code> | | Power spectral density of the signal. |
|
||||
| sampleRate | <code>number</code> | | The sample rate of the signal. |
|
||||
| band | <code>Array.<number></code> \| <code>string</code> | | The frequency band provided as an array [frequencyStart, frequencyStop] or a string <code>delta</code> (1-3 Hz), <code>theta</code> (4-7 Hz), <code>alpha</code> (8-12 Hz), <code>beta</code> (13-30 Hz), or <code>gamma</code> (31-50 Hz). While string representations allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in future updates. |
|
||||
| [fftSize] | <code>number</code> | <code>Math.pow(2, bci.nextpow2(psd.length))</code> | Size of the fourier transform used to compute the PSD. |
|
||||
|
||||
<a name="module_webbci.signalBandPower"></a>
|
||||
|
||||
### webbci.signalBandPower(signal, sampleRate, band, [fftSize]) ⇒ <code>number</code>
|
||||
Compute the average power across a given frequency band in a signal.
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>number</code> - The average power in the frequency band.
|
||||
|
||||
| Param | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| signal | <code>Array.<number></code> | | The signal. |
|
||||
| sampleRate | <code>number</code> | | The sample rate of the signal. |
|
||||
| band | <code>Array.<number></code> \| <code>string</code> | | The frequency band provided as an array [frequencyStart, frequencyStop] or a string <code>delta</code> (1-3 Hz), <code>theta</code> (4-7 Hz), <code>alpha</code> (8-12 Hz), <code>beta</code> (13-30 Hz), or <code>gamma</code> (31-50 Hz). While string representations allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in future updates. |
|
||||
| [fftSize] | <code>number</code> | <code>Math.pow(2, bci.nextpow2(signal.length))</code> | Size of the fourier transform used to compute the PSD. |
|
||||
|
||||
<a name="module_webbci.loadCSV"></a>
|
||||
|
||||
### webbci.loadCSV(filePath) ⇒ <code>Promise</code>
|
||||
Loads a CSV file into an array
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Promise</code> - A promise object representing the CSV data array
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| filePath | <code>string</code> | The path to the CSV file |
|
||||
|
||||
<a name="module_webbci.partition"></a>
|
||||
|
||||
### webbci.partition(array, ...divisions) ⇒ <code>Array.<Array></code>
|
||||
Partitions an array into multiple arrays
|
||||
Can be used to split data into training and testing sets
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Array.<Array></code> - Array of subarrays which are the partitons
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| array | <code>Array</code> | The array to be partitioned |
|
||||
| ...divisions | <code>Array.<number></code> | The size of each partition, each value should range from 0 to 1 |
|
||||
|
||||
**Example**
|
||||
```js
|
||||
partition([1, 2, 3, 4], 0.25, 0.75); // returns [[1], [2, 3, 4]]
|
||||
```
|
||||
<a name="module_webbci.round"></a>
|
||||
|
||||
### webbci.round(array, places) ⇒ <code>Array.<number></code>
|
||||
Rounds every value in an array to a set number of decimal places
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Array.<number></code> - The rounded array
|
||||
|
||||
| Param | Type |
|
||||
| --- | --- |
|
||||
| array | <code>Array.<number></code> |
|
||||
| places | <code>number</code> |
|
||||
|
||||
<a name="module_webbci.saveCSV"></a>
|
||||
|
||||
### webbci.saveCSV(array, filename) ⇒ <code>Promise</code>
|
||||
Saves an array to a CSV file
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Promise</code> - A promise object that resolves when the file has been saved. Does not currently reject on write error.
|
||||
|
||||
| Param | Type |
|
||||
| --- | --- |
|
||||
| array | <code>Array</code> |
|
||||
| filename | <code>string</code> |
|
||||
|
||||
<a name="module_webbci.subscript"></a>
|
||||
|
||||
### webbci.subscript(array, ...params) ⇒ <code>Array</code>
|
||||
Subscript an array with MATLAB-like syntax
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Array</code> - The subscripted array
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| array | <code>Array</code> | The array to be subscripted |
|
||||
| ...params | <code>string</code> | Colon notation for which elements to include in each dimension |
|
||||
|
||||
**Example**
|
||||
```js
|
||||
var bci = require('webbci');
|
||||
var arr = [3, 2, 4, 1, 5];
|
||||
var subarr = bci.subscript(arr, '1:3');
|
||||
console.log(subarr); // [3, 2, 4]
|
||||
```
|
||||
**Example**
|
||||
```js
|
||||
var bci = require('webbci');
|
||||
var arr = [
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7, 8, 9]
|
||||
];
|
||||
var subarr = bci.subscript(arr, '1 3', '2:3'); // rows 1 and 3, columns 2 through 3
|
||||
console.log(subarr); // [[2, 3], [8, 9]]
|
||||
```
|
||||
<a name="module_webbci.toFixed"></a>
|
||||
|
||||
### webbci.toFixed(array, places) ⇒ <code>Array.<string></code>
|
||||
Returns an array of numbers as strings rounded to the proper number of decimal places and padded with zeros as needed.
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Array.<string></code> - Array of string representations of numbers
|
||||
|
||||
| Param | Type |
|
||||
| --- | --- |
|
||||
| array | <code>Array</code> |
|
||||
| places | <code>number</code> |
|
||||
|
||||
<a name="module_webbci.toTable"></a>
|
||||
|
||||
### webbci.toTable(array) ⇒ <code>string</code>
|
||||
Returns an ASCII table representation of an array
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>string</code> - ASCII table
|
||||
|
||||
| Param | Type |
|
||||
| --- | --- |
|
||||
| array | <code>Array</code> |
|
||||
|
||||
<a name="module_webbci.windowApply"></a>
|
||||
|
||||
### webbci.windowApply(array, func, length, step, tail) ⇒ <code>Array</code>
|
||||
Similar to JavaScript's map, but it applies a function to sub arrays instead of each element.
|
||||
Each sub array, or window, starts at index 0 and has length 'length'
|
||||
Each next window will be shifted 'step' elements from the first. The result of each function is stored in a returned array.
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Array</code> - An array containing the function result for each window
|
||||
|
||||
| Param | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| array | <code>Array</code> | | The array of elements which will be windowed |
|
||||
| func | <code>function</code> | | The function to call on each window, the returned result is stored in a returned array |
|
||||
| length | <code>number</code> | | The number of elements to include in each window |
|
||||
| step | <code>number</code> | | The start of the window is incremented by this amount every iteration |
|
||||
| tail | <code>boolean</code> | <code>false</code> | If false, windows which begin near the end of the array which cannot reach length 'length' will be ignored |
|
||||
|
||||
**Example**
|
||||
```js
|
||||
var bci = require('webbci');
|
||||
bci.windowApply([1, 2, 3, 4, 5], window => console.log(window), 3, 1);
|
||||
// [1, 2, 3]
|
||||
// [2, 3, 4]
|
||||
// [3, 4, 5]
|
||||
```
|
||||
**Example**
|
||||
```js
|
||||
var bci = require('webbci');
|
||||
var sums = bci.windowApply([1, 2, 3, 4, 5], window => {
|
||||
var sum = 0;
|
||||
window.forEach(x => sum += x);
|
||||
return sum;
|
||||
}, 3, 1);
|
||||
console.log(sums);
|
||||
// [6, 9, 12]
|
||||
```
|
||||
<a name="module_webbci.oscCollect"></a>
|
||||
|
||||
### webbci.oscCollect(address, port, header, samples) ⇒ <code>Promise</code>
|
||||
Collect a set number of samples over OSC
|
||||
|
||||
**Kind**: static method of [<code>webbci</code>](#module_webbci)
|
||||
**Returns**: <code>Promise</code> - Resolves with collected data
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
@@ -0,0 +1,215 @@
|
||||
<a name="module_webbci"></a>
|
||||
|
||||
## webbci
|
||||
|
||||
* [webbci](#module_webbci)
|
||||
* ~~[.LDA](#module_webbci.LDA)~~
|
||||
* [new LDA(class1, class2)](#new_module_webbci.LDA_new)
|
||||
* [.project(point)](#module_webbci.LDA.project) ⇒ <code>number</code>
|
||||
* ~~[.network](#module_webbci.network) : <code>object</code>~~
|
||||
* [.addEEGListener(oscAddress, oscPort, eegAddress, callback)](#module_webbci.network.addEEGListener)
|
||||
* ~~[.signal](#module_webbci.signal) : <code>object</code>~~
|
||||
* [generate(amplitudes, frequencies, sampleRate, duration)](#generate) ⇒ <code>Array.<number></code>
|
||||
* _static_
|
||||
* [.CSP](#module_webbci.signal.CSP)
|
||||
* [new CSP(class1, class2)](#new_module_webbci.signal.CSP_new)
|
||||
* [.project(data, [dimensions])](#module_webbci.signal.CSP.project) ⇒ <code>Array.<Array.<number>></code>
|
||||
* [.EEGWindow](#module_webbci.signal.EEGWindow)
|
||||
* [new EEGWindow(size, numChannels, callback)](#new_module_webbci.signal.EEGWindow_new)
|
||||
* [.addData(data)](#module_webbci.signal.EEGWindow+addData)
|
||||
* [.clear()](#module_webbci.signal.EEGWindow+clear)
|
||||
* [.getPSD(size, signal)](#module_webbci.signal.getPSD) ⇒ <code>Array.<number></code>
|
||||
* [.getBandPower(size, psd, sampleRate, band)](#module_webbci.signal.getBandPower) ⇒ <code>number</code>
|
||||
|
||||
<a name="module_webbci.LDA"></a>
|
||||
|
||||
### ~~webbci.LDA~~
|
||||
***Deprecated***
|
||||
|
||||
**Kind**: static class of [<code>webbci</code>](#module_webbci)
|
||||
|
||||
* ~~[.LDA](#module_webbci.LDA)~~
|
||||
* [new LDA(class1, class2)](#new_module_webbci.LDA_new)
|
||||
* [.project(point)](#module_webbci.LDA.project) ⇒ <code>number</code>
|
||||
|
||||
<a name="new_module_webbci.LDA_new"></a>
|
||||
|
||||
#### new LDA(class1, class2)
|
||||
An LDA object
|
||||
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| class1 | <code>Array.<Array.<number>></code> | Data set for class 1, rows are samples, columns are variables |
|
||||
| class2 | <code>Array.<Array.<number>></code> | Data set for class 2, rows are samples, columns are variables |
|
||||
|
||||
<a name="module_webbci.LDA.project"></a>
|
||||
|
||||
#### LDA.project(point) ⇒ <code>number</code>
|
||||
Predict the class of an unknown data point
|
||||
|
||||
**Kind**: static method of [<code>LDA</code>](#module_webbci.LDA)
|
||||
**Returns**: <code>number</code> - value less than 0 if predicted to be in class 1, 0 if exactly inbetween, greater than 0 if class 2
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| point | <code>Array.<number></code> | The data point to be classified. |
|
||||
|
||||
<a name="module_webbci.network"></a>
|
||||
|
||||
### ~~webbci.network : <code>object</code>~~
|
||||
***Deprecated***
|
||||
|
||||
The network operations for webbci
|
||||
|
||||
**Kind**: static namespace of [<code>webbci</code>](#module_webbci)
|
||||
<a name="module_webbci.network.addEEGListener"></a>
|
||||
|
||||
#### network.addEEGListener(oscAddress, oscPort, eegAddress, callback)
|
||||
Calls callback when EEG data is received over the network.
|
||||
|
||||
**Kind**: static method of [<code>network</code>](#module_webbci.network)
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| oscAddress | <code>string</code> | The address of the OSC server. For example: 127.0.0.1. |
|
||||
| oscPort | <code>number</code> | The port of the OSC server. |
|
||||
| eegAddress | <code>string</code> | The OSC header for the EEG data. For example: Person0/eeg. |
|
||||
| callback | <code>requestCallback</code> | Called when EEG data is received. |
|
||||
|
||||
<a name="module_webbci.signal"></a>
|
||||
|
||||
### ~~webbci.signal : <code>object</code>~~
|
||||
***Deprecated***
|
||||
|
||||
Signal processing operations
|
||||
|
||||
**Kind**: static namespace of [<code>webbci</code>](#module_webbci)
|
||||
|
||||
* ~~[.signal](#module_webbci.signal) : <code>object</code>~~
|
||||
* [generate(amplitudes, frequencies, sampleRate, duration)](#generate) ⇒ <code>Array.<number></code>
|
||||
* _static_
|
||||
* [.CSP](#module_webbci.signal.CSP)
|
||||
* [new CSP(class1, class2)](#new_module_webbci.signal.CSP_new)
|
||||
* [.project(data, [dimensions])](#module_webbci.signal.CSP.project) ⇒ <code>Array.<Array.<number>></code>
|
||||
* [.EEGWindow](#module_webbci.signal.EEGWindow)
|
||||
* [new EEGWindow(size, numChannels, callback)](#new_module_webbci.signal.EEGWindow_new)
|
||||
* [.addData(data)](#module_webbci.signal.EEGWindow+addData)
|
||||
* [.clear()](#module_webbci.signal.EEGWindow+clear)
|
||||
* [.getPSD(size, signal)](#module_webbci.signal.getPSD) ⇒ <code>Array.<number></code>
|
||||
* [.getBandPower(size, psd, sampleRate, band)](#module_webbci.signal.getBandPower) ⇒ <code>number</code>
|
||||
|
||||
<a name="generate"></a>
|
||||
|
||||
#### signalgenerate(amplitudes, frequencies, sampleRate, duration) ⇒ <code>Array.<number></code>
|
||||
Generate a signal.
|
||||
|
||||
**Returns**: <code>Array.<number></code> - The generated signal. Equals the summation of <code>amplitudes[i] * sin(2 * pi * frequencies[i] * t)</code>.
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| amplitudes | <code>Array.<number></code> | The amplitudes of each frequency in the signal. |
|
||||
| frequencies | <code>Array.<number></code> | The frequencies to be included in the signal. |
|
||||
| sampleRate | <code>number</code> | The sample rate of the signal in Hz. |
|
||||
| duration | <code>number</code> | The duration of the signal in seconds. |
|
||||
|
||||
<a name="module_webbci.signal.CSP"></a>
|
||||
|
||||
#### signal.CSP
|
||||
**Kind**: static class of [<code>signal</code>](#module_webbci.signal)
|
||||
|
||||
* [.CSP](#module_webbci.signal.CSP)
|
||||
* [new CSP(class1, class2)](#new_module_webbci.signal.CSP_new)
|
||||
* [.project(data, [dimensions])](#module_webbci.signal.CSP.project) ⇒ <code>Array.<Array.<number>></code>
|
||||
|
||||
<a name="new_module_webbci.signal.CSP_new"></a>
|
||||
|
||||
##### new CSP(class1, class2)
|
||||
Creates a new CSP object
|
||||
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| class1 | <code>Array.<Array.<number>></code> | Data samples for class 1. Rows should be samples, columns should be signals. |
|
||||
| class2 | <code>Array.<Array.<number>></code> | Data samples for class 2. Rows should be samples, columns should be signals. |
|
||||
|
||||
<a name="module_webbci.signal.CSP.project"></a>
|
||||
|
||||
##### CSP.project(data, [dimensions]) ⇒ <code>Array.<Array.<number>></code>
|
||||
Projects data and reduces to given number of dimensions
|
||||
|
||||
**Kind**: static method of [<code>CSP</code>](#module_webbci.signal.CSP)
|
||||
**Returns**: <code>Array.<Array.<number>></code> - Projected data. Rows are samples, columns are dimensions sorted by descending importance.
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| data | <code>Array.<Array.<number>></code> | Data points to be projected. Rows should be samples, columns should be signals. |
|
||||
| [dimensions] | <code>number</code> | Number of dimensions to be returned. Can range from 1 to number of signals. Defaults to number of signals. |
|
||||
|
||||
<a name="module_webbci.signal.EEGWindow"></a>
|
||||
|
||||
#### signal.EEGWindow
|
||||
**Kind**: static class of [<code>signal</code>](#module_webbci.signal)
|
||||
|
||||
* [.EEGWindow](#module_webbci.signal.EEGWindow)
|
||||
* [new EEGWindow(size, numChannels, callback)](#new_module_webbci.signal.EEGWindow_new)
|
||||
* [.addData(data)](#module_webbci.signal.EEGWindow+addData)
|
||||
* [.clear()](#module_webbci.signal.EEGWindow+clear)
|
||||
|
||||
<a name="new_module_webbci.signal.EEGWindow_new"></a>
|
||||
|
||||
##### new EEGWindow(size, numChannels, callback)
|
||||
Create a new EEGWindow object.
|
||||
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| size | <code>number</code> | The number of samples to be stored before callback is called. |
|
||||
| numChannels | <code>number</code> | The number of channels in each sample. |
|
||||
| callback | <code>requestCallback</code> | Called when the EEGWindow has a number of samples equal to size. An array of dimensions channels x samples is passed to the callback function. |
|
||||
|
||||
<a name="module_webbci.signal.EEGWindow+addData"></a>
|
||||
|
||||
##### eegWindow.addData(data)
|
||||
Adds a data sample to the EEGWindow.
|
||||
|
||||
**Kind**: instance method of [<code>EEGWindow</code>](#module_webbci.signal.EEGWindow)
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| data | <code>Array.<number></code> | The data sample to be added. Should be of length 'channels' |
|
||||
|
||||
<a name="module_webbci.signal.EEGWindow+clear"></a>
|
||||
|
||||
##### eegWindow.clear()
|
||||
Reset the EEGWindow and clear all data from it.
|
||||
|
||||
**Kind**: instance method of [<code>EEGWindow</code>](#module_webbci.signal.EEGWindow)
|
||||
<a name="module_webbci.signal.getPSD"></a>
|
||||
|
||||
#### signal.getPSD(size, signal) ⇒ <code>Array.<number></code>
|
||||
Compute the power spectral density of a given signal.
|
||||
|
||||
**Kind**: static method of [<code>signal</code>](#module_webbci.signal)
|
||||
**Returns**: <code>Array.<number></code> - The PSD.
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| size | <code>number</code> | Size of the fourier transform to be used. Should be a power of 2. |
|
||||
| signal | <code>Array.<number></code> | The signal. |
|
||||
|
||||
<a name="module_webbci.signal.getBandPower"></a>
|
||||
|
||||
#### signal.getBandPower(size, psd, sampleRate, band) ⇒ <code>number</code>
|
||||
Compute the average power across a given frequency band given the PSD.
|
||||
|
||||
**Kind**: static method of [<code>signal</code>](#module_webbci.signal)
|
||||
**Returns**: <code>number</code> - The average power in the frequency band.
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| size | <code>number</code> | Size of the fourier transform used to compute the PSD. |
|
||||
| psd | <code>Array.<number></code> | Power spectral density of the signal. |
|
||||
| sampleRate | <code>number</code> | The sample rate of the signal. |
|
||||
| band | <code>Array.<number></code> \| <code>string</code> | The frequency band provided as an array [frequencyStart, frequencyStop] or a string <code>delta</code> (1-3 Hz), <code>theta</code> (4-7 Hz), <code>alpha</code> (8-12 Hz), <code>beta</code> (13-30 Hz), or <code>gamma</code> (31-50 Hz). While string representations allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in future updates. |
|
||||
|
||||
Arquivo binário não exibido.
@@ -1,92 +0,0 @@
|
||||
Copyright (c) 2010-2014 by tyPoland Lukasz Dziedzic (team@latofonts.com) with Reserved Font Name "Lato"
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
Arquivo binário não exibido.
+90
-17
@@ -9,9 +9,13 @@
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/ionicons.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -23,7 +27,7 @@
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.LDA.html">LDA</a><ul class='methods'><li data-type='method'><a href="module-webbci.LDA.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.CSP.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#addData">addData</a></li><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#clear">clear</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.network.html">network</a><ul class='methods'><li data-type='method'><a href="module-webbci.network.html#.addEEGListener">addEEGListener</a></li></ul></li><li><a href="module-webbci.signal.html">signal</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.html">generate</a></li><li data-type='method'><a href="module-webbci.signal.html#.getBandPower">getBandPower</a></li><li data-type='method'><a href="module-webbci.signal.html#.getPSD">getPSD</a></li></ul></li></ul>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
@@ -49,8 +53,9 @@
|
||||
<section class="readme">
|
||||
<article><h1>WebBCI</h1><p>JavaScript based EEG signal processing</p>
|
||||
<p><strong>Goal:</strong> Build portable/modern framework for web-based BCI applications</p>
|
||||
<h2>Installation</h2><pre class="prettyprint source lang-bash"><code>npm install webbci</code></pre><h2>Getting Started</h2><pre class="prettyprint source lang-javascript"><code>var wbci = require('webbci');
|
||||
var ws = wbci.signal;
|
||||
<p>Deploying BCI applications in a more portable language such as JavaScript can be difficult as many BCI specific methods have yet to be implemented. WebBCI aims to help bridge this gap by implementing BCI specific methods, building on existing libraries such as Math.js and Numeric Javascript. It also implements MATLAB specific methods, such as colon notation for array subscripting, to make data manipulation in JavaScript easier.</p>
|
||||
<h2>Dev</h2><p>This is the dev branch of webbci. Documentation may be lacking and the API can change at any time.</p>
|
||||
<h2>Installation</h2><pre class="prettyprint source lang-bash"><code>npm install webbci@dev</code></pre><h2>Getting Started</h2><h3>Signal Processing</h3><pre class="prettyprint source lang-javascript"><code>var bci = require('webbci');
|
||||
|
||||
// Generate 1 second of sample data
|
||||
var sampleRate = 512;
|
||||
@@ -63,18 +68,86 @@ var frequencies = [
|
||||
17 // 17 Hz, beta range
|
||||
];
|
||||
|
||||
var signal = ws.generate(amplitudes, frequencies, sampleRate, duration);
|
||||
|
||||
// Get frequency powers in signal
|
||||
var length = sampleRate * duration;
|
||||
var psd = ws.getPSD(length, signal);
|
||||
var signal = bci.generateSignal(amplitudes, frequencies, sampleRate, duration);
|
||||
|
||||
// Compute average power in each frequency band
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'delta')); // 85
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'theta')); // 128
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'alpha')); // 205
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'beta')); // 114</code></pre><h2>Examples</h2><p>More examples can be found in the <a href="https://github.com/pwstegman/WebBCI/tree/master/examples">examples</a> directory</p>
|
||||
<h2>Documentation</h2><p>Documentation can be found at <a href="http://pwstegman.me/WebBCI/">http://pwstegman.me/WebBCI/</a></p></article>
|
||||
var fftSize = sampleRate * duration;
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'delta', fftSize)); // 85
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'theta', fftSize)); // 128
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'alpha', fftSize)); // 205
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'beta', fftSize)); // 114</code></pre><h3>Machine Learning</h3><pre class="prettyprint source lang-javascript"><code>var bci = require('webbci');
|
||||
|
||||
// Training set
|
||||
var class1 = [
|
||||
[0, 0],
|
||||
[1, 2],
|
||||
[2, 2],
|
||||
[1.5, 0.5]
|
||||
];
|
||||
var class2 = [
|
||||
[8, 8],
|
||||
[9, 10],
|
||||
[7, 8],
|
||||
[9, 9]
|
||||
];
|
||||
|
||||
// Testing set
|
||||
var unknownPoints = [
|
||||
[-1, 0],
|
||||
[1.5, 2],
|
||||
[3, 3],
|
||||
[5, 5],
|
||||
[7, 9],
|
||||
[10, 12]
|
||||
];
|
||||
|
||||
// Learn an LDA classifier
|
||||
var ldaParams = bci.ldaLearn(class1, class2);
|
||||
|
||||
// Test classifier
|
||||
var predictions = unknownPoints.map(point => {
|
||||
return Math.sign(bci.ldaProject(ldaParams, point))
|
||||
});
|
||||
|
||||
console.log(predictions); // [ -1, -1, -1, 1, 1, 1 ]</code></pre><h3>Data Manipulation and Feature Extraction</h3><pre class="prettyprint source lang-javascript"><code>var bci = require('webbci');
|
||||
|
||||
// Some random numbers
|
||||
var data = [3, 2, 3, 0, 4, 0, 0, 5, 4, 0];
|
||||
|
||||
// Partition into training and testing sets
|
||||
var [training, testing] = bci.partition(data, 0.6, 0.4);
|
||||
|
||||
console.log(training); // [3, 2, 3, 0, 4, 0]
|
||||
console.log(testing); // [0, 5, 4, 0]
|
||||
|
||||
// Traverse the data array with windows of size 3 and a step of 2 (overlap of 1 item per window)
|
||||
bci.windowApply(data, window => console.log(window), 3, 2);
|
||||
/*
|
||||
[ 3, 2, 3 ]
|
||||
[ 3, 0, 4 ]
|
||||
[ 4, 0, 0 ]
|
||||
[ 0, 5, 4 ]
|
||||
*/
|
||||
|
||||
// Find the log of the variance of these windows (feature extraction)
|
||||
var features = bci.windowApply(data, bci.features.logvar, 3, 2);
|
||||
console.log(features); // [-1.099, 1.466, 1.674, 1.946]
|
||||
|
||||
// Colon notation for array subscripting
|
||||
var arr = [
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7, 8, 9]
|
||||
];
|
||||
var subarr = bci.subscript(arr, '1 3', '2:3'); // rows 1 and 3, columns 2 through 3
|
||||
console.log(subarr);
|
||||
/*
|
||||
[[2, 3],
|
||||
[8, 9]]
|
||||
*/</code></pre><h2>Usage in the web</h2><pre class="prettyprint source lang-bash"><code>npm run dist</code></pre><p>This will generate <code>dist/bci.js</code> and <code>dist/bci.min.js</code>. WebBCI methods can be accessed via the global object <em>bci</em>.</p>
|
||||
<p>OSC methods will not work in the web.</p>
|
||||
<h2>Documentation</h2><p>For a complete list of methods and documentation check out <a href="https://github.com/pwstegman/WebBCI/blob/dev/docs/api.md">docs/api.md</a></p>
|
||||
<h2>Examples</h2><p>More examples can be found in the <a href="https://github.com/pwstegman/WebBCI/tree/dev/examples">examples</a> directory</p></article>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -87,7 +160,7 @@ console.log(ws.getBandPower(length, psd, sampleRate, 'beta')); // 114</code></pr
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated on Tue Nov 21 2017 23:06:36 GMT-0500 (Eastern Standard Time)
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
|
||||
+40
-16
@@ -9,9 +9,13 @@
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/ionicons.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -23,7 +27,7 @@
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.LDA.html">LDA</a><ul class='methods'><li data-type='method'><a href="module-webbci.LDA.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.CSP.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#addData">addData</a></li><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#clear">clear</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.network.html">network</a><ul class='methods'><li data-type='method'><a href="module-webbci.network.html#.addEEGListener">addEEGListener</a></li></ul></li><li><a href="module-webbci.signal.html">signal</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.html">generate</a></li><li data-type='method'><a href="module-webbci.signal.html#.getBandPower">getBandPower</a></li><li data-type='method'><a href="module-webbci.signal.html#.getPSD">getPSD</a></li></ul></li></ul>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
@@ -38,17 +42,37 @@
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* A module for BCI design and EEG signal processing.
|
||||
* @module webbci
|
||||
*/
|
||||
|
||||
exports.signal = require('./lib/signal.js');
|
||||
exports.network = require('./lib/network.js');
|
||||
exports.LDA = require('./lib/lda.js');
|
||||
|
||||
// backwards compatibility
|
||||
exports.lda = exports.LDA;
|
||||
<pre class="prettyprint source linenums"><code>// This file was auto generated, changes will be overwritten
|
||||
// Created on Tue May 01 2018 19:28:54 GMT-0500 (Central Daylight Time)
|
||||
/** @module webbci */
|
||||
module.exports.cspLearn = require('./lib/math/cspLearn.js');
|
||||
module.exports.cspProject = require('./lib/math/cspProject.js');
|
||||
module.exports.features = require('./lib/math/features.js');
|
||||
module.exports.generateSignal = require('./lib/math/generateSignal.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.oscCollect = require('./lib/network/oscCollect.js');
|
||||
module.exports.oscHeaderScan = require('./lib/network/oscHeaderScan.js');
|
||||
module.exports.oscStream = require('./lib/network/oscStream.js');
|
||||
module.exports.wait = require('./lib/network/wait.js');
|
||||
module.exports.loadCSV = require('./lib/data/loadCSV.js');
|
||||
module.exports.partition = require('./lib/data/partition.js');
|
||||
module.exports.round = require('./lib/data/round.js');
|
||||
module.exports.saveCSV = require('./lib/data/saveCSV.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.csp = require('./lib/compat/csp.js');
|
||||
module.exports.lda = require('./lib/compat/lda.js');
|
||||
module.exports.network = require('./lib/compat/network.js');
|
||||
module.exports.signal = require('./lib/compat/signal.js');
|
||||
// Additional backwards compatibility
|
||||
exports.LDA = exports.lda;
|
||||
exports.csp = exports.signal.CSP;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
@@ -61,7 +85,7 @@ exports.csp = exports.signal.CSP;</code></pre>
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated on Tue Nov 21 2017 23:06:36 GMT-0500 (Eastern Standard Time)
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/csp.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/ionicons.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.LDA.html">LDA</a><ul class='methods'><li data-type='method'><a href="module-webbci.LDA.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.CSP.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#addData">addData</a></li><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#clear">clear</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.network.html">network</a><ul class='methods'><li data-type='method'><a href="module-webbci.network.html#.addEEGListener">addEEGListener</a></li></ul></li><li><a href="module-webbci.signal.html">signal</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.html">generate</a></li><li data-type='method'><a href="module-webbci.signal.html#.getBandPower">getBandPower</a></li><li data-type='method'><a href="module-webbci.signal.html#.getPSD">getPSD</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/csp.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var pwcsp = require('pw-csp');
|
||||
|
||||
/**
|
||||
* Creates a new CSP object
|
||||
* @name CSP
|
||||
* @memberof module:webbci.signal
|
||||
* @constructor
|
||||
* @param {number[][]} class1 - Data samples for class 1. Rows should be samples, columns should be signals.
|
||||
* @param {number[][]} class2 - Data samples for class 2. Rows should be samples, columns should be signals.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Projects data and reduces to given number of dimensions
|
||||
* @name project
|
||||
* @memberof module:webbci.signal.CSP
|
||||
* @function
|
||||
* @param {number[][]} data - Data points to be projected. Rows should be samples, columns should be signals.
|
||||
* @param {number} [dimensions] - Number of dimensions to be returned. Can range from 1 to number of signals. Defaults to number of signals.
|
||||
* @returns {number[][]} Projected data. Rows are samples, columns are dimensions sorted by descending importance.
|
||||
*/
|
||||
|
||||
module.exports = pwcsp;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated on Tue Nov 21 2017 23:06:36 GMT-0500 (Eastern Standard Time)
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,87 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/data/loadCSV.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/data/loadCSV.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var csv = require('csvtojson');
|
||||
|
||||
/**
|
||||
* Loads a CSV file into an array
|
||||
* @memberof module:webbci
|
||||
* @param {string} filePath - The path to the CSV file
|
||||
* @returns {Promise} A promise object representing the CSV data array
|
||||
*/
|
||||
function loadCSV(filePath) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var data = [];
|
||||
|
||||
csv({ noheader: true })
|
||||
.fromFile(filePath)
|
||||
.on('csv', (row) => {
|
||||
data.push(row.map(Number));
|
||||
})
|
||||
.on('done', (error) => {
|
||||
if (error) reject(error);
|
||||
else resolve(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = loadCSV;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,88 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/data/partition.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/data/partition.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Partitions an array into multiple arrays
|
||||
* Can be used to split data into training and testing sets
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array - The array to be partitioned
|
||||
* @param {...number[]} divisions - The size of each partition, each value should range from 0 to 1
|
||||
* @example
|
||||
* partition([1, 2, 3, 4], 0.25, 0.75); // returns [[1], [2, 3, 4]]
|
||||
* @returns {Array.<Array>} Array of subarrays which are the partitons
|
||||
*/
|
||||
function partition(array, ...divisions) {
|
||||
var parts = [];
|
||||
|
||||
var lastDivision = 0;
|
||||
var runningSum = 0;
|
||||
divisions.forEach(division => {
|
||||
runningSum += division;
|
||||
var end = Math.round(runningSum * array.length);
|
||||
parts.push(array.slice(lastDivision, end));
|
||||
lastDivision = end;
|
||||
});
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
module.exports = partition;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/data/round.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/data/round.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Rounds every value in an array to a set number of decimal places
|
||||
* @memberof module:webbci
|
||||
* @param {number[]} array
|
||||
* @param {number} places
|
||||
* @returns {number[]} The rounded array
|
||||
*/
|
||||
function round(array, places) {
|
||||
return helper(array);
|
||||
|
||||
function helper(array) {
|
||||
return array.map(item => {
|
||||
if (typeof item === 'number') {
|
||||
return parseFloat(item.toFixed(places));
|
||||
}
|
||||
|
||||
return helper(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = round;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,82 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/data/saveCSV.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/data/saveCSV.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var csv = require('fast-csv');
|
||||
|
||||
/**
|
||||
* Saves an array to a CSV file
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array
|
||||
* @param {string} filename
|
||||
* @returns {Promise} A promise object that resolves when the file has been saved. Does not currently reject on write error.
|
||||
*/
|
||||
function saveCSV(array, filename) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
csv
|
||||
.writeToPath(filename, array, { headers: false })
|
||||
.on("finish", function () {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = saveCSV;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,146 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/data/subscript.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/data/subscript.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Subscript an array with MATLAB-like syntax
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array - The array to be subscripted
|
||||
* @param {...string} params - Colon notation for which elements to include in each dimension
|
||||
* @returns {Array} The subscripted array
|
||||
* @example
|
||||
* var bci = require('webbci');
|
||||
* var arr = [3, 2, 4, 1, 5];
|
||||
* var subarr = bci.subscript(arr, '1:3');
|
||||
* console.log(subarr); // [3, 2, 4]
|
||||
* @example
|
||||
* var bci = require('webbci');
|
||||
* var arr = [
|
||||
* [1, 2, 3],
|
||||
* [4, 5, 6],
|
||||
* [7, 8, 9]
|
||||
* ];
|
||||
* var subarr = bci.subscript(arr, '1 3', '2:3'); // rows 1 and 3, columns 2 through 3
|
||||
* console.log(subarr); // [[2, 3], [8, 9]]
|
||||
*/
|
||||
function subscript(array, ...params) {
|
||||
return recur(array, ...params);
|
||||
|
||||
function recur(array, ...dims) {
|
||||
var arr = slice(array, dims.shift(), "matlab");
|
||||
|
||||
if (dims.length != 0) {
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
arr[i] = recur(arr[i], ...dims);
|
||||
}
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function slice(array, dims, format = "python") {
|
||||
dims = dims.split(" ");
|
||||
|
||||
var subs = [];
|
||||
|
||||
dims.forEach(dim => {
|
||||
var cp = dim.indexOf(':');
|
||||
var indexes = dim.split(':');
|
||||
|
||||
if (indexes.length > 2 || dim == '') {
|
||||
console.error("Invalid subscript string");
|
||||
return;
|
||||
}
|
||||
|
||||
if (indexes[1] == '') {
|
||||
indexes[1] = array.length;
|
||||
}
|
||||
|
||||
indexes = indexes.map(Number);
|
||||
|
||||
if (format == "matlab" || format == "mat") {
|
||||
// TODO: Implement 'end' keyword
|
||||
// This format is still in beta
|
||||
if (indexes[0] > 0) {
|
||||
indexes[0] -= 1;
|
||||
}
|
||||
|
||||
if (indexes[1] == -1) {
|
||||
indexes[1] = array.length;
|
||||
}
|
||||
|
||||
if (indexes[1] < 0) {
|
||||
indexes[1] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (indexes.length == 1) {
|
||||
indexes.push(indexes[0] + 1);
|
||||
}
|
||||
|
||||
subs.push(array.slice(...indexes));
|
||||
});
|
||||
|
||||
return [].concat(...subs);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = subscript;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/data/toFixed.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/data/toFixed.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Returns an array of numbers as strings rounded to the proper number of decimal places and padded with zeros as needed.
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array
|
||||
* @param {number} places
|
||||
* @returns {string[]} Array of string representations of numbers
|
||||
*/
|
||||
function toFixed(array, places) {
|
||||
return helper(array);
|
||||
|
||||
function helper(array) {
|
||||
return array.map(item => {
|
||||
if (typeof item === 'number') {
|
||||
return item.toFixed(places);
|
||||
}
|
||||
|
||||
return helper(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = toFixed;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,76 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/data/toTable.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/data/toTable.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var Table = require('easy-table');
|
||||
var toFixed = require('./toFixed.js');
|
||||
|
||||
/**
|
||||
* Returns an ASCII table representation of an array
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array
|
||||
* @returns {string} ASCII table
|
||||
*/
|
||||
function toTable(array) {
|
||||
return Table.print(array);
|
||||
}
|
||||
|
||||
module.exports = toTable;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,105 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/data/windowApply.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/data/windowApply.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Similar to JavaScript's map, but it applies a function to sub arrays instead of each element.
|
||||
* Each sub array, or window, starts at index 0 and has length 'length'
|
||||
* Each next window will be shifted 'step' elements from the first. The result of each function is stored in a returned array.
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array - The array of elements which will be windowed
|
||||
* @param {Function} func - The function to call on each window, the returned result is stored in a returned array
|
||||
* @param {number} length - The number of elements to include in each window
|
||||
* @param {number} step - The start of the window is incremented by this amount every iteration
|
||||
* @param {boolean} tail - If false, windows which begin near the end of the array which cannot reach length 'length' will be ignored
|
||||
* @returns {Array} An array containing the function result for each window
|
||||
* @example
|
||||
* var bci = require('webbci');
|
||||
* bci.windowApply([1, 2, 3, 4, 5], window => console.log(window), 3, 1);
|
||||
* // [1, 2, 3]
|
||||
* // [2, 3, 4]
|
||||
* // [3, 4, 5]
|
||||
* @example
|
||||
* var bci = require('webbci');
|
||||
* var sums = bci.windowApply([1, 2, 3, 4, 5], window => {
|
||||
* var sum = 0;
|
||||
* window.forEach(x => sum += x);
|
||||
* return sum;
|
||||
* }, 3, 1);
|
||||
* console.log(sums);
|
||||
* // [6, 9, 12]
|
||||
*/
|
||||
function windowApply(array, func, length, step = -1, tail = false) {
|
||||
if (step == -1) step = length;
|
||||
|
||||
var result = [];
|
||||
|
||||
for (var i = 0; i < array.length; i += step) {
|
||||
var window = array.slice(i, i + length);
|
||||
if (tail || window.length == length) {
|
||||
result.push(func(window));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = windowApply;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,80 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/lda.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/ionicons.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.LDA.html">LDA</a><ul class='methods'><li data-type='method'><a href="module-webbci.LDA.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.CSP.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#addData">addData</a></li><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#clear">clear</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.network.html">network</a><ul class='methods'><li data-type='method'><a href="module-webbci.network.html#.addEEGListener">addEEGListener</a></li></ul></li><li><a href="module-webbci.signal.html">signal</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.html">generate</a></li><li data-type='method'><a href="module-webbci.signal.html#.getBandPower">getBandPower</a></li><li data-type='method'><a href="module-webbci.signal.html#.getPSD">getPSD</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/lda.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var pwlda = require('pw-lda');
|
||||
|
||||
/**
|
||||
* An LDA object
|
||||
* @name LDA
|
||||
* @memberof module:webbci
|
||||
* @constructor
|
||||
* @param {number[][]} class1 - Data set for class 1, rows are samples, columns are variables
|
||||
* @param {number[][]} class2 - Data set for class 2, rows are samples, columns are variables
|
||||
*/
|
||||
|
||||
/**
|
||||
* Predict the class of an unknown data point
|
||||
* @name project
|
||||
* @memberof module:webbci.LDA
|
||||
* @function
|
||||
* @param {number[]} point - The data point to be classified.
|
||||
* @returns {number} value less than 0 if predicted to be in class 1, 0 if exactly inbetween, greater than 0 if class 2
|
||||
*/
|
||||
|
||||
module.exports = pwlda;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated on Tue Nov 21 2017 23:06:36 GMT-0500 (Eastern Standard Time)
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/math/cspLearn.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/math/cspLearn.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var numeric = require('numeric');
|
||||
var math = require('mathjs');
|
||||
var stat = require('pw-stat');
|
||||
|
||||
/**
|
||||
* Learn common spatial pattern for two datasets
|
||||
* @memberof module:webbci
|
||||
* @param {number[][]} class1 - Data samples for class 1. Rows should be samples, columns should be signals.
|
||||
* @param {number[][]} class2 - Data samples for class 2. Rows should be samples, columns should be signals.
|
||||
* @returns {Object} Learned CSP parameters
|
||||
*/
|
||||
function cspLearn(class1, class2) {
|
||||
var cov1 = stat.cov(class1);
|
||||
var cov2 = stat.cov(class2);
|
||||
var V = numeric.eig(math.multiply(math.inv(math.add(cov1, cov2)), cov1)).E.x;
|
||||
|
||||
return {
|
||||
V: V
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = cspLearn;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,98 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/math/cspProject.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/math/cspProject.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var math = require('mathjs');
|
||||
|
||||
/**
|
||||
* Projects data and reduces to given number of dimensions
|
||||
* @memberof module:webbci
|
||||
* @param {object} cspParams - CSP parameters computed using the cspLearn function
|
||||
* @param {number[][]} data - Data points to be projected. Rows should be samples, columns should be signals.
|
||||
* @param {number} [dimensions] - Number of dimensions to be returned. Can range from 1 to number of signals. Defaults to number of signals.
|
||||
* @returns {number[][]} Projected data. Rows are samples, columns are dimensions sorted by descending importance.
|
||||
*/
|
||||
function cspProject(cspParams, data, dimensions) {
|
||||
var projected = math.multiply(data, cspParams.V);
|
||||
|
||||
// Default number of dimensions is all of them, which is number of columns in data
|
||||
dimensions = typeof dimensions !== "undefined" ? dimensions : projected[0].length;
|
||||
|
||||
var reduced = [];
|
||||
|
||||
for (var r = 0; r < projected.length; r++) {
|
||||
reduced.push([]);
|
||||
|
||||
for (var i = 0; i < dimensions; i++) {
|
||||
// Start at left and right ends of matrix columns are work towards center
|
||||
if (i % 2 == 0) {
|
||||
var column = i / 2;
|
||||
} else {
|
||||
var column = projected[0].length - (i + 1) / 2;
|
||||
}
|
||||
reduced[r].push(projected[r][column]);
|
||||
}
|
||||
}
|
||||
|
||||
return reduced;
|
||||
}
|
||||
|
||||
module.exports = cspProject;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,120 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/math/features.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/math/features.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Feature extraction methods
|
||||
* @namespace features
|
||||
* @memberof module:webbci
|
||||
*/
|
||||
|
||||
var math = require('mathjs');
|
||||
var sbp = require('./signalBandPower.js');
|
||||
|
||||
/**
|
||||
* Computes the log of the variance along the specified dimension
|
||||
* @memberof module:webbci.features
|
||||
* @param {number[] | number[][]} window - The data
|
||||
* @param {string} [dimension] - If 'rows' or 'columns' passed, the features are calculated along that dimension
|
||||
*/
|
||||
function logvar(window, dimension = null) {
|
||||
if(dimension == null){
|
||||
return math.log(math.var(window));
|
||||
}
|
||||
|
||||
var possibleDimensions = ['rows', 'cols', 'columns'];
|
||||
if(possibleDimensions.indexOf(dimension) == -1){
|
||||
throw "Invalid dimension";
|
||||
}
|
||||
|
||||
if(dimension == 'cols' || dimension == 'columns'){
|
||||
window = math.transpose(window);
|
||||
}
|
||||
|
||||
return window.map(channel => math.log(math.var(channel)));
|
||||
}
|
||||
module.exports.logvar = logvar;
|
||||
|
||||
/**
|
||||
* Computes the root mean square along the specified dimension
|
||||
* @memberof module:webbci.features
|
||||
* @param {number[] | number[][]} window - The data
|
||||
* @param {string} [dimension] - If 'rows' or 'columns' passed, the features are calculated along that dimension
|
||||
*/
|
||||
function rootMeanSquare(window, dimension = null) {
|
||||
if(dimension == null){
|
||||
return math.sqrt(math.mean(math.square(window)));
|
||||
}
|
||||
|
||||
var possibleDimensions = ['rows', 'cols', 'columns'];
|
||||
if(possibleDimensions.indexOf(dimension) == -1){
|
||||
throw "Invalid dimension";
|
||||
}
|
||||
|
||||
if(dimension == 'cols' || dimension == 'columns'){
|
||||
window = math.transpose(window);
|
||||
}
|
||||
|
||||
return window.map(channel => math.sqrt(math.mean(math.square(channel))));
|
||||
}
|
||||
module.exports.rootMeanSquare = rootMeanSquare;
|
||||
|
||||
/* TODO: Add features with bands */</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,85 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/math/generateSignal.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/math/generateSignal.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var math = require('mathjs');
|
||||
|
||||
/**
|
||||
* Generate a signal with the given frequencies and their amplitudes.
|
||||
* @memberof module:webbci
|
||||
* @param {number[]} amplitudes - The amplitudes of each frequency.
|
||||
* @param {number[]} frequencies - The frequencies.
|
||||
* @param {number} sampleRate - Sample rate of the signal in Hz.
|
||||
* @param {number} duration - Duration of the signal in seconds.
|
||||
* @returns {number[]} The generated signal.
|
||||
*/
|
||||
function generateSignal(amplitudes, frequencies, sampleRate, duration) {
|
||||
var x = math.range(0, duration, 1 / sampleRate);
|
||||
|
||||
var signal = math.zeros(x.size()[0]);
|
||||
for (var i = 0; i < amplitudes.length; i++) {
|
||||
signal = math.add(signal, math.multiply(amplitudes[i], math.sin(math.multiply(2 * math.pi * frequencies[i], x))));
|
||||
}
|
||||
|
||||
return signal.toArray();
|
||||
}
|
||||
|
||||
module.exports = generateSignal;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,86 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/math/ldaLearn.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/math/ldaLearn.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var math = require('mathjs');
|
||||
var stat = require('pw-stat');
|
||||
|
||||
/**
|
||||
* Perform linear discriminant analysis between two datasets
|
||||
* @memberof module:webbci
|
||||
* @param {number[][]} class1 - Data set for class 1, rows are samples, columns are variables
|
||||
* @param {number[][]} class2 - Data set for class 2, rows are samples, columns are variables
|
||||
* @returns {Object} Computed LDA parameters
|
||||
*/
|
||||
function ldaLearn(class1, class2) {
|
||||
var mu1 = math.transpose(stat.mean(class1));
|
||||
var mu2 = math.transpose(stat.mean(class2));
|
||||
var pooledCov = math.add(stat.cov(class1), stat.cov(class2));
|
||||
var theta = math.multiply(math.inv(pooledCov), math.subtract(mu2, mu1));
|
||||
var b = math.multiply(-1, math.transpose(theta), math.add(mu1, mu2), 1 / 2);
|
||||
|
||||
return {
|
||||
theta: theta,
|
||||
b: b
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = ldaLearn;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/math/ldaProject.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/math/ldaProject.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var math = require('mathjs');
|
||||
|
||||
/**
|
||||
* Predict the class of an unknown data point.
|
||||
* @memberof module:webbci
|
||||
* @param {object} ldaParams - The parameters for the LDA, computed with the function ldaLearn
|
||||
* @param {number[]} point - The data point to be classified.
|
||||
* @returns {number} value less than 0 if predicted to be in class 1, 0 if exactly inbetween, greater than 0 if class 2
|
||||
*/
|
||||
function ldaProject(ldaParams, point) {
|
||||
return math.add(math.multiply(point, ldaParams.theta), ldaParams.b);
|
||||
}
|
||||
|
||||
module.exports = ldaProject;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,78 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/math/nextpow2.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/math/nextpow2.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Returns the ceil of the log2 of the absolute value of the passed number
|
||||
* @memberof module:webbci
|
||||
* @param {number} num
|
||||
* @example
|
||||
* nextpow2(8); // 3
|
||||
* nextpow2(9); // 4
|
||||
* nextpow2(16); // 4
|
||||
* nextpow2(30); // 5
|
||||
* nextpow2(0); // -Infinity
|
||||
*/
|
||||
function nextpow2(num){
|
||||
return Math.ceil(Math.log2(Math.abs(num)));
|
||||
}
|
||||
|
||||
module.exports = nextpow2;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,115 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/math/psd.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/math/psd.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var fft = require('fft.js');
|
||||
var nextpow2 = require('./nextpow2.js');
|
||||
|
||||
var fftCache = {};
|
||||
|
||||
/**
|
||||
* Compute the power spectral density of a given signal.
|
||||
* @memberof module:webbci
|
||||
* @param {number[]} signal - The 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 {boolean} [options.truncate=false] - If true, only the first half of the PSD array is returned
|
||||
* @returns {number[]} The PSD.
|
||||
*/
|
||||
function psd(signal, options) {
|
||||
var {fftSize, truncate} = Object.assign({
|
||||
fftSize: Math.pow(2, nextpow2(signal.length)),
|
||||
truncate: false
|
||||
}, options);
|
||||
|
||||
var f;
|
||||
if (fftCache.hasOwnProperty(fftSize)) {
|
||||
f = fftCache[fftSize];
|
||||
} else {
|
||||
f = new fft(fftSize);
|
||||
fftCache[fftSize] = f;
|
||||
}
|
||||
|
||||
// Zero pad signal to length if needed
|
||||
if (signal.length < fftSize) {
|
||||
signal = signal.concat(Array(fftSize - signal.length).fill(0));
|
||||
}
|
||||
|
||||
var freqs = f.createComplexArray();
|
||||
f.realTransform(freqs, signal);
|
||||
if(truncate){
|
||||
var powers = getPowers(freqs, freqs.length / 2);
|
||||
}else{
|
||||
var powers = getPowers(freqs, freqs.length);
|
||||
}
|
||||
|
||||
return powers;
|
||||
}
|
||||
|
||||
function getPowers(complexArray, length) {
|
||||
var magnitudes = [];
|
||||
for (var i = 0; i < length - 1; i += 2) {
|
||||
magnitudes.push(Math.sqrt(complexArray[i] * complexArray[i] + complexArray[i + 1] * complexArray[i + 1]));
|
||||
}
|
||||
return magnitudes;
|
||||
}
|
||||
|
||||
module.exports = psd;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,106 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/math/psdBandPower.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/math/psdBandPower.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var nextpow2 = require('./nextpow2.js');
|
||||
|
||||
/**
|
||||
* Compute the average power across a given frequency band given the PSD.
|
||||
* @memberof module:webbci
|
||||
* @param {number[]} psd - Power spectral density of the signal.
|
||||
* @param {number} sampleRate - The sample rate of the signal.
|
||||
* @param {(number[]|string)} - The frequency band provided as an array [frequencyStart, frequencyStop] or a
|
||||
* string <code>delta</code> (1-3 Hz), <code>theta</code> (4-7 Hz), <code>alpha</code> (8-12 Hz), <code>beta</code> (13-30 Hz), or <code>gamma</code> (31-50 Hz).
|
||||
* While string representations
|
||||
* allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in
|
||||
* future updates.
|
||||
* @param {number} [fftSize=Math.pow(2, bci.nextpow2(psd.length))] - Size of the fourier transform used to compute the PSD.
|
||||
* @returns {number} The average power in the frequency band.
|
||||
*/
|
||||
function psdBandPower(psd, sampleRate, band, fftSize=null) {
|
||||
if(fftSize === null){
|
||||
fftSize = Math.pow(2, nextpow2(psd.length));
|
||||
}
|
||||
|
||||
var bands = {
|
||||
// From Dan Szafir's "Pay Attention!", 2012
|
||||
'delta': [1, 3],
|
||||
'theta': [4, 7],
|
||||
'alpha': [8, 12],
|
||||
'beta': [13, 30],
|
||||
'gamma': [31, 50]
|
||||
};
|
||||
|
||||
if (typeof band === 'string' || band instanceof String) {
|
||||
band = bands[band];
|
||||
}
|
||||
|
||||
var startIndex = Math.floor(band[0] / sampleRate * fftSize);
|
||||
var endIndex = Math.min(Math.ceil(band[1] / sampleRate * fftSize), psd.length - 1);
|
||||
|
||||
var power = 0;
|
||||
for (var i = startIndex; i < endIndex + 1; i++) {
|
||||
power += psd[i];
|
||||
}
|
||||
return power / (endIndex - startIndex + 1);
|
||||
}
|
||||
|
||||
module.exports = psdBandPower;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,89 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/math/signalBandPower.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/math/signalBandPower.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var psd = require('./psd.js');
|
||||
var psdBandPower = require('./psdBandPower.js');
|
||||
var nextpow2 = require('./nextpow2.js');
|
||||
|
||||
/**
|
||||
* Compute the average power across a given frequency band in a signal.
|
||||
* @memberof module:webbci
|
||||
* @param {number[]} signal - The signal.
|
||||
* @param {number} sampleRate - The sample rate of the signal.
|
||||
* @param {(number[]|string)} - The frequency band provided as an array [frequencyStart, frequencyStop] or a
|
||||
* string <code>delta</code> (1-3 Hz), <code>theta</code> (4-7 Hz), <code>alpha</code> (8-12 Hz), <code>beta</code> (13-30 Hz), or <code>gamma</code> (31-50 Hz).
|
||||
* While string representations
|
||||
* allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in
|
||||
* future updates.
|
||||
* @param {number} [fftSize=Math.pow(2, bci.nextpow2(signal.length))] - Size of the fourier transform used to compute the PSD.
|
||||
* @returns {number} The average power in the frequency band.
|
||||
*/
|
||||
function signalBandPower(signal, sampleRate, band, fftSize = null) {
|
||||
if(fftSize === null){
|
||||
fftSize = Math.pow(2, nextpow2(signal.length));
|
||||
}
|
||||
|
||||
var p = psd(signal, {fftSize: fftSize});
|
||||
return psdBandPower(p, sampleRate, band, fftSize);
|
||||
}
|
||||
|
||||
module.exports = signalBandPower;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,86 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/network.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/ionicons.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.LDA.html">LDA</a><ul class='methods'><li data-type='method'><a href="module-webbci.LDA.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.CSP.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#addData">addData</a></li><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#clear">clear</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.network.html">network</a><ul class='methods'><li data-type='method'><a href="module-webbci.network.html#.addEEGListener">addEEGListener</a></li></ul></li><li><a href="module-webbci.signal.html">signal</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.html">generate</a></li><li data-type='method'><a href="module-webbci.signal.html#.getBandPower">getBandPower</a></li><li data-type='method'><a href="module-webbci.signal.html#.getPSD">getPSD</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/network.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* The network operations for webbci
|
||||
* @namespace network
|
||||
* @memberof module:webbci
|
||||
*/
|
||||
|
||||
var osc = require('node-osc');
|
||||
|
||||
/**
|
||||
* Calls callback when EEG data is received over the network.
|
||||
* @memberof module:webbci.network
|
||||
* @param {string} oscAddress - The address of the OSC server. For example: 127.0.0.1.
|
||||
* @param {number} oscPort - The port of the OSC server.
|
||||
* @param {string} eegAddress - The OSC header for the EEG data. For example: Person0/eeg.
|
||||
* @param {requestCallback} callback - Called when EEG data is received.
|
||||
*/
|
||||
function addEEGListener(oscAddress, oscPort, eegAddress, callback){
|
||||
var oscServer = new osc.Server(oscPort, oscAddress);
|
||||
|
||||
oscServer.on("message", function (msg, rinfo) {
|
||||
if(msg[0] == eegAddress){
|
||||
callback(msg.slice(1));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
exports.addEEGListener = addEEGListener;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated on Tue Nov 21 2017 23:06:36 GMT-0500 (Eastern Standard Time)
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,106 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/network/oscCollect.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/network/oscCollect.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* @memberof module:webbci.network
|
||||
*/
|
||||
|
||||
var osc = require('node-osc');
|
||||
|
||||
/**
|
||||
* Collect a set number of samples over OSC
|
||||
* @memberof module:webbci
|
||||
* @param {string} address - OSC address
|
||||
* @param {number} port - OSC port
|
||||
* @param {string} header - OSC header, can be found by scanning with oscHeaderScan if unknown
|
||||
* @param {number} samples - The number of samples to collect
|
||||
* @returns {Promise} Resolves with collected data
|
||||
*/
|
||||
function oscCollect(address, port, header, samples) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var data = [];
|
||||
|
||||
if (samples == 0) {
|
||||
resolve(data);
|
||||
return;
|
||||
}
|
||||
|
||||
var server = new osc.Server(port, address);
|
||||
|
||||
server.on("message", function (msg, rinfo) {
|
||||
if (msg[0] == header) {
|
||||
data.push(msg.slice(1));
|
||||
|
||||
if (data.length > samples) {
|
||||
server.kill();
|
||||
reject("More OSC samples seen than expected");
|
||||
}else if (data.length == samples) {
|
||||
server.kill();
|
||||
resolve(data);
|
||||
data = [];
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = oscCollect;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,98 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/network/oscHeaderScan.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/network/oscHeaderScan.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* @memberof module:webbci.network
|
||||
*/
|
||||
|
||||
var osc = require('node-osc');
|
||||
|
||||
/**
|
||||
* Scan for OSC headers on a port and address
|
||||
* @memberof module:webbci
|
||||
* @param {any} address - OSC address
|
||||
* @param {any} port - OSC port
|
||||
* @param {any} duration - Duration of scan in milliseconds
|
||||
* @returns {Promise} Resolves with an array of found headers
|
||||
*/
|
||||
function oscHeaderScan(address, port, duration) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var server = new osc.Server(port, address);
|
||||
|
||||
var headers = new Set();
|
||||
var start = Date.now();
|
||||
|
||||
server.on("message", function (msg, rinfo) {
|
||||
var header = msg[0];
|
||||
headers.add(header);
|
||||
|
||||
var time = Date.now();
|
||||
|
||||
if (time - start >= duration) {
|
||||
server.kill();
|
||||
resolve([...headers]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = oscHeaderScan;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,115 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/network/oscStream.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/network/oscStream.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>var osc = require('node-osc');
|
||||
|
||||
/**
|
||||
* Listen for messages over OSC
|
||||
* @memberof module:webbci
|
||||
*/
|
||||
class oscStream {
|
||||
/**
|
||||
* @constructor
|
||||
* @param {string} address - Address to listen on
|
||||
* @param {number} port - Port to listen on
|
||||
*/
|
||||
constructor(address, port) {
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
this.header = header;
|
||||
this.onFuncs = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Start listening for OSC messages
|
||||
*/
|
||||
start() {
|
||||
this.server = new osc.Server(this.port, this.address);
|
||||
|
||||
this.server.on("message", function (msg, rinfo) {
|
||||
var header = msg[0];
|
||||
var data = msg.slice(1);
|
||||
|
||||
if (header in this.onFuncs) {
|
||||
this.onFuncs(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop listening for OSC messages
|
||||
*/
|
||||
stop() {
|
||||
this.server.kill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call a callback function when data containing a specified OSC header is seen
|
||||
* @param {string} header - The OSC header
|
||||
* @param {requestCallback} callback - Called with the OSC data passed as the parameter
|
||||
*/
|
||||
on(header, callback) {
|
||||
this.onFuncs[header] = callback;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = oscStream;</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,70 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/network/wait.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/network/wait.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>// Use setTimeout as a promise
|
||||
/**
|
||||
* @memberof module:webbci
|
||||
* @function
|
||||
* @name wait
|
||||
* @param {number} ms - Number of milliseconds to wait
|
||||
*/
|
||||
module.exports = ms => new Promise(resolve => setTimeout(resolve, ms));</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,231 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lib/signal.js - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/ionicons.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.LDA.html">LDA</a><ul class='methods'><li data-type='method'><a href="module-webbci.LDA.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.CSP.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#addData">addData</a></li><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#clear">clear</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.network.html">network</a><ul class='methods'><li data-type='method'><a href="module-webbci.network.html#.addEEGListener">addEEGListener</a></li></ul></li><li><a href="module-webbci.signal.html">signal</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.html">generate</a></li><li data-type='method'><a href="module-webbci.signal.html#.getBandPower">getBandPower</a></li><li data-type='method'><a href="module-webbci.signal.html#.getPSD">getPSD</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">lib/signal.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Signal processing operations
|
||||
* @namespace signal
|
||||
* @memberof module:webbci
|
||||
*/
|
||||
|
||||
var math = require('mathjs');
|
||||
var fft = require('fft.js');
|
||||
|
||||
var fftCache = {};
|
||||
|
||||
/**
|
||||
* Compute the power spectral density of a given signal.
|
||||
* @memberof module:webbci.signal
|
||||
* @param {number} size - Size of the fourier transform to be used. Should be a power of 2.
|
||||
* @param {number[]} signal - The signal.
|
||||
* @returns {number[]} The PSD.
|
||||
*/
|
||||
function getPSD(size, signal) {
|
||||
if (fftCache.hasOwnProperty(size)) {
|
||||
f = fftCache[size];
|
||||
} else {
|
||||
f = new fft(size);
|
||||
fftCache[size] = f;
|
||||
}
|
||||
|
||||
var freqs = f.createComplexArray();
|
||||
f.realTransform(freqs, signal);
|
||||
var powers = getPowers(size, freqs);
|
||||
|
||||
return powers;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local helper function
|
||||
* Return an array containing the magnitude of the first half of complex numbers
|
||||
* in the complex Array
|
||||
*/
|
||||
function getPowers(size, complexArray) {
|
||||
var magnitudes = [];
|
||||
for (var i = 0; i < size; i += 2) {
|
||||
magnitudes.push(Math.sqrt(complexArray[i] * complexArray[i] + complexArray[i + 1] * complexArray[i + 1]));
|
||||
}
|
||||
return magnitudes;
|
||||
}
|
||||
|
||||
/*
|
||||
* String representation of common frequency bands
|
||||
*/
|
||||
var bands = {
|
||||
// From Dan Szafir's "Pay Attention!", 2012
|
||||
'delta': [1, 3],
|
||||
'theta': [4, 7],
|
||||
'alpha': [8, 12],
|
||||
'beta': [13, 30],
|
||||
'gamma': [31, 50]
|
||||
};
|
||||
|
||||
/**
|
||||
* Compute the average power across a given frequency band given the PSD.
|
||||
* @memberof module:webbci.signal
|
||||
* @param {number} size - Size of the fourier transform used to compute the PSD.
|
||||
* @param {number[]} psd - Power spectral density of the signal.
|
||||
* @param {number} sampleRate - The sample rate of the signal.
|
||||
* @param {(number[]|string)} - The frequency band provided as an array [frequencyStart, frequencyStop] or a
|
||||
* string <code>delta</code> (1-3 Hz), <code>theta</code> (4-7 Hz), <code>alpha</code> (8-12 Hz), <code>beta</code> (13-30 Hz), or <code>gamma</code> (31-50 Hz).
|
||||
* While string representations
|
||||
* allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in
|
||||
* future updates.
|
||||
* @returns {number} The average power in the frequency band.
|
||||
*/
|
||||
function getBandPower(size, psd, sampleRate, band) {
|
||||
// Allow selecting of a band by name
|
||||
if (typeof band === 'string' || band instanceof String) {
|
||||
band = bands[band];
|
||||
}
|
||||
|
||||
var startIndex = Math.ceil(band[0] / sampleRate * size);
|
||||
var endIndex = Math.floor(band[1] / sampleRate * size);
|
||||
var power = 0;
|
||||
for (var i = startIndex; i < endIndex + 1; i++) {
|
||||
power += psd[i];
|
||||
}
|
||||
return power / (endIndex - startIndex + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local helper function for debugging
|
||||
* Prints a complex array to the console, where the array elements are alternating real and imaginary components.
|
||||
* @param {number[]} complexArray - The array to be displayed. Should be of form [real1, imag1, real2, imag2, ..., realn, imagn].
|
||||
* @param {number} [precision] - The number of decimal places to be shown. Defaults to 5.
|
||||
*/
|
||||
function displayComplex(complexArray, precision) {
|
||||
if (precision === undefined) {
|
||||
precision = 5;
|
||||
}
|
||||
var p = Math.pow(10, precision);
|
||||
|
||||
for (var i = 0; i < complexArray.length; i += 2) {
|
||||
console.log(Math.round(complexArray[i] * p) / p + '+' + Math.round(complexArray[i + 1] * p) / p + 'i');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new EEGWindow object.
|
||||
* @memberof module:webbci.signal
|
||||
* @constructor
|
||||
* @param {number} size - The number of samples to be stored before callback is called.
|
||||
* @param {number} numChannels - The number of channels in each sample.
|
||||
* @param {requestCallback} callback - Called when the EEGWindow has a number of samples equal to size.
|
||||
* An array of dimensions channels x samples is passed to the callback function.
|
||||
*/
|
||||
function EEGWindow(size, numChannels, callback) {
|
||||
this.size = size;
|
||||
this.length = 0;
|
||||
this.callback = callback;
|
||||
this.channels = [];
|
||||
for (var i = 0; i < numChannels; i++) {
|
||||
this.channels.push([]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a data sample to the EEGWindow.
|
||||
* @param {number[]} - The data sample to be added. Should be of length 'channels'
|
||||
*/
|
||||
EEGWindow.prototype.addData = function (data) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
this.channels[i].push(data[i]);
|
||||
}
|
||||
this.length += 1;
|
||||
if (this.length >= this.size) {
|
||||
this.callback(this.channels);
|
||||
this.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the EEGWindow and clear all data from it.
|
||||
*/
|
||||
EEGWindow.prototype.clear = function () {
|
||||
this.length = 0;
|
||||
for (var i = 0; i < this.channels.length; i++) {
|
||||
this.channels[i] = [];
|
||||
}
|
||||
}
|
||||
|
||||
exports.EEGWindow = EEGWindow;
|
||||
|
||||
/**
|
||||
* Generate a signal.
|
||||
* @alias generate
|
||||
* @memberof module:webbci.signal
|
||||
* @param {number[]} amplitudes - The amplitudes of each frequency in the signal.
|
||||
* @param {number[]} frequencies - The frequencies to be included in the signal.
|
||||
* @param {number} sampleRate - The sample rate of the signal in Hz.
|
||||
* @param {number} duration - The duration of the signal in seconds.
|
||||
* @returns {number[]} The generated signal. Equals the summation of <code>amplitudes[i] * sin(2 * pi * frequencies[i] * t)</code>.
|
||||
*/
|
||||
exports.generate = function (amplitudes, frequencies, sampleRate, duration) {
|
||||
var x = math.range(0, duration, 1 / sampleRate);
|
||||
|
||||
var signal = math.zeros(x.size()[0]);
|
||||
for (var i = 0; i < amplitudes.length; i++) {
|
||||
signal = math.add(signal, math.multiply(amplitudes[i], math.sin(math.multiply(2 * math.pi * frequencies[i], x))));
|
||||
}
|
||||
|
||||
return signal.toArray();
|
||||
}
|
||||
|
||||
exports.getPSD = getPSD;
|
||||
exports.getBandPower = getBandPower;
|
||||
exports.CSP = require('./csp.js');</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated on Tue Nov 21 2017 23:06:36 GMT-0500 (Eastern Standard Time)
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,403 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>LDA - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/ionicons.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.LDA.html">LDA</a><ul class='methods'><li data-type='method'><a href="module-webbci.LDA.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.CSP.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#addData">addData</a></li><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#clear">clear</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.network.html">network</a><ul class='methods'><li data-type='method'><a href="module-webbci.network.html#.addEEGListener">addEEGListener</a></li></ul></li><li><a href="module-webbci.signal.html">signal</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.html">generate</a></li><li data-type='method'><a href="module-webbci.signal.html#.getBandPower">getBandPower</a></li><li data-type='method'><a href="module-webbci.signal.html#.getPSD">getPSD</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">LDA</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<header>
|
||||
|
||||
<h2>
|
||||
<span class="ancestors"><a href="module-webbci.html">webbci</a>.</span>
|
||||
|
||||
LDA
|
||||
</h2>
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div class="container-overview">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="LDA"><span class="type-signature"></span>new LDA<span class="signature">(class1, class2)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
An LDA object
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>class1</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<Array.<number>></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">Data set for class 1, rows are samples, columns are variables</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>class2</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<Array.<number>></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">Data set for class 2, rows are samples, columns are variables</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_lda.js.html">lib/lda.js</a>, <a href="lib_lda.js.html#line3">line 3</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".project"><span class="type-signature">(static) </span>project<span class="signature">(point)</span><span class="type-signature"> → {number}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Predict the class of an unknown data point
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>point</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<number></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The data point to be classified.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_lda.js.html">lib/lda.js</a>, <a href="lib_lda.js.html#line12">line 12</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
<div class="param-desc">
|
||||
value less than 0 if predicted to be in class 1, 0 if exactly inbetween, greater than 0 if class 2
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<dl class="param-type">
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated on Tue Nov 21 2017 23:06:36 GMT-0500 (Eastern Standard Time)
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,533 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>features - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">features</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<header>
|
||||
|
||||
<h2>
|
||||
<span class="ancestors"><a href="module-webbci.html">webbci</a>.</span>
|
||||
|
||||
features
|
||||
</h2>
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div class="container-overview">
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_math_features.js.html">lib/math/features.js</a>, <a href="lib_math_features.js.html#line1">line 1</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description"><p>Feature extraction methods</p></div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".logvar"><span class="type-signature">(static) </span>logvar<span class="signature">(window, dimension<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_math_features.js.html">lib/math/features.js</a>, <a href="lib_math_features.js.html#line16">line 16</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
<p>Computes the log of the variance along the specified dimension</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
<th>Attributes</th>
|
||||
|
||||
|
||||
|
||||
<th>Default</th>
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>window</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<number></span>
|
||||
|
|
||||
|
||||
<span class="param-type">Array.<Array.<number>></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="attributes">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td class="default">
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="description last"><p>The data</p></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>dimension</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="attributes">
|
||||
|
||||
<optional><br>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td class="default">
|
||||
|
||||
<code>null</code>
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="description last"><p>If 'rows' or 'columns' passed, the features are calculated along that dimension</p></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".rootMeanSquare"><span class="type-signature">(static) </span>rootMeanSquare<span class="signature">(window, dimension<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_math_features.js.html">lib/math/features.js</a>, <a href="lib_math_features.js.html#line40">line 40</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
<p>Computes the root mean square along the specified dimension</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
<th>Attributes</th>
|
||||
|
||||
|
||||
|
||||
<th>Default</th>
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>window</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<number></span>
|
||||
|
|
||||
|
||||
<span class="param-type">Array.<Array.<number>></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="attributes">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td class="default">
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="description last"><p>The data</p></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>dimension</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="attributes">
|
||||
|
||||
<optional><br>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<td class="default">
|
||||
|
||||
<code>null</code>
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="description last"><p>If 'rows' or 'columns' passed, the features are calculated along that dimension</p></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+4204
-183
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,346 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>network - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/ionicons.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.LDA.html">LDA</a><ul class='methods'><li data-type='method'><a href="module-webbci.LDA.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.CSP.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#addData">addData</a></li><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#clear">clear</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.network.html">network</a><ul class='methods'><li data-type='method'><a href="module-webbci.network.html#.addEEGListener">addEEGListener</a></li></ul></li><li><a href="module-webbci.signal.html">signal</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.html">generate</a></li><li data-type='method'><a href="module-webbci.signal.html#.getBandPower">getBandPower</a></li><li data-type='method'><a href="module-webbci.signal.html#.getPSD">getPSD</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">network</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<header>
|
||||
|
||||
<h2>
|
||||
<span class="ancestors"><a href="module-webbci.html">webbci</a>.</span>
|
||||
|
||||
network
|
||||
</h2>
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div class="container-overview">
|
||||
|
||||
|
||||
<div class="description">The network operations for webbci</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_network.js.html">lib/network.js</a>, <a href="lib_network.js.html#line1">line 1</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".addEEGListener"><span class="type-signature">(static) </span>addEEGListener<span class="signature">(oscAddress, oscPort, eegAddress, callback)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Calls callback when EEG data is received over the network.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>oscAddress</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The address of the OSC server. For example: 127.0.0.1.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>oscPort</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The port of the OSC server.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>eegAddress</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The OSC header for the EEG data. For example: Person0/eeg.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>callback</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">requestCallback</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">Called when EEG data is received.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_network.js.html">lib/network.js</a>, <a href="lib_network.js.html#line17">line 17</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated on Tue Nov 21 2017 23:06:36 GMT-0500 (Eastern Standard Time)
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,580 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>oscStream - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||
<style>
|
||||
li > code {
|
||||
min-height: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.oscStream.html">oscStream</a><ul class='methods'><li data-type='method'><a href="module-webbci.oscStream.html#on">on</a></li><li data-type='method'><a href="module-webbci.oscStream.html#start">start</a></li><li data-type='method'><a href="module-webbci.oscStream.html#stop">stop</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a><ul class='methods'><li data-type='method'><a href="module-webbci.html#.cspLearn">cspLearn</a></li><li data-type='method'><a href="module-webbci.html#.cspProject">cspProject</a></li><li data-type='method'><a href="module-webbci.html#.generateSignal">generateSignal</a></li><li data-type='method'><a href="module-webbci.html#.ldaLearn">ldaLearn</a></li><li data-type='method'><a href="module-webbci.html#.ldaProject">ldaProject</a></li><li data-type='method'><a href="module-webbci.html#.loadCSV">loadCSV</a></li><li data-type='method'><a href="module-webbci.html#.nextpow2">nextpow2</a></li><li data-type='method'><a href="module-webbci.html#.oscCollect">oscCollect</a></li><li data-type='method'><a href="module-webbci.html#.oscHeaderScan">oscHeaderScan</a></li><li data-type='method'><a href="module-webbci.html#.partition">partition</a></li><li data-type='method'><a href="module-webbci.html#.psd">psd</a></li><li data-type='method'><a href="module-webbci.html#.psdBandPower">psdBandPower</a></li><li data-type='method'><a href="module-webbci.html#.round">round</a></li><li data-type='method'><a href="module-webbci.html#.saveCSV">saveCSV</a></li><li data-type='method'><a href="module-webbci.html#.signalBandPower">signalBandPower</a></li><li data-type='method'><a href="module-webbci.html#.subscript">subscript</a></li><li data-type='method'><a href="module-webbci.html#.toFixed">toFixed</a></li><li data-type='method'><a href="module-webbci.html#.toTable">toTable</a></li><li data-type='method'><a href="module-webbci.html#.wait">wait</a></li><li data-type='method'><a href="module-webbci.html#.windowApply">windowApply</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.features.html">features</a><ul class='methods'><li data-type='method'><a href="module-webbci.features.html#.logvar">logvar</a></li><li data-type='method'><a href="module-webbci.features.html#.rootMeanSquare">rootMeanSquare</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">oscStream</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<header>
|
||||
|
||||
<h2>
|
||||
<span class="ancestors"><a href="module-webbci.html">webbci</a>.</span>
|
||||
|
||||
oscStream
|
||||
</h2>
|
||||
|
||||
<div class="class-description"><p>Listen for messages over OSC</p></div>
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div class="container-overview">
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>Constructor</h2>
|
||||
|
||||
|
||||
<h4 class="name" id="oscStream"><span class="type-signature"></span>new oscStream<span class="signature">(address, port)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_network_oscStream.js.html">lib/network/oscStream.js</a>, <a href="lib_network_oscStream.js.html#line7">line 7</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>address</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>Address to listen on</p></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>port</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>Port to listen on</p></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="on"><span class="type-signature"></span>on<span class="signature">(header, callback)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_network_oscStream.js.html">lib/network/oscStream.js</a>, <a href="lib_network_oscStream.js.html#line48">line 48</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
<p>Call a callback function when data containing a specified OSC header is seen</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>header</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>The OSC header</p></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>callback</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">requestCallback</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>Called with the OSC data passed as the parameter</p></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="start"><span class="type-signature"></span>start<span class="signature">()</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_network_oscStream.js.html">lib/network/oscStream.js</a>, <a href="lib_network_oscStream.js.html#line23">line 23</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
<p>Start listening for OSC messages</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="stop"><span class="type-signature"></span>stop<span class="signature">()</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_network_oscStream.js.html">lib/network/oscStream.js</a>, <a href="lib_network_oscStream.js.html#line39">line 39</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
<p>Stop listening for OSC messages</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 01 2018 19:29:02 GMT-0500 (Central Daylight Time) using a modified version of the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,446 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CSP - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/ionicons.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.LDA.html">LDA</a><ul class='methods'><li data-type='method'><a href="module-webbci.LDA.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.CSP.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#addData">addData</a></li><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#clear">clear</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.network.html">network</a><ul class='methods'><li data-type='method'><a href="module-webbci.network.html#.addEEGListener">addEEGListener</a></li></ul></li><li><a href="module-webbci.signal.html">signal</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.html">generate</a></li><li data-type='method'><a href="module-webbci.signal.html#.getBandPower">getBandPower</a></li><li data-type='method'><a href="module-webbci.signal.html#.getPSD">getPSD</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">CSP</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<header>
|
||||
|
||||
<h2>
|
||||
<span class="ancestors"><a href="module-webbci.html">webbci</a><a href="module-webbci.signal.html">.signal</a>.</span>
|
||||
|
||||
CSP
|
||||
</h2>
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div class="container-overview">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="CSP"><span class="type-signature"></span>new CSP<span class="signature">(class1, class2)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Creates a new CSP object
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>class1</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<Array.<number>></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">Data samples for class 1. Rows should be samples, columns should be signals.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>class2</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<Array.<number>></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">Data samples for class 2. Rows should be samples, columns should be signals.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_csp.js.html">lib/csp.js</a>, <a href="lib_csp.js.html#line3">line 3</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".project"><span class="type-signature">(static) </span>project<span class="signature">(data, dimensions<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array.<Array.<number>>}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Projects data and reduces to given number of dimensions
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
<th>Attributes</th>
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>data</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<Array.<number>></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="attributes">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">Data points to be projected. Rows should be samples, columns should be signals.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>dimensions</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="attributes">
|
||||
|
||||
<optional><br>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">Number of dimensions to be returned. Can range from 1 to number of signals. Defaults to number of signals.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_csp.js.html">lib/csp.js</a>, <a href="lib_csp.js.html#line12">line 12</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
<div class="param-desc">
|
||||
Projected data. Rows are samples, columns are dimensions sorted by descending importance.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<dl class="param-type">
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Array.<Array.<number>></span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated on Tue Nov 21 2017 23:06:36 GMT-0500 (Eastern Standard Time)
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,486 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>EEGWindow - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/ionicons.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.LDA.html">LDA</a><ul class='methods'><li data-type='method'><a href="module-webbci.LDA.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.CSP.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#addData">addData</a></li><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#clear">clear</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.network.html">network</a><ul class='methods'><li data-type='method'><a href="module-webbci.network.html#.addEEGListener">addEEGListener</a></li></ul></li><li><a href="module-webbci.signal.html">signal</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.html">generate</a></li><li data-type='method'><a href="module-webbci.signal.html#.getBandPower">getBandPower</a></li><li data-type='method'><a href="module-webbci.signal.html#.getPSD">getPSD</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">EEGWindow</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<header>
|
||||
|
||||
<h2>
|
||||
<span class="ancestors"><a href="module-webbci.html">webbci</a><a href="module-webbci.signal.html">.signal</a>.</span>
|
||||
|
||||
EEGWindow
|
||||
</h2>
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div class="container-overview">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="EEGWindow"><span class="type-signature"></span>new EEGWindow<span class="signature">(size, numChannels, callback)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Create a new EEGWindow object.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>size</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The number of samples to be stored before callback is called.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>numChannels</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The number of channels in each sample.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>callback</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">requestCallback</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">Called when the EEGWindow has a number of samples equal to size.
|
||||
An array of dimensions channels x samples is passed to the callback function.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_signal.js.html">lib/signal.js</a>, <a href="lib_signal.js.html#line113">line 113</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="addData"><span class="type-signature"></span>addData<span class="signature">(data)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Adds a data sample to the EEGWindow.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>data</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<number></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The data sample to be added. Should be of length 'channels'</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_signal.js.html">lib/signal.js</a>, <a href="lib_signal.js.html#line127">line 127</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="clear"><span class="type-signature"></span>clear<span class="signature">()</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Reset the EEGWindow and clear all data from it.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_signal.js.html">lib/signal.js</a>, <a href="lib_signal.js.html#line141">line 141</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated on Tue Nov 21 2017 23:06:36 GMT-0500 (Eastern Standard Time)
|
||||
</footer>
|
||||
|
||||
<script>prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
@@ -1,779 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>signal - Documentation</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/ionicons.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||
<label for="nav-trigger" class="navicon-button x">
|
||||
<div class="navicon"></div>
|
||||
</label>
|
||||
|
||||
<label for="nav-trigger" class="overlay"></label>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module-webbci.LDA.html">LDA</a><ul class='methods'><li data-type='method'><a href="module-webbci.LDA.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.CSP.html#.project">project</a></li></ul></li><li><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#addData">addData</a></li><li data-type='method'><a href="module-webbci.signal.EEGWindow.html#clear">clear</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-webbci.html">webbci</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-webbci.network.html">network</a><ul class='methods'><li data-type='method'><a href="module-webbci.network.html#.addEEGListener">addEEGListener</a></li></ul></li><li><a href="module-webbci.signal.html">signal</a><ul class='methods'><li data-type='method'><a href="module-webbci.signal.html">generate</a></li><li data-type='method'><a href="module-webbci.signal.html#.getBandPower">getBandPower</a></li><li data-type='method'><a href="module-webbci.signal.html#.getPSD">getPSD</a></li></ul></li></ul>
|
||||
</nav>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">signal</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<header>
|
||||
|
||||
<h2>
|
||||
<span class="ancestors"><a href="module-webbci.html">webbci</a>.</span>
|
||||
|
||||
signal
|
||||
</h2>
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div class="container-overview">
|
||||
|
||||
|
||||
<div class="description">Signal processing operations</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_signal.js.html">lib/signal.js</a>, <a href="lib_signal.js.html#line1">line 1</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Classes</h3>
|
||||
|
||||
<dl>
|
||||
<dt><a href="module-webbci.signal.CSP.html">CSP</a></dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt><a href="module-webbci.signal.EEGWindow.html">EEGWindow</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="generate"><span class="type-signature"></span>generate<span class="signature">(amplitudes, frequencies, sampleRate, duration)</span><span class="type-signature"> → {Array.<number>}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Generate a signal.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>amplitudes</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<number></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The amplitudes of each frequency in the signal.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>frequencies</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<number></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The frequencies to be included in the signal.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>sampleRate</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The sample rate of the signal in Hz.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>duration</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The duration of the signal in seconds.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_signal.js.html">lib/signal.js</a>, <a href="lib_signal.js.html#line160">line 160</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
<div class="param-desc">
|
||||
The generated signal. Equals the summation of <code>amplitudes[i] * sin(2 * pi * frequencies[i] * t)</code>.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<dl class="param-type">
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Array.<number></span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".getBandPower"><span class="type-signature">(static) </span>getBandPower<span class="signature">(size, psd, sampleRate, band)</span><span class="type-signature"> → {number}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Compute the average power across a given frequency band given the PSD.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>size</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">Size of the fourier transform used to compute the PSD.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>psd</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<number></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">Power spectral density of the signal.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>sampleRate</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The sample rate of the signal.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>band</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<number></span>
|
||||
|
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The frequency band provided as an array [frequencyStart, frequencyStop] or a
|
||||
string <code>delta</code> (1-3 Hz), <code>theta</code> (4-7 Hz), <code>alpha</code> (8-12 Hz), <code>beta</code> (13-30 Hz), or <code>gamma</code> (31-50 Hz).
|
||||
While string representations
|
||||
allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in
|
||||
future updates.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_signal.js.html">lib/signal.js</a>, <a href="lib_signal.js.html#line72">line 72</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
<div class="param-desc">
|
||||
The average power in the frequency band.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<dl class="param-type">
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id=".getPSD"><span class="type-signature">(static) </span>getPSD<span class="signature">(size, signal)</span><span class="type-signature"> → {Array.<number>}</span></h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">
|
||||
Compute the power spectral density of a given signal.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>size</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">number</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">Size of the fourier transform to be used. Should be a power of 2.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>signal</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">Array.<number></span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The signal.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="lib_signal.js.html">lib/signal.js</a>, <a href="lib_signal.js.html#line19">line 19</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
<div class="param-desc">
|
||||
The PSD.
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<dl class="param-type">
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Array.<number></span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated on Tue Nov 21 2017 23:06:36 GMT-0500 (Eastern Standard Time)
|
||||
</footer>
|
||||
|
||||
externo
-11
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
@@ -1,12 +1,4 @@
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
src: url('../fonts/Lato-Regular.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Source Code Pro';
|
||||
src: url('../fonts/SourceCodePro-Regular.ttf') format('truetype');
|
||||
}
|
||||
@import url(https://fonts.googleapis.com/css?family=Montserrat:400,700);
|
||||
|
||||
* {
|
||||
box-sizing: border-box
|
||||
@@ -21,21 +13,28 @@ body {
|
||||
color: #4d4e53;
|
||||
background-color: white;
|
||||
margin: 0 auto;
|
||||
padding: 0 0;
|
||||
|
||||
font-family: 'Lato';
|
||||
padding: 0 20px;
|
||||
font-family: 'Helvetica Neue', Helvetica, sans-serif;
|
||||
font-size: 16px;
|
||||
line-height: 160%;
|
||||
}
|
||||
|
||||
a,
|
||||
a:active {
|
||||
color: #7F3416;
|
||||
color: #606;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
article a {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
article a:hover, article a:active {
|
||||
border-bottom-color: #222;
|
||||
}
|
||||
|
||||
p, ul, ol, blockquote {
|
||||
@@ -43,7 +42,7 @@ p, ul, ol, blockquote {
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: 'Lato';
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
@@ -79,6 +78,24 @@ h4 {
|
||||
color: #4d4e53;
|
||||
}
|
||||
|
||||
h4.name {
|
||||
color: #fff;
|
||||
background: #6d426d;
|
||||
box-shadow: 0 .25em .5em #d3d3d3;
|
||||
border-top: 1px solid #d3d3d3;
|
||||
border-bottom: 1px solid #d3d3d3;
|
||||
margin: 1.5em 0 0.5em;
|
||||
padding: .75em 0 .75em 10px;
|
||||
}
|
||||
|
||||
h4.name a {
|
||||
color: #fc83ff;
|
||||
}
|
||||
|
||||
h4.name a:hover {
|
||||
border-bottom-color: #fc83ff;
|
||||
}
|
||||
|
||||
h5, .container-overview .subsection-title {
|
||||
font-size: 120%;
|
||||
letter-spacing: -0.01em;
|
||||
@@ -93,11 +110,9 @@ h6 {
|
||||
}
|
||||
|
||||
tt, code, kbd, samp {
|
||||
font-family: 'Source Code Pro';
|
||||
font-size: 80%;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||
background: #f4f4f4;
|
||||
padding: 1px 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.class-description {
|
||||
@@ -112,9 +127,9 @@ tt, code, kbd, samp {
|
||||
}
|
||||
|
||||
#main {
|
||||
margin-left: 250px;
|
||||
float: right;
|
||||
min-width: 360px;
|
||||
width: calc(100% - 250px);
|
||||
width: calc(100% - 240px);
|
||||
}
|
||||
|
||||
header {
|
||||
@@ -124,7 +139,7 @@ header {
|
||||
section {
|
||||
display: block;
|
||||
background-color: #fff;
|
||||
padding: 0 30px;
|
||||
padding: 0 0 0 30px;
|
||||
}
|
||||
|
||||
.variation {
|
||||
@@ -133,53 +148,35 @@ section {
|
||||
|
||||
.signature-attributes {
|
||||
font-size: 60%;
|
||||
color: #aaa;
|
||||
color: #eee;
|
||||
font-style: italic;
|
||||
font-weight: lighter;
|
||||
}
|
||||
|
||||
nav {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
float: left;
|
||||
display: block;
|
||||
width: 250px;
|
||||
background: #fff;
|
||||
overflow: auto;
|
||||
position: fixed;
|
||||
height: 100%;
|
||||
background: rgb(51,51,51);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
nav h2 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #ff6429;
|
||||
}
|
||||
|
||||
nav > h2 > a {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: #fff !important;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
padding: 10px 10px 6px 10px;
|
||||
}
|
||||
|
||||
nav h2,
|
||||
nav h3 {
|
||||
margin: 0;
|
||||
margin-top: 12px;
|
||||
font-size: 13px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
font-weight: 700;
|
||||
line-height: 24px;
|
||||
color: #fff !important;
|
||||
margin: 15px 0 10px;
|
||||
padding: 0;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
nav h3 {
|
||||
padding: 10px 10px 6px 10px;
|
||||
}
|
||||
nav ul {
|
||||
font-family: 'Lato';
|
||||
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
|
||||
font-size: 100%;
|
||||
line-height: 17px;
|
||||
padding: 0;
|
||||
@@ -187,36 +184,36 @@ nav ul {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
nav ul a {
|
||||
font-family: 'Lato';
|
||||
nav ul a,
|
||||
nav ul a:active {
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
line-height: 18px;
|
||||
padding: 0;
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
transition: padding 0.2s, color 0.2s, font-weight 0.2s;
|
||||
}
|
||||
|
||||
nav ul a:hover {
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
nav a:hover,
|
||||
nav a:active {
|
||||
color: #606;
|
||||
}
|
||||
|
||||
nav > ul {
|
||||
padding: 0;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
nav > ul > li > a {
|
||||
margin: 0;
|
||||
color: #999;
|
||||
padding: 4px 10px 4px 10px;
|
||||
font-weight: 500;
|
||||
color: #606;
|
||||
}
|
||||
|
||||
nav ul ul {
|
||||
margin-bottom: 10px
|
||||
}
|
||||
|
||||
nav ul ul + ul {
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
nav ul ul a {
|
||||
color: hsl(207, 1%, 60%);
|
||||
border-left: 1px solid hsl(207, 10%, 86%);
|
||||
@@ -227,15 +224,25 @@ nav ul ul a:active {
|
||||
padding-left: 20px
|
||||
}
|
||||
|
||||
nav h2 {
|
||||
font-size: 12px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
nav > h2 > a {
|
||||
display: block;
|
||||
margin: 10px 0 -10px;
|
||||
color: #606 !important;
|
||||
}
|
||||
|
||||
footer {
|
||||
color: hsl(0, 0%, 28%);
|
||||
margin-left: 250px;
|
||||
display: block;
|
||||
padding: 30px;
|
||||
font-size: 80%;
|
||||
color: #999;
|
||||
text-transform: lowercase;
|
||||
padding: 15px;
|
||||
font-style: italic;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
.ancestors {
|
||||
@@ -244,7 +251,6 @@ footer {
|
||||
|
||||
.ancestors a {
|
||||
color: #999 !important;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.clear {
|
||||
@@ -257,34 +263,32 @@ footer {
|
||||
}
|
||||
|
||||
.yes-def {
|
||||
text-indent: -1000px;
|
||||
text-indent: -1000px
|
||||
}
|
||||
|
||||
.type-signature {
|
||||
color: #aaa;
|
||||
color: #CA79CA
|
||||
}
|
||||
|
||||
.type-signature:last-child {
|
||||
color: #eee;
|
||||
}
|
||||
|
||||
.name, .signature {
|
||||
font-family: Consolas, Monaco, 'Andale Mono', monospace
|
||||
}
|
||||
|
||||
.signature {
|
||||
font-family: 'Source Code Pro';
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-family: 'Source Code Pro';
|
||||
font-size: 110%;
|
||||
font-weight: bold;
|
||||
color: #ff6429;
|
||||
padding-top: 30px;
|
||||
color: #fc83ff;
|
||||
}
|
||||
|
||||
.details {
|
||||
margin: 0;
|
||||
color: #999;
|
||||
margin-top: 6px;
|
||||
border-left: 2px solid #DDD;
|
||||
line-height: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.details .tag-source a {
|
||||
color: #999;
|
||||
}
|
||||
.details dt {
|
||||
width: 120px;
|
||||
float: left;
|
||||
@@ -292,7 +296,9 @@ footer {
|
||||
}
|
||||
|
||||
.details dd {
|
||||
margin-left: 70px
|
||||
margin-left: 70px;
|
||||
margin-top: 6px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.details ul {
|
||||
@@ -303,10 +309,6 @@ footer {
|
||||
list-style-type: none
|
||||
}
|
||||
|
||||
.details li {
|
||||
margin-left: 30px
|
||||
}
|
||||
|
||||
.details pre.prettyprint {
|
||||
margin: 0
|
||||
}
|
||||
@@ -327,28 +329,27 @@ footer {
|
||||
}
|
||||
|
||||
.prettyprint {
|
||||
font-size: 13px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 1px 3px hsla(0, 0%, 0%, 0.05);
|
||||
font-size: 14px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.prettyprint.source {
|
||||
width: inherit
|
||||
width: inherit;
|
||||
line-height: 18px;
|
||||
display: block;
|
||||
background-color: #0d152a;
|
||||
color: #aeaeae;
|
||||
}
|
||||
|
||||
.prettyprint code {
|
||||
font-size: 100%;
|
||||
line-height: 18px;
|
||||
display: block;
|
||||
margin: 0 30px;
|
||||
background-color: #fff;
|
||||
background-color: #0d152a;
|
||||
color: #4D4E53;
|
||||
}
|
||||
|
||||
.prettyprint > code {
|
||||
padding: 15px
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.prettyprint .linenums code {
|
||||
@@ -376,11 +377,11 @@ footer {
|
||||
}
|
||||
|
||||
.prettyprint.linenums li {
|
||||
border-left: 3px #ddd solid
|
||||
border-left: 3px #34446B solid;
|
||||
}
|
||||
|
||||
.prettyprint.linenums li.selected, .prettyprint.linenums li.selected * {
|
||||
background-color: lightyellow
|
||||
background-color: #34446B;
|
||||
}
|
||||
|
||||
.prettyprint.linenums li * {
|
||||
@@ -398,11 +399,20 @@ footer {
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.params .name, .props .name, .name code {
|
||||
.params .type {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.params code {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.params td, .params .name, .props .name, .name code {
|
||||
color: #4D4E53;
|
||||
font-family: 'Source Code Pro';
|
||||
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
@@ -438,19 +448,17 @@ footer {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
dl.param-type {
|
||||
border-bottom: 1px solid hsl(0, 0%, 87%);
|
||||
margin-bottom: 30px;
|
||||
padding-bottom: 30px;
|
||||
span.param-type, .params td .param-type, .param-type dd {
|
||||
color: #606;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', monospace
|
||||
}
|
||||
|
||||
.param-type dt, .param-type dd {
|
||||
display: inline-block
|
||||
}
|
||||
|
||||
.param-type dd {
|
||||
font-family: 'Source Code Pro';
|
||||
font-size: 80%;
|
||||
.param-type {
|
||||
margin: 14px 0;
|
||||
}
|
||||
|
||||
.disabled {
|
||||
@@ -464,7 +472,10 @@ dl.param-type {
|
||||
padding: 2.0625rem 1.5rem;
|
||||
transition: 0.25s;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
opacity: .8;
|
||||
}
|
||||
.navicon-button .navicon:before, .navicon-button .navicon:after {
|
||||
@@ -524,7 +535,8 @@ dl.param-type {
|
||||
|
||||
/* Minus */
|
||||
.nav-trigger:checked + label {
|
||||
transform: scale(0.75);
|
||||
-webkit-transform: scale(0.75);
|
||||
transform: scale(0.75);
|
||||
}
|
||||
|
||||
/* × and + */
|
||||
@@ -535,18 +547,21 @@ dl.param-type {
|
||||
|
||||
.nav-trigger:checked + label.plus .navicon:before,
|
||||
.nav-trigger:checked + label.x .navicon:before {
|
||||
transform: rotate(-45deg);
|
||||
-webkit-transform: rotate(-45deg);
|
||||
transform: rotate(-45deg);
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
.nav-trigger:checked + label.plus .navicon:after,
|
||||
.nav-trigger:checked + label.x .navicon:after {
|
||||
transform: rotate(45deg);
|
||||
-webkit-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
.nav-trigger:checked + label.plus {
|
||||
transform: scale(0.75) rotate(45deg);
|
||||
-webkit-transform: scale(0.75) rotate(45deg);
|
||||
transform: scale(0.75) rotate(45deg);
|
||||
}
|
||||
|
||||
.nav-trigger:checked ~ nav {
|
||||
@@ -582,11 +597,16 @@ dl.param-type {
|
||||
}
|
||||
|
||||
nav {
|
||||
background: #FFF;
|
||||
width: 250px;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: -250px;
|
||||
z-index: 3;
|
||||
padding: 0 10px;
|
||||
transition: left 0.2s;
|
||||
}
|
||||
|
||||
@@ -601,8 +621,6 @@ dl.param-type {
|
||||
#main {
|
||||
width: 100%;
|
||||
min-width: 360px;
|
||||
margin-left: 0;
|
||||
padding: 0 25px;
|
||||
}
|
||||
|
||||
#main h1.page-title {
|
||||
@@ -617,3 +635,11 @@ dl.param-type {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Add a '#' to static members */
|
||||
[data-type="member"] a::before {
|
||||
content: '#';
|
||||
display: inline-block;
|
||||
margin-left: -14px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
/* JSDoc prettify.js theme */
|
||||
|
||||
/* plain text */
|
||||
.pln {
|
||||
color: #000000;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* string content */
|
||||
.str {
|
||||
color: hsl(104, 100%, 24%);
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a keyword */
|
||||
.kwd {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a comment */
|
||||
.com {
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* a type name */
|
||||
.typ {
|
||||
color: #000000;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a literal value */
|
||||
.lit {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* punctuation */
|
||||
.pun {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* lisp open bracket */
|
||||
.opn {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* lisp close bracket */
|
||||
.clo {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a markup tag name */
|
||||
.tag {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a markup attribute name */
|
||||
.atn {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a markup attribute value */
|
||||
.atv {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a declaration */
|
||||
.dec {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a variable name */
|
||||
.var {
|
||||
color: #000000;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a function name */
|
||||
.fun {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
/* Tomorrow Theme */
|
||||
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
||||
/* Pretty printing styles. Used with prettify.js. */
|
||||
/* SPAN elements with the classes below are added by prettyprint. */
|
||||
/* plain text */
|
||||
.pln {
|
||||
color: #4d4d4c; }
|
||||
|
||||
@media screen {
|
||||
/* string content */
|
||||
.str {
|
||||
color: hsl(104, 100%, 24%); }
|
||||
|
||||
/* a keyword */
|
||||
.kwd {
|
||||
color: hsl(240, 100%, 50%); }
|
||||
|
||||
/* a comment */
|
||||
.com {
|
||||
color: hsl(0, 0%, 60%); }
|
||||
|
||||
/* a type name */
|
||||
.typ {
|
||||
color: hsl(240, 100%, 32%); }
|
||||
|
||||
/* a literal value */
|
||||
.lit {
|
||||
color: hsl(240, 100%, 40%); }
|
||||
|
||||
/* punctuation */
|
||||
.pun {
|
||||
color: #000000; }
|
||||
|
||||
/* lisp open bracket */
|
||||
.opn {
|
||||
color: #000000; }
|
||||
|
||||
/* lisp close bracket */
|
||||
.clo {
|
||||
color: #000000; }
|
||||
|
||||
/* a markup tag name */
|
||||
.tag {
|
||||
color: #c82829; }
|
||||
|
||||
/* a markup attribute name */
|
||||
.atn {
|
||||
color: #f5871f; }
|
||||
|
||||
/* a markup attribute value */
|
||||
.atv {
|
||||
color: #3e999f; }
|
||||
|
||||
/* a declaration */
|
||||
.dec {
|
||||
color: #f5871f; }
|
||||
|
||||
/* a variable name */
|
||||
.var {
|
||||
color: #c82829; }
|
||||
|
||||
/* a function name */
|
||||
.fun {
|
||||
color: #4271ae; } }
|
||||
/* Use higher contrast and text-weight for printable form. */
|
||||
@media print, projection {
|
||||
.str {
|
||||
color: #060; }
|
||||
|
||||
.kwd {
|
||||
color: #006;
|
||||
font-weight: bold; }
|
||||
|
||||
.com {
|
||||
color: #600;
|
||||
font-style: italic; }
|
||||
|
||||
.typ {
|
||||
color: #404;
|
||||
font-weight: bold; }
|
||||
|
||||
.lit {
|
||||
color: #044; }
|
||||
|
||||
.pun, .opn, .clo {
|
||||
color: #440; }
|
||||
|
||||
.tag {
|
||||
color: #006;
|
||||
font-weight: bold; }
|
||||
|
||||
.atn {
|
||||
color: #404; }
|
||||
|
||||
.atv {
|
||||
color: #060; } }
|
||||
/* Style */
|
||||
/*
|
||||
pre.prettyprint {
|
||||
background: white;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px; }
|
||||
*/
|
||||
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0; }
|
||||
|
||||
/* IE indents via margin-left */
|
||||
li.L0,
|
||||
li.L1,
|
||||
li.L2,
|
||||
li.L3,
|
||||
li.L4,
|
||||
li.L5,
|
||||
li.L6,
|
||||
li.L7,
|
||||
li.L8,
|
||||
li.L9 {
|
||||
/* */ }
|
||||
|
||||
/* Alternate shading for lines */
|
||||
li.L1,
|
||||
li.L3,
|
||||
li.L5,
|
||||
li.L7,
|
||||
li.L9 {
|
||||
/* */ }
|
||||
@@ -0,0 +1,79 @@
|
||||
.pln {
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
/* string content */
|
||||
.str {
|
||||
color: #61ce3c;
|
||||
}
|
||||
|
||||
/* a keyword */
|
||||
.kwd {
|
||||
color: #fbde2d;
|
||||
}
|
||||
|
||||
/* a comment */
|
||||
.com {
|
||||
color: #aeaeae;
|
||||
}
|
||||
|
||||
/* a type name */
|
||||
.typ {
|
||||
color: #8da6ce;
|
||||
}
|
||||
|
||||
/* a literal value */
|
||||
.lit {
|
||||
color: #fbde2d;
|
||||
}
|
||||
|
||||
/* punctuation */
|
||||
.pun {
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
/* lisp open bracket */
|
||||
.opn {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
/* lisp close bracket */
|
||||
.clo {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
/* a markup tag name */
|
||||
.tag {
|
||||
color: #8da6ce;
|
||||
}
|
||||
|
||||
/* a markup attribute name */
|
||||
.atn {
|
||||
color: #fbde2d;
|
||||
}
|
||||
|
||||
/* a markup attribute value */
|
||||
.atv {
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
/* a declaration */
|
||||
.dec {
|
||||
color: #EF5050;
|
||||
}
|
||||
|
||||
/* a variable name */
|
||||
.var {
|
||||
color: #c82829;
|
||||
}
|
||||
|
||||
/* a function name */
|
||||
.fun {
|
||||
color: #4271ae;
|
||||
}
|
||||
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
+7
-11
@@ -1,5 +1,4 @@
|
||||
var wbci = require('webbci');
|
||||
var ws = wbci.signal;
|
||||
var bci = require('../index.js');
|
||||
|
||||
// Generate 1 second of sample data
|
||||
var sampleRate = 512;
|
||||
@@ -12,14 +11,11 @@ var frequencies = [
|
||||
17 // 17 Hz, beta range
|
||||
];
|
||||
|
||||
var signal = ws.generate(amplitudes, frequencies, sampleRate, duration);
|
||||
|
||||
// Get frequency powers in signal
|
||||
var length = sampleRate * duration;
|
||||
var psd = ws.getPSD(length, signal);
|
||||
var signal = bci.generateSignal(amplitudes, frequencies, sampleRate, duration);
|
||||
|
||||
// Compute average power in each frequency band
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'delta')); // 64
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'theta')); // 128
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'alpha')); // 204
|
||||
console.log(ws.getBandPower(length, psd, sampleRate, 'beta')); // 512
|
||||
var fftSize = sampleRate * duration;
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'delta', fftSize)); // 85
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'theta', fftSize)); // 128
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'alpha', fftSize)); // 205
|
||||
console.log(bci.signalBandPower(signal, sampleRate, 'beta', fftSize)); // 114
|
||||
@@ -1,37 +0,0 @@
|
||||
var wbci = require('webbci');
|
||||
var LDA = wbci.lda;
|
||||
|
||||
// Arrays should be of size 'number of samples' rows x 'number of features' columns
|
||||
var class1 = [
|
||||
[0, 0],
|
||||
[1, 2],
|
||||
[2, 2],
|
||||
[1.5, 0.5]
|
||||
];
|
||||
|
||||
var class2 = [
|
||||
[8, 8],
|
||||
[9, 10],
|
||||
[7, 8],
|
||||
[9, 9]
|
||||
];
|
||||
|
||||
var classifier = new LDA(class1, class2);
|
||||
|
||||
var unknownPoints = [
|
||||
[-1, 0],
|
||||
[1.5, 2],
|
||||
[3, 3],
|
||||
[5, 5],
|
||||
[7, 9],
|
||||
[10, 12]
|
||||
];
|
||||
|
||||
var predictions = [];
|
||||
|
||||
for(var i = 0; i < unknownPoints.length; i++){
|
||||
var projection = classifier.project(unknownPoints[i]);
|
||||
predictions.push(Math.sign(projection));
|
||||
}
|
||||
|
||||
console.log(predictions); // [ -1, -1, -1, 1, 1, 1 ]
|
||||
@@ -0,0 +1,71 @@
|
||||
var bci = require('../index.js');
|
||||
|
||||
async function classify(data){
|
||||
// Time how long the function takes
|
||||
var startTime = Date.now();
|
||||
|
||||
// Load EEG data from CSV
|
||||
console.log('Loading data from csv files');
|
||||
var left = await bci.loadCSV('data/left.csv');
|
||||
var right = await bci.loadCSV('data/right.csv');
|
||||
|
||||
// Learn a CSP filter for the EEG data
|
||||
console.log('Computing CSP filter')
|
||||
var cspParams = bci.cspLearn(left, right);
|
||||
|
||||
// Project the loaded data with the learned CSP parameters
|
||||
var cspLeft = bci.cspProject(cspParams, left);
|
||||
var cspRight = bci.cspProject(cspParams, right);
|
||||
|
||||
/*
|
||||
CSP projects data so one dataset has highest variance in the first dimension
|
||||
and lowest variance in the last dimension, while the other dataset has
|
||||
lowest variance in the first and highest in the last. Therefore, the variance
|
||||
of the data in each dimension can be used as an effective feature for differentiating
|
||||
between the two classes. Taking the log of this variance makes the distribution
|
||||
more gaussian, so a classifier such as LDA can be used.
|
||||
*/
|
||||
|
||||
// Split the data into 64 sample windows with 50% overlap
|
||||
// Use the log of the variance of each channel in a window as the feature vector
|
||||
console.log('Passing features to LDA. Window size = 64 samples, overlap = 50%');
|
||||
var featuresLeft = bci.windowApply(cspLeft, window => bci.features.logvar(window, 'columns'), 64, 32);
|
||||
var featuresRight = bci.windowApply(cspRight, window => bci.features.logvar(window, 'columns'), 64, 32);
|
||||
|
||||
// Separate into training and testing sets
|
||||
var [trainingLeft, testingLeft] = bci.partition(featuresLeft, 0.6, 0.4);
|
||||
var [trainingRight, testingRight] = bci.partition(featuresRight, 0.6, 0.4);
|
||||
|
||||
console.log('Using 60/40 split for training and testing sets');
|
||||
console.log('left hand training set size: ' + trainingLeft.length + ', testing set size: ' + testingLeft.length);
|
||||
console.log('right hand training set size: ' + trainingRight.length + ', testing set size: ' + testingRight.length);
|
||||
|
||||
// Use LDA to separate the two training feature datasets
|
||||
var ldaParams = bci.ldaLearn(trainingLeft, trainingRight);
|
||||
|
||||
// Let's see how well the learned LDA parameters perform on the testing set
|
||||
var predictionsLeft = bci.ldaProject(ldaParams, testingLeft);
|
||||
var predictionsRight = bci.ldaProject(ldaParams, testingRight);
|
||||
|
||||
var leftCorrect = predictionsLeft.filter(x => x < 0).length;
|
||||
var leftIncorrect = predictionsLeft.length - leftCorrect;
|
||||
var rightCorrect = predictionsRight.filter(x => x > 0).length;
|
||||
var rightIncorrect = predictionsRight.length - rightCorrect;
|
||||
|
||||
var confusionMatrix = [
|
||||
[' ', 'Predicted left', 'Predicted right'],
|
||||
['Actual left', leftCorrect, leftIncorrect],
|
||||
['Actual right', rightIncorrect, rightCorrect]
|
||||
];
|
||||
var precision = leftCorrect / (leftCorrect + rightIncorrect);
|
||||
var recall = leftCorrect / (leftCorrect + leftIncorrect);
|
||||
var f1 = 2*recall*precision / (recall + precision);
|
||||
console.log();
|
||||
console.log(bci.toTable(confusionMatrix));
|
||||
console.log('f1 score ' + f1.toFixed(2));
|
||||
console.log();
|
||||
|
||||
var runtime = Date.now() - startTime;
|
||||
console.log('Total run time ' + runtime + 'ms');
|
||||
}
|
||||
classify().catch(e => console.error(e));
|
||||
@@ -0,0 +1,36 @@
|
||||
var bci = require('../index.js');
|
||||
|
||||
// Some random numbers
|
||||
var data = [3, 2, 3, 0, 4, 0, 0, 5, 4, 0];
|
||||
|
||||
// Partition into training and testing sets
|
||||
var [training, testing] = bci.partition(data, 0.6, 0.4);
|
||||
|
||||
console.log(training); // [3, 2, 3, 0, 4, 0]
|
||||
console.log(testing); // [0, 5, 4, 0]
|
||||
|
||||
// Traverse the data array with windows of size 3 and a step of 2 (overlap of 1 item per window)
|
||||
bci.windowApply(data, window => console.log(window), 3, 2);
|
||||
/*
|
||||
[ 3, 2, 3 ]
|
||||
[ 3, 0, 4 ]
|
||||
[ 4, 0, 0 ]
|
||||
[ 0, 5, 4 ]
|
||||
*/
|
||||
|
||||
// Find the log of the variance of these windows (feature extraction)
|
||||
var features = bci.windowApply(data, bci.features.logvar, 3, 2);
|
||||
console.log(features); // [-1.099, 1.466, 1.674, 1.946]
|
||||
|
||||
// Colon notation for array subscripting
|
||||
var arr = [
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7, 8, 9]
|
||||
];
|
||||
var subarr = bci.subscript(arr, '1 3', '2:3'); // rows 1 and 3, columns 2 through 3
|
||||
console.log(subarr);
|
||||
/*
|
||||
[[2, 3],
|
||||
[8, 9]]
|
||||
*/
|
||||
@@ -0,0 +1,35 @@
|
||||
var bci = require('../index.js');
|
||||
|
||||
// Training set
|
||||
var class1 = [
|
||||
[0, 0],
|
||||
[1, 2],
|
||||
[2, 2],
|
||||
[1.5, 0.5]
|
||||
];
|
||||
var class2 = [
|
||||
[8, 8],
|
||||
[9, 10],
|
||||
[7, 8],
|
||||
[9, 9]
|
||||
];
|
||||
|
||||
// Testing set
|
||||
var unknownPoints = [
|
||||
[-1, 0],
|
||||
[1.5, 2],
|
||||
[3, 3],
|
||||
[5, 5],
|
||||
[7, 9],
|
||||
[10, 12]
|
||||
];
|
||||
|
||||
// Learn an LDA classifier
|
||||
var ldaParams = bci.ldaLearn(class1, class2);
|
||||
|
||||
// Test classifier
|
||||
var predictions = unknownPoints.map(point => {
|
||||
return Math.sign(bci.ldaProject(ldaParams, point))
|
||||
});
|
||||
|
||||
console.log(predictions); // [ -1, -1, -1, 1, 1, 1 ]
|
||||
@@ -1,36 +0,0 @@
|
||||
var wbci = require('webbci');
|
||||
var net = wbci.network;
|
||||
var ws = wbci.signal;
|
||||
|
||||
// OSC properties
|
||||
var oscPort = 7000;
|
||||
var oscAddress = '127.0.0.1';
|
||||
var eegAddress = 'Person0/eeg';
|
||||
|
||||
// Listen for EEG data
|
||||
net.addEEGListener(oscAddress, oscPort, eegAddress, onEEG);
|
||||
|
||||
var windowSize = 512;
|
||||
var numChannels = 4;
|
||||
var sampleRate = 256;
|
||||
|
||||
var dataWindow = new ws.EEGWindow(windowSize, numChannels, onWindowFull);
|
||||
function onEEG(data) {
|
||||
dataWindow.addData(data);
|
||||
}
|
||||
|
||||
function onWindowFull(channels) {
|
||||
// Compute sum of alpha and beta powers over all channels
|
||||
var alpha = 0;
|
||||
var beta = 0;
|
||||
|
||||
for (var i = 0; i < channels.length; i++) {
|
||||
var powers = ws.getPSD(windowSize, channels[i]);
|
||||
alpha += ws.getBandPower(windowSize, powers, sampleRate, 'alpha');
|
||||
beta += ws.getBandPower(windowSize, powers, sampleRate, 'beta');
|
||||
}
|
||||
|
||||
var concentration = beta / alpha;
|
||||
|
||||
console.log(concentration);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
var fs = require('fs');
|
||||
var gulp = require('gulp');
|
||||
|
||||
var browserify = require('browserify');
|
||||
var source = require('vinyl-source-stream');
|
||||
var buffer = require('vinyl-buffer');
|
||||
var uglify = require('gulp-uglify-es').default;
|
||||
var rename = require('gulp-rename');
|
||||
|
||||
var jsdoc = require('gulp-jsdoc3');
|
||||
|
||||
var fsThen = require('fs-then-native');
|
||||
var jsdoc2md = require('jsdoc-to-markdown');
|
||||
|
||||
gulp.task('build', function () {
|
||||
var libdir = 'lib';
|
||||
var libs = ['math', 'network', 'data', 'compat'];
|
||||
|
||||
var header = "// This file was auto generated, changes will be overwritten\n// Created on " + (new Date()) + "\n";
|
||||
header += "/** @module webbci */\n";
|
||||
var out = fs.openSync('./index.js', 'w');
|
||||
fs.writeSync(out, header);
|
||||
|
||||
libs.forEach(lib => {
|
||||
var path = libdir + '/' + lib;
|
||||
var files = fs.readdirSync(path);
|
||||
|
||||
files.forEach(file => {
|
||||
var functionName = file.substring(0, file.length - 3);
|
||||
fs.appendFileSync(out, 'module.exports.' + functionName + ' = require(\'./' + path + '/' + file + '\');\n');
|
||||
});
|
||||
});
|
||||
|
||||
var moreCompat = fs.readFileSync('./compat.js', {encoding: 'utf8'});
|
||||
fs.appendFileSync(out, moreCompat);
|
||||
|
||||
fs.closeSync(out);
|
||||
});
|
||||
|
||||
gulp.task('docs-html', function(cb){
|
||||
var config = require('./jsdoc.json');
|
||||
var files = [
|
||||
'README.md',
|
||||
'index.js',
|
||||
'lib/data',
|
||||
'lib/math',
|
||||
'lib/network'
|
||||
];
|
||||
gulp.src(files, {read: false})
|
||||
.pipe(jsdoc(config, cb));
|
||||
});
|
||||
|
||||
gulp.task('docs-md', function(cb){
|
||||
return jsdoc2md.render({ files: ['./index.js', './lib/math/*.js', './lib/data/*.js', './lib/network/*.js'] })
|
||||
.then(output => fsThen.writeFile('docs/api.md', output))
|
||||
.then(() => jsdoc2md.render({files: ['./index.js', './lib/compat/*.js']}))
|
||||
.then(output => fsThen.writeFile('docs/deprecated.md', output));
|
||||
});
|
||||
|
||||
gulp.task('dist', function () {
|
||||
return browserify({
|
||||
debug: false,
|
||||
entries: './index.js',
|
||||
standalone: 'bci'
|
||||
})
|
||||
.bundle()
|
||||
.on('error', (...args) => console.log(args))
|
||||
.pipe(source('bci.js'))
|
||||
.pipe(buffer())
|
||||
.pipe(gulp.dest('dist'))
|
||||
.pipe(rename({ extname: '.min.js' }))
|
||||
.pipe(uglify())
|
||||
.pipe(gulp.dest('dist'));
|
||||
});
|
||||
+31
-11
@@ -1,12 +1,32 @@
|
||||
/**
|
||||
* A module for BCI design and EEG signal processing.
|
||||
* @module webbci
|
||||
*/
|
||||
|
||||
exports.signal = require('./lib/signal.js');
|
||||
exports.network = require('./lib/network.js');
|
||||
exports.LDA = require('./lib/lda.js');
|
||||
|
||||
// backwards compatibility
|
||||
exports.lda = exports.LDA;
|
||||
// This file was auto generated, changes will be overwritten
|
||||
// Created on Tue May 01 2018 19:28:54 GMT-0500 (Central Daylight Time)
|
||||
/** @module webbci */
|
||||
module.exports.cspLearn = require('./lib/math/cspLearn.js');
|
||||
module.exports.cspProject = require('./lib/math/cspProject.js');
|
||||
module.exports.features = require('./lib/math/features.js');
|
||||
module.exports.generateSignal = require('./lib/math/generateSignal.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.oscCollect = require('./lib/network/oscCollect.js');
|
||||
module.exports.oscHeaderScan = require('./lib/network/oscHeaderScan.js');
|
||||
module.exports.oscStream = require('./lib/network/oscStream.js');
|
||||
module.exports.wait = require('./lib/network/wait.js');
|
||||
module.exports.loadCSV = require('./lib/data/loadCSV.js');
|
||||
module.exports.partition = require('./lib/data/partition.js');
|
||||
module.exports.round = require('./lib/data/round.js');
|
||||
module.exports.saveCSV = require('./lib/data/saveCSV.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.csp = require('./lib/compat/csp.js');
|
||||
module.exports.lda = require('./lib/compat/lda.js');
|
||||
module.exports.network = require('./lib/compat/network.js');
|
||||
module.exports.signal = require('./lib/compat/signal.js');
|
||||
// Additional backwards compatibility
|
||||
exports.LDA = exports.lda;
|
||||
exports.csp = exports.signal.CSP;
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"recurseDepth": 10,
|
||||
"sourceType": "module",
|
||||
"tags": {
|
||||
"allowUnknownTags": true,
|
||||
"dictionaries": ["jsdoc", "closure"]
|
||||
},
|
||||
"source": {
|
||||
"include": [],
|
||||
"exclude": [],
|
||||
"includePattern": ".js$",
|
||||
"excludePattern": "(node_modules/|docs)"
|
||||
},
|
||||
"plugins": [
|
||||
"plugins/markdown"
|
||||
],
|
||||
"markdown": {
|
||||
"excludeTags": ["author"]
|
||||
},
|
||||
"templates": {
|
||||
"cleverLinks": false,
|
||||
"monospaceLinks": false,
|
||||
"default": {
|
||||
"layoutFile": "./docs-layout.tmpl"
|
||||
}
|
||||
},
|
||||
"opts": {
|
||||
"destination": "./docs/",
|
||||
"encoding": "utf8",
|
||||
"private": false,
|
||||
"recurse": true,
|
||||
"template": "./node_modules/docdash"
|
||||
},
|
||||
"docdash": {
|
||||
"static": true,
|
||||
"sort": true
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ var pwlda = require('pw-lda');
|
||||
|
||||
/**
|
||||
* An LDA object
|
||||
* @deprecated since version 1.1
|
||||
* @name LDA
|
||||
* @memberof module:webbci
|
||||
* @constructor
|
||||
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* The network operations for webbci
|
||||
* @deprecated since version 1.1
|
||||
* @namespace network
|
||||
* @memberof module:webbci
|
||||
*/
|
||||
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* Signal processing operations
|
||||
* @deprecated since version 1.1
|
||||
* @namespace signal
|
||||
* @memberof module:webbci
|
||||
*/
|
||||
@@ -0,0 +1,25 @@
|
||||
var csv = require('csvtojson');
|
||||
|
||||
/**
|
||||
* Loads a CSV file into an array
|
||||
* @memberof module:webbci
|
||||
* @param {string} filePath - The path to the CSV file
|
||||
* @returns {Promise} A promise object representing the CSV data array
|
||||
*/
|
||||
function loadCSV(filePath) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var data = [];
|
||||
|
||||
csv({ noheader: true })
|
||||
.fromFile(filePath)
|
||||
.on('csv', (row) => {
|
||||
data.push(row.map(Number));
|
||||
})
|
||||
.on('done', (error) => {
|
||||
if (error) reject(error);
|
||||
else resolve(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = loadCSV;
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Partitions an array into multiple arrays
|
||||
* Can be used to split data into training and testing sets
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array - The array to be partitioned
|
||||
* @param {...number[]} divisions - The size of each partition, each value should range from 0 to 1
|
||||
* @example
|
||||
* partition([1, 2, 3, 4], 0.25, 0.75); // returns [[1], [2, 3, 4]]
|
||||
* @returns {Array.<Array>} Array of subarrays which are the partitons
|
||||
*/
|
||||
function partition(array, ...divisions) {
|
||||
var parts = [];
|
||||
|
||||
var lastDivision = 0;
|
||||
var runningSum = 0;
|
||||
divisions.forEach(division => {
|
||||
runningSum += division;
|
||||
var end = Math.round(runningSum * array.length);
|
||||
parts.push(array.slice(lastDivision, end));
|
||||
lastDivision = end;
|
||||
});
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
module.exports = partition;
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Rounds every value in an array to a set number of decimal places
|
||||
* @memberof module:webbci
|
||||
* @param {number[]} array
|
||||
* @param {number} places
|
||||
* @returns {number[]} The rounded array
|
||||
*/
|
||||
function round(array, places) {
|
||||
return helper(array);
|
||||
|
||||
function helper(array) {
|
||||
return array.map(item => {
|
||||
if (typeof item === 'number') {
|
||||
return parseFloat(item.toFixed(places));
|
||||
}
|
||||
|
||||
return helper(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = round;
|
||||
@@ -0,0 +1,20 @@
|
||||
var csv = require('fast-csv');
|
||||
|
||||
/**
|
||||
* Saves an array to a CSV file
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array
|
||||
* @param {string} filename
|
||||
* @returns {Promise} A promise object that resolves when the file has been saved. Does not currently reject on write error.
|
||||
*/
|
||||
function saveCSV(array, filename) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
csv
|
||||
.writeToPath(filename, array, { headers: false })
|
||||
.on("finish", function () {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = saveCSV;
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Subscript an array with MATLAB-like syntax
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array - The array to be subscripted
|
||||
* @param {...string} params - Colon notation for which elements to include in each dimension
|
||||
* @returns {Array} The subscripted array
|
||||
* @example
|
||||
* var bci = require('webbci');
|
||||
* var arr = [3, 2, 4, 1, 5];
|
||||
* var subarr = bci.subscript(arr, '1:3');
|
||||
* console.log(subarr); // [3, 2, 4]
|
||||
* @example
|
||||
* var bci = require('webbci');
|
||||
* var arr = [
|
||||
* [1, 2, 3],
|
||||
* [4, 5, 6],
|
||||
* [7, 8, 9]
|
||||
* ];
|
||||
* var subarr = bci.subscript(arr, '1 3', '2:3'); // rows 1 and 3, columns 2 through 3
|
||||
* console.log(subarr); // [[2, 3], [8, 9]]
|
||||
*/
|
||||
function subscript(array, ...params) {
|
||||
return recur(array, ...params);
|
||||
|
||||
function recur(array, ...dims) {
|
||||
var arr = slice(array, dims.shift(), "matlab");
|
||||
|
||||
if (dims.length != 0) {
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
arr[i] = recur(arr[i], ...dims);
|
||||
}
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function slice(array, dims, format = "python") {
|
||||
dims = dims.split(" ");
|
||||
|
||||
var subs = [];
|
||||
|
||||
dims.forEach(dim => {
|
||||
var cp = dim.indexOf(':');
|
||||
var indexes = dim.split(':');
|
||||
|
||||
if (indexes.length > 2 || dim == '') {
|
||||
console.error("Invalid subscript string");
|
||||
return;
|
||||
}
|
||||
|
||||
if (indexes[1] == '') {
|
||||
indexes[1] = array.length;
|
||||
}
|
||||
|
||||
indexes = indexes.map(Number);
|
||||
|
||||
if (format == "matlab" || format == "mat") {
|
||||
// TODO: Implement 'end' keyword
|
||||
// This format is still in beta
|
||||
if (indexes[0] > 0) {
|
||||
indexes[0] -= 1;
|
||||
}
|
||||
|
||||
if (indexes[1] == -1) {
|
||||
indexes[1] = array.length;
|
||||
}
|
||||
|
||||
if (indexes[1] < 0) {
|
||||
indexes[1] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (indexes.length == 1) {
|
||||
indexes.push(indexes[0] + 1);
|
||||
}
|
||||
|
||||
subs.push(array.slice(...indexes));
|
||||
});
|
||||
|
||||
return [].concat(...subs);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = subscript;
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Returns an array of numbers as strings rounded to the proper number of decimal places and padded with zeros as needed.
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array
|
||||
* @param {number} places
|
||||
* @returns {string[]} Array of string representations of numbers
|
||||
*/
|
||||
function toFixed(array, places) {
|
||||
return helper(array);
|
||||
|
||||
function helper(array) {
|
||||
return array.map(item => {
|
||||
if (typeof item === 'number') {
|
||||
return item.toFixed(places);
|
||||
}
|
||||
|
||||
return helper(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = toFixed;
|
||||
@@ -0,0 +1,14 @@
|
||||
var Table = require('easy-table');
|
||||
var toFixed = require('./toFixed.js');
|
||||
|
||||
/**
|
||||
* Returns an ASCII table representation of an array
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array
|
||||
* @returns {string} ASCII table
|
||||
*/
|
||||
function toTable(array) {
|
||||
return Table.print(array);
|
||||
}
|
||||
|
||||
module.exports = toTable;
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Similar to JavaScript's map, but it applies a function to sub arrays instead of each element.
|
||||
* Each sub array, or window, starts at index 0 and has length 'length'
|
||||
* Each next window will be shifted 'step' elements from the first. The result of each function is stored in a returned array.
|
||||
* @memberof module:webbci
|
||||
* @param {Array} array - The array of elements which will be windowed
|
||||
* @param {Function} func - The function to call on each window, the returned result is stored in a returned array
|
||||
* @param {number} length - The number of elements to include in each window
|
||||
* @param {number} step - The start of the window is incremented by this amount every iteration
|
||||
* @param {boolean} tail - If false, windows which begin near the end of the array which cannot reach length 'length' will be ignored
|
||||
* @returns {Array} An array containing the function result for each window
|
||||
* @example
|
||||
* var bci = require('webbci');
|
||||
* bci.windowApply([1, 2, 3, 4, 5], window => console.log(window), 3, 1);
|
||||
* // [1, 2, 3]
|
||||
* // [2, 3, 4]
|
||||
* // [3, 4, 5]
|
||||
* @example
|
||||
* var bci = require('webbci');
|
||||
* var sums = bci.windowApply([1, 2, 3, 4, 5], window => {
|
||||
* var sum = 0;
|
||||
* window.forEach(x => sum += x);
|
||||
* return sum;
|
||||
* }, 3, 1);
|
||||
* console.log(sums);
|
||||
* // [6, 9, 12]
|
||||
*/
|
||||
function windowApply(array, func, length, step = -1, tail = false) {
|
||||
if (step == -1) step = length;
|
||||
|
||||
var result = [];
|
||||
|
||||
for (var i = 0; i < array.length; i += step) {
|
||||
var window = array.slice(i, i + length);
|
||||
if (tail || window.length == length) {
|
||||
result.push(func(window));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = windowApply;
|
||||
@@ -0,0 +1,22 @@
|
||||
var numeric = require('numeric');
|
||||
var math = require('mathjs');
|
||||
var stat = require('pw-stat');
|
||||
|
||||
/**
|
||||
* Learn common spatial pattern for two datasets
|
||||
* @memberof module:webbci
|
||||
* @param {number[][]} class1 - Data samples for class 1. Rows should be samples, columns should be signals.
|
||||
* @param {number[][]} class2 - Data samples for class 2. Rows should be samples, columns should be signals.
|
||||
* @returns {Object} Learned CSP parameters
|
||||
*/
|
||||
function cspLearn(class1, class2) {
|
||||
var cov1 = stat.cov(class1);
|
||||
var cov2 = stat.cov(class2);
|
||||
var V = numeric.eig(math.multiply(math.inv(math.add(cov1, cov2)), cov1)).E.x;
|
||||
|
||||
return {
|
||||
V: V
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = cspLearn;
|
||||
@@ -0,0 +1,36 @@
|
||||
var math = require('mathjs');
|
||||
|
||||
/**
|
||||
* Projects data and reduces to given number of dimensions
|
||||
* @memberof module:webbci
|
||||
* @param {object} cspParams - CSP parameters computed using the cspLearn function
|
||||
* @param {number[][]} data - Data points to be projected. Rows should be samples, columns should be signals.
|
||||
* @param {number} [dimensions] - Number of dimensions to be returned. Can range from 1 to number of signals. Defaults to number of signals.
|
||||
* @returns {number[][]} Projected data. Rows are samples, columns are dimensions sorted by descending importance.
|
||||
*/
|
||||
function cspProject(cspParams, data, dimensions) {
|
||||
var projected = math.multiply(data, cspParams.V);
|
||||
|
||||
// Default number of dimensions is all of them, which is number of columns in data
|
||||
dimensions = typeof dimensions !== "undefined" ? dimensions : projected[0].length;
|
||||
|
||||
var reduced = [];
|
||||
|
||||
for (var r = 0; r < projected.length; r++) {
|
||||
reduced.push([]);
|
||||
|
||||
for (var i = 0; i < dimensions; i++) {
|
||||
// Start at left and right ends of matrix columns are work towards center
|
||||
if (i % 2 == 0) {
|
||||
var column = i / 2;
|
||||
} else {
|
||||
var column = projected[0].length - (i + 1) / 2;
|
||||
}
|
||||
reduced[r].push(projected[r][column]);
|
||||
}
|
||||
}
|
||||
|
||||
return reduced;
|
||||
}
|
||||
|
||||
module.exports = cspProject;
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Feature extraction methods
|
||||
* @namespace features
|
||||
* @memberof module:webbci
|
||||
*/
|
||||
|
||||
var math = require('mathjs');
|
||||
var sbp = require('./signalBandPower.js');
|
||||
|
||||
/**
|
||||
* Computes the log of the variance along the specified dimension
|
||||
* @memberof module:webbci.features
|
||||
* @param {number[] | number[][]} window - The data
|
||||
* @param {string} [dimension] - If 'rows' or 'columns' passed, the features are calculated along that dimension
|
||||
*/
|
||||
function logvar(window, dimension = null) {
|
||||
if(dimension == null){
|
||||
return math.log(math.var(window));
|
||||
}
|
||||
|
||||
var possibleDimensions = ['rows', 'cols', 'columns'];
|
||||
if(possibleDimensions.indexOf(dimension) == -1){
|
||||
throw "Invalid dimension";
|
||||
}
|
||||
|
||||
if(dimension == 'cols' || dimension == 'columns'){
|
||||
window = math.transpose(window);
|
||||
}
|
||||
|
||||
return window.map(channel => math.log(math.var(channel)));
|
||||
}
|
||||
module.exports.logvar = logvar;
|
||||
|
||||
/**
|
||||
* Computes the root mean square along the specified dimension
|
||||
* @memberof module:webbci.features
|
||||
* @param {number[] | number[][]} window - The data
|
||||
* @param {string} [dimension] - If 'rows' or 'columns' passed, the features are calculated along that dimension
|
||||
*/
|
||||
function rootMeanSquare(window, dimension = null) {
|
||||
if(dimension == null){
|
||||
return math.sqrt(math.mean(math.square(window)));
|
||||
}
|
||||
|
||||
var possibleDimensions = ['rows', 'cols', 'columns'];
|
||||
if(possibleDimensions.indexOf(dimension) == -1){
|
||||
throw "Invalid dimension";
|
||||
}
|
||||
|
||||
if(dimension == 'cols' || dimension == 'columns'){
|
||||
window = math.transpose(window);
|
||||
}
|
||||
|
||||
return window.map(channel => math.sqrt(math.mean(math.square(channel))));
|
||||
}
|
||||
module.exports.rootMeanSquare = rootMeanSquare;
|
||||
|
||||
/* TODO: Add features with bands */
|
||||
@@ -0,0 +1,23 @@
|
||||
var math = require('mathjs');
|
||||
|
||||
/**
|
||||
* Generate a signal with the given frequencies and their amplitudes.
|
||||
* @memberof module:webbci
|
||||
* @param {number[]} amplitudes - The amplitudes of each frequency.
|
||||
* @param {number[]} frequencies - The frequencies.
|
||||
* @param {number} sampleRate - Sample rate of the signal in Hz.
|
||||
* @param {number} duration - Duration of the signal in seconds.
|
||||
* @returns {number[]} The generated signal.
|
||||
*/
|
||||
function generateSignal(amplitudes, frequencies, sampleRate, duration) {
|
||||
var x = math.range(0, duration, 1 / sampleRate);
|
||||
|
||||
var signal = math.zeros(x.size()[0]);
|
||||
for (var i = 0; i < amplitudes.length; i++) {
|
||||
signal = math.add(signal, math.multiply(amplitudes[i], math.sin(math.multiply(2 * math.pi * frequencies[i], x))));
|
||||
}
|
||||
|
||||
return signal.toArray();
|
||||
}
|
||||
|
||||
module.exports = generateSignal;
|
||||
@@ -0,0 +1,24 @@
|
||||
var math = require('mathjs');
|
||||
var stat = require('pw-stat');
|
||||
|
||||
/**
|
||||
* Perform linear discriminant analysis between two datasets
|
||||
* @memberof module:webbci
|
||||
* @param {number[][]} class1 - Data set for class 1, rows are samples, columns are variables
|
||||
* @param {number[][]} class2 - Data set for class 2, rows are samples, columns are variables
|
||||
* @returns {Object} Computed LDA parameters
|
||||
*/
|
||||
function ldaLearn(class1, class2) {
|
||||
var mu1 = math.transpose(stat.mean(class1));
|
||||
var mu2 = math.transpose(stat.mean(class2));
|
||||
var pooledCov = math.add(stat.cov(class1), stat.cov(class2));
|
||||
var theta = math.multiply(math.inv(pooledCov), math.subtract(mu2, mu1));
|
||||
var b = math.multiply(-1, math.transpose(theta), math.add(mu1, mu2), 1 / 2);
|
||||
|
||||
return {
|
||||
theta: theta,
|
||||
b: b
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = ldaLearn;
|
||||
@@ -0,0 +1,14 @@
|
||||
var math = require('mathjs');
|
||||
|
||||
/**
|
||||
* Predict the class of an unknown data point.
|
||||
* @memberof module:webbci
|
||||
* @param {object} ldaParams - The parameters for the LDA, computed with the function ldaLearn
|
||||
* @param {number[]} point - The data point to be classified.
|
||||
* @returns {number} value less than 0 if predicted to be in class 1, 0 if exactly inbetween, greater than 0 if class 2
|
||||
*/
|
||||
function ldaProject(ldaParams, point) {
|
||||
return math.add(math.multiply(point, ldaParams.theta), ldaParams.b);
|
||||
}
|
||||
|
||||
module.exports = ldaProject;
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Returns the ceil of the log2 of the absolute value of the passed number
|
||||
* @memberof module:webbci
|
||||
* @param {number} num
|
||||
* @example
|
||||
* nextpow2(8); // 3
|
||||
* nextpow2(9); // 4
|
||||
* nextpow2(16); // 4
|
||||
* nextpow2(30); // 5
|
||||
* nextpow2(0); // -Infinity
|
||||
*/
|
||||
function nextpow2(num){
|
||||
return Math.ceil(Math.log2(Math.abs(num)));
|
||||
}
|
||||
|
||||
module.exports = nextpow2;
|
||||
@@ -0,0 +1,53 @@
|
||||
var fft = require('fft.js');
|
||||
var nextpow2 = require('./nextpow2.js');
|
||||
|
||||
var fftCache = {};
|
||||
|
||||
/**
|
||||
* Compute the power spectral density of a given signal.
|
||||
* @memberof module:webbci
|
||||
* @param {number[]} signal - The 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 {boolean} [options.truncate=false] - If true, only the first half of the PSD array is returned
|
||||
* @returns {number[]} The PSD.
|
||||
*/
|
||||
function psd(signal, options) {
|
||||
var {fftSize, truncate} = Object.assign({
|
||||
fftSize: Math.pow(2, nextpow2(signal.length)),
|
||||
truncate: false
|
||||
}, options);
|
||||
|
||||
var f;
|
||||
if (fftCache.hasOwnProperty(fftSize)) {
|
||||
f = fftCache[fftSize];
|
||||
} else {
|
||||
f = new fft(fftSize);
|
||||
fftCache[fftSize] = f;
|
||||
}
|
||||
|
||||
// Zero pad signal to length if needed
|
||||
if (signal.length < fftSize) {
|
||||
signal = signal.concat(Array(fftSize - signal.length).fill(0));
|
||||
}
|
||||
|
||||
var freqs = f.createComplexArray();
|
||||
f.realTransform(freqs, signal);
|
||||
if(truncate){
|
||||
var powers = getPowers(freqs, freqs.length / 2);
|
||||
}else{
|
||||
var powers = getPowers(freqs, freqs.length);
|
||||
}
|
||||
|
||||
return powers;
|
||||
}
|
||||
|
||||
function getPowers(complexArray, length) {
|
||||
var magnitudes = [];
|
||||
for (var i = 0; i < length - 1; i += 2) {
|
||||
magnitudes.push(Math.sqrt(complexArray[i] * complexArray[i] + complexArray[i + 1] * complexArray[i + 1]));
|
||||
}
|
||||
return magnitudes;
|
||||
}
|
||||
|
||||
module.exports = psd;
|
||||
@@ -0,0 +1,44 @@
|
||||
var nextpow2 = require('./nextpow2.js');
|
||||
|
||||
/**
|
||||
* Compute the average power across a given frequency band given the PSD.
|
||||
* @memberof module:webbci
|
||||
* @param {number[]} psd - Power spectral density of the signal.
|
||||
* @param {number} sampleRate - The sample rate of the signal.
|
||||
* @param {(number[]|string)} - The frequency band provided as an array [frequencyStart, frequencyStop] or a
|
||||
* string <code>delta</code> (1-3 Hz), <code>theta</code> (4-7 Hz), <code>alpha</code> (8-12 Hz), <code>beta</code> (13-30 Hz), or <code>gamma</code> (31-50 Hz).
|
||||
* While string representations
|
||||
* allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in
|
||||
* future updates.
|
||||
* @param {number} [fftSize=Math.pow(2, bci.nextpow2(psd.length))] - Size of the fourier transform used to compute the PSD.
|
||||
* @returns {number} The average power in the frequency band.
|
||||
*/
|
||||
function psdBandPower(psd, sampleRate, band, fftSize=null) {
|
||||
if(fftSize === null){
|
||||
fftSize = Math.pow(2, nextpow2(psd.length));
|
||||
}
|
||||
|
||||
var bands = {
|
||||
// From Dan Szafir's "Pay Attention!", 2012
|
||||
'delta': [1, 3],
|
||||
'theta': [4, 7],
|
||||
'alpha': [8, 12],
|
||||
'beta': [13, 30],
|
||||
'gamma': [31, 50]
|
||||
};
|
||||
|
||||
if (typeof band === 'string' || band instanceof String) {
|
||||
band = bands[band];
|
||||
}
|
||||
|
||||
var startIndex = Math.floor(band[0] / sampleRate * fftSize);
|
||||
var endIndex = Math.min(Math.ceil(band[1] / sampleRate * fftSize), psd.length - 1);
|
||||
|
||||
var power = 0;
|
||||
for (var i = startIndex; i < endIndex + 1; i++) {
|
||||
power += psd[i];
|
||||
}
|
||||
return power / (endIndex - startIndex + 1);
|
||||
}
|
||||
|
||||
module.exports = psdBandPower;
|
||||
@@ -0,0 +1,27 @@
|
||||
var psd = require('./psd.js');
|
||||
var psdBandPower = require('./psdBandPower.js');
|
||||
var nextpow2 = require('./nextpow2.js');
|
||||
|
||||
/**
|
||||
* Compute the average power across a given frequency band in a signal.
|
||||
* @memberof module:webbci
|
||||
* @param {number[]} signal - The signal.
|
||||
* @param {number} sampleRate - The sample rate of the signal.
|
||||
* @param {(number[]|string)} - The frequency band provided as an array [frequencyStart, frequencyStop] or a
|
||||
* string <code>delta</code> (1-3 Hz), <code>theta</code> (4-7 Hz), <code>alpha</code> (8-12 Hz), <code>beta</code> (13-30 Hz), or <code>gamma</code> (31-50 Hz).
|
||||
* While string representations
|
||||
* allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in
|
||||
* future updates.
|
||||
* @param {number} [fftSize=Math.pow(2, bci.nextpow2(signal.length))] - Size of the fourier transform used to compute the PSD.
|
||||
* @returns {number} The average power in the frequency band.
|
||||
*/
|
||||
function signalBandPower(signal, sampleRate, band, fftSize = null) {
|
||||
if(fftSize === null){
|
||||
fftSize = Math.pow(2, nextpow2(signal.length));
|
||||
}
|
||||
|
||||
var p = psd(signal, {fftSize: fftSize});
|
||||
return psdBandPower(p, sampleRate, band, fftSize);
|
||||
}
|
||||
|
||||
module.exports = signalBandPower;
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @memberof module:webbci.network
|
||||
*/
|
||||
|
||||
var osc = require('node-osc');
|
||||
|
||||
/**
|
||||
* Collect a set number of samples over OSC
|
||||
* @memberof module:webbci
|
||||
* @param {string} address - OSC address
|
||||
* @param {number} port - OSC port
|
||||
* @param {string} header - OSC header, can be found by scanning with oscHeaderScan if unknown
|
||||
* @param {number} samples - The number of samples to collect
|
||||
* @returns {Promise} Resolves with collected data
|
||||
*/
|
||||
function oscCollect(address, port, header, samples) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var data = [];
|
||||
|
||||
if (samples == 0) {
|
||||
resolve(data);
|
||||
return;
|
||||
}
|
||||
|
||||
var server = new osc.Server(port, address);
|
||||
|
||||
server.on("message", function (msg, rinfo) {
|
||||
if (msg[0] == header) {
|
||||
data.push(msg.slice(1));
|
||||
|
||||
if (data.length > samples) {
|
||||
server.kill();
|
||||
reject("More OSC samples seen than expected");
|
||||
}else if (data.length == samples) {
|
||||
server.kill();
|
||||
resolve(data);
|
||||
data = [];
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = oscCollect;
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @memberof module:webbci.network
|
||||
*/
|
||||
|
||||
var osc = require('node-osc');
|
||||
|
||||
/**
|
||||
* Scan for OSC headers on a port and address
|
||||
* @memberof module:webbci
|
||||
* @param {any} address - OSC address
|
||||
* @param {any} port - OSC port
|
||||
* @param {any} duration - Duration of scan in milliseconds
|
||||
* @returns {Promise} Resolves with an array of found headers
|
||||
*/
|
||||
function oscHeaderScan(address, port, duration) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var server = new osc.Server(port, address);
|
||||
|
||||
var headers = new Set();
|
||||
var start = Date.now();
|
||||
|
||||
server.on("message", function (msg, rinfo) {
|
||||
var header = msg[0];
|
||||
headers.add(header);
|
||||
|
||||
var time = Date.now();
|
||||
|
||||
if (time - start >= duration) {
|
||||
server.kill();
|
||||
resolve([...headers]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = oscHeaderScan;
|
||||
@@ -0,0 +1,53 @@
|
||||
var osc = require('node-osc');
|
||||
|
||||
/**
|
||||
* Listen for messages over OSC
|
||||
* @memberof module:webbci
|
||||
*/
|
||||
class oscStream {
|
||||
/**
|
||||
* @constructor
|
||||
* @param {string} address - Address to listen on
|
||||
* @param {number} port - Port to listen on
|
||||
*/
|
||||
constructor(address, port) {
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
this.header = header;
|
||||
this.onFuncs = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Start listening for OSC messages
|
||||
*/
|
||||
start() {
|
||||
this.server = new osc.Server(this.port, this.address);
|
||||
|
||||
this.server.on("message", function (msg, rinfo) {
|
||||
var header = msg[0];
|
||||
var data = msg.slice(1);
|
||||
|
||||
if (header in this.onFuncs) {
|
||||
this.onFuncs(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop listening for OSC messages
|
||||
*/
|
||||
stop() {
|
||||
this.server.kill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call a callback function when data containing a specified OSC header is seen
|
||||
* @param {string} header - The OSC header
|
||||
* @param {requestCallback} callback - Called with the OSC data passed as the parameter
|
||||
*/
|
||||
on(header, callback) {
|
||||
this.onFuncs[header] = callback;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = oscStream;
|
||||
@@ -0,0 +1,8 @@
|
||||
// Use setTimeout as a promise
|
||||
/**
|
||||
* @memberof module:webbci
|
||||
* @function
|
||||
* @name wait
|
||||
* @param {number} ms - Number of milliseconds to wait
|
||||
*/
|
||||
module.exports = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||
gerado
+5226
-17
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+29
-5
@@ -1,19 +1,31 @@
|
||||
{
|
||||
"name": "webbci",
|
||||
"version": "1.0.3",
|
||||
"version": "1.1.0-beta.4",
|
||||
"description": "JavaScript based EEG processing tool",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
"test": "mocha",
|
||||
"build": "gulp build",
|
||||
"dist": "gulp dist",
|
||||
"dist-nobabel": "gulp dist-nobabel",
|
||||
"docs-md": "gulp docs-md",
|
||||
"docs-html": "gulp docs-html",
|
||||
"docs": "npm run docs-html && npm run docs-md",
|
||||
"prepublish": "npm run build && npm run test && npm run docs"
|
||||
},
|
||||
"author": "Pierce Stegman <pwstegman@gmail.com> (https://github.com/pwstegman)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"console.table": "^0.10.0",
|
||||
"csvtojson": "^1.1.9",
|
||||
"fast-csv": "^2.4.1",
|
||||
"fft.js": "^4.0.3",
|
||||
"mathjs": "^3.16.3",
|
||||
"mathjs": "^3.20.2",
|
||||
"node-osc": "^2.1.0",
|
||||
"opn": "^5.2.0",
|
||||
"pw-csp": "^1.0.0",
|
||||
"pw-lda": "^1.0.0"
|
||||
"pw-lda": "^1.0.0",
|
||||
"pw-stat": "^1.0.0"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "lib"
|
||||
@@ -33,7 +45,19 @@
|
||||
},
|
||||
"homepage": "https://github.com/pwstegman/WebBCI#readme",
|
||||
"devDependencies": {
|
||||
"browserify": "^16.1.0",
|
||||
"docdash": "^0.4.0",
|
||||
"easy-table": "^1.1.1",
|
||||
"fs-then-native": "^2.0.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-jsdoc3": "^2.0.0",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-uglify-es": "^1.0.1",
|
||||
"jsdoc": "^3.5.5",
|
||||
"mocha": "^4.0.1"
|
||||
"jsdoc-to-markdown": "^4.0.1",
|
||||
"mocha": "^4.1.0",
|
||||
"tmp": "0.0.33",
|
||||
"vinyl-buffer": "^1.0.1",
|
||||
"vinyl-source-stream": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
+270
-49
@@ -1,5 +1,8 @@
|
||||
var assert = require('assert');
|
||||
var webbci = require('../index.js');
|
||||
var math = require('mathjs');
|
||||
var tmp = require('tmp');
|
||||
var path = require('path');
|
||||
var bci = require('../index.js');
|
||||
|
||||
// From https://stackoverflow.com/questions/10865025/merge-flatten-an-array-of-arrays-in-javascript/39000004#39000004
|
||||
const flatten = function (arr, result = []) {
|
||||
@@ -14,7 +17,7 @@ const flatten = function (arr, result = []) {
|
||||
return result;
|
||||
};
|
||||
|
||||
function arrayAlmostEqual(arr1, arr2, tolerance) {
|
||||
function arrayAlmostEqual(arr1, arr2, tolerance = 0.00001) {
|
||||
|
||||
var a = flatten(arr1);
|
||||
var b = flatten(arr2);
|
||||
@@ -32,60 +35,145 @@ function arrayAlmostEqual(arr1, arr2, tolerance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
describe('signal', function () {
|
||||
describe('CSP', function () {
|
||||
describe('#project', function() {
|
||||
it('Should return CSP projected data', function () {
|
||||
var a = [[-1, -1], [1, 1]];
|
||||
var b = [[-1, 1], [1, -1]];
|
||||
describe('data', function(){
|
||||
describe('saveCSV and loadCSV', function(){
|
||||
it('Saves an array to and loads an array from a CSV file', function(){
|
||||
var tmpobj = tmp.dirSync();
|
||||
var tmpdir = tmpobj.name;
|
||||
var csvpath = path.join(tmpdir, new Date().getTime() + '.csv');
|
||||
|
||||
var csp = new webbci.signal.CSP(a, b);
|
||||
var array = [[1,2], [3,4], [5,6]];
|
||||
|
||||
var ap = csp.project(a, 2);
|
||||
var bp = csp.project(b, 2);
|
||||
|
||||
assert(arrayAlmostEqual(ap, [[1.414213562373095, 0], [-1.414213562373095, 0]], 0.00001));
|
||||
assert(arrayAlmostEqual(bp, [[0, -1.414213562373095], [0, 1.414213562373095]], 0.00001));
|
||||
bci.saveCSV(array, csvpath)
|
||||
.then(() => {
|
||||
return bci.loadCSV(csvpath);
|
||||
}).then(result => {
|
||||
assert.deepEqual(result, array);
|
||||
})
|
||||
.catch(() => {
|
||||
// saveCSV and loadCSV don't current have error checking
|
||||
// Adding this for future when it is added
|
||||
console.warn('Unable to test saveCSV and loadCSV using temporary files');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('generate and getBandPower', function () {
|
||||
it('Should generate a signal and return the average power in a frequency band', function () {
|
||||
// Generate 1 second of sample data
|
||||
var sampleRate = 512;
|
||||
var duration = 1;
|
||||
var amplitudes = [1, 2, 4, 8];
|
||||
var frequencies = [
|
||||
1, // 1 Hz, delta range
|
||||
5, // 5 Hz, theta range
|
||||
8, // 8 Hz, alpha range
|
||||
17 // 17 Hz, beta range
|
||||
];
|
||||
describe('partition', function(){
|
||||
it('partitions data into subsets such as training and testing sets', function(){
|
||||
assert.deepEqual(
|
||||
bci.partition([1, 2, 3, 4], 0.5, 0.5),
|
||||
[[1,2], [3,4]]
|
||||
);
|
||||
|
||||
var signal = webbci.signal.generate(amplitudes, frequencies, sampleRate, duration);
|
||||
assert.deepEqual(
|
||||
bci.partition([1, 2, 3, 4, 5, 6], 0.6, 0.4),
|
||||
[[1, 2, 3, 4], [5, 6]]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// Get frequency powers in signal
|
||||
var length = sampleRate * duration;
|
||||
var psd = webbci.signal.getPSD(length, signal);
|
||||
describe('round', function(){
|
||||
it('Rounds every value in an array to a set number of decimal places', function(){
|
||||
var arr = [[1.123, 1.55], [5.50000], [17]];
|
||||
var arrRounded = bci.round(arr, 1);
|
||||
assert.deepEqual(arrRounded, [[1.1, 1.6], [5.5], [17]]);
|
||||
});
|
||||
});
|
||||
|
||||
// Compute average power in each frequency band
|
||||
var power_d = webbci.signal.getBandPower(length, psd, sampleRate, 'delta');
|
||||
var power_t = webbci.signal.getBandPower(length, psd, sampleRate, 'theta');
|
||||
var power_a = webbci.signal.getBandPower(length, psd, sampleRate, 'alpha');
|
||||
var power_b = webbci.signal.getBandPower(length, psd, sampleRate, 'beta');
|
||||
describe('subscript', function(){
|
||||
it('Applies MATLAB style subscripting to an array', function(){
|
||||
var data = [[1,2,3], [1,2,3], [1,2,3]];
|
||||
var sub = bci.subscript(data, ":", "1 3");
|
||||
assert.deepEqual(sub, [[1,3], [1,3], [1,3]]);
|
||||
});
|
||||
});
|
||||
|
||||
assert(Math.abs(power_d - 85.333333333) < 0.00001);
|
||||
assert(Math.abs(power_t - 128.00000000) < 0.00001);
|
||||
assert(Math.abs(power_a - 204.80000000) < 0.00001);
|
||||
assert(Math.abs(power_b - 113.77777777) < 0.00001);
|
||||
describe('toFixed', function(){
|
||||
it('Rounds and zero pads as a string every value in an array to a set number of decimal places', function(){
|
||||
var arr = [1, 1.1, [1.12], [1.129]];
|
||||
var fixed = bci.toFixed(arr, 2);
|
||||
assert.deepEqual(fixed, ['1.00', '1.10', ['1.12'], ['1.13']]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toTable', function(){
|
||||
it('Returns an ASCII table representation of an array', function(){
|
||||
var testArray = [[1,2],[3,4]];
|
||||
var tableASCII = bci.toTable(testArray);
|
||||
assert.equal(tableASCII, '0 1\n- -\n1 2\n3 4\n');
|
||||
});
|
||||
});
|
||||
|
||||
describe('windowApply', function(){
|
||||
it('Applies a function over the sub arrays of an array', function(){
|
||||
var data = [[1,2], [3,4], [5,6], [7,8], [9,10]];
|
||||
var features = bci.windowApply(data, window=>math.sum(window), 3, 2, false);
|
||||
assert.deepEqual(features, [21, 45]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('LDA', function () {
|
||||
describe('#project', function () {
|
||||
it('Should compute LDA projected data', function () {
|
||||
describe('math', function(){
|
||||
describe('cspLearn and cspProject', function(){
|
||||
it('Learns parameters for a CSP transformation on a set of signals', function(){
|
||||
var A = [[-1, -1], [1, 1]];
|
||||
var B = [[-1, 1], [1, -1]];
|
||||
|
||||
var params = bci.cspLearn(A, B);
|
||||
|
||||
var Ap = bci.cspProject(params, A);
|
||||
var Bp = bci.cspProject(params, B);
|
||||
|
||||
assert(arrayAlmostEqual(Ap, [[1.414213562373095, 0], [-1.414213562373095, 0]], 0.00001));
|
||||
assert(arrayAlmostEqual(Bp, [[0, -1.414213562373095], [0, 1.414213562373095]], 0.00001));
|
||||
});
|
||||
});
|
||||
|
||||
describe('features', function(){
|
||||
var x = [
|
||||
[1, 1],
|
||||
[2, 5],
|
||||
[3, 3],
|
||||
[4, 1],
|
||||
[5, 5]
|
||||
];
|
||||
|
||||
describe('rootMeanSquare', function(){
|
||||
it('Computes root mean square of every column', function(){
|
||||
var rms = bci.features.rootMeanSquare(x, 'columns');
|
||||
assert(arrayAlmostEqual(rms, [3.3166247903554, 3.492849839314596], 0.00001));
|
||||
});
|
||||
});
|
||||
|
||||
describe('logvar', function(){
|
||||
it('Computes the log of the variance of every column', function(){
|
||||
var logvar = bci.features.logvar(x, 'columns');
|
||||
assert(arrayAlmostEqual(logvar, [0.9162907318741551, 1.3862943611198906], 0.00001));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateSignal', function(){
|
||||
it('Generates a signal given frequencies and amplitudes', function(){
|
||||
var x = bci.generateSignal([10], [5], 256, 1);
|
||||
var y = bci.generateSignal([3], [20], 256, 1);
|
||||
var z = bci.generateSignal([10, 3], [5, 20], 256, 1);
|
||||
|
||||
assert.equal(x.length, y.length);
|
||||
assert.equal(x.length, y.length);
|
||||
|
||||
var same = true;
|
||||
for(var i = 0; i < x.length; i++){
|
||||
if(Math.abs(x[i] + y[i] - z[i]) > 0.00001){
|
||||
same = false;
|
||||
}
|
||||
}
|
||||
assert(same);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ldaLearn and ldaProject', function(){
|
||||
it('Runs linear discriminant analysis on data', function(){
|
||||
var class1 = [
|
||||
[0, 0],
|
||||
[1, 2],
|
||||
@@ -100,7 +188,7 @@ describe('LDA', function () {
|
||||
[9, 9]
|
||||
];
|
||||
|
||||
var lda = new webbci.LDA(class1, class2);
|
||||
var params = bci.ldaLearn(class1, class2);
|
||||
|
||||
var unknownPoints = [
|
||||
[-1, 0],
|
||||
@@ -112,7 +200,7 @@ describe('LDA', function () {
|
||||
];
|
||||
|
||||
var projections = unknownPoints.map(function (p) {
|
||||
return lda.project(p);
|
||||
return bci.ldaProject(params, p);
|
||||
});
|
||||
|
||||
assert(arrayAlmostEqual(projections, [
|
||||
@@ -125,18 +213,151 @@ describe('LDA', function () {
|
||||
]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('psd', function(){
|
||||
it('Computes the power spectral density of a signal', function(){
|
||||
var psd = bci.psd([1,2,1,2,5,2,1,2], {truncate: true});
|
||||
assert(arrayAlmostEqual(psd, [16, 4, 4, 4]));
|
||||
|
||||
psd = bci.psd([1,2,3,4], {fftSize: 2});
|
||||
assert(arrayAlmostEqual(psd, [3, 1]));
|
||||
|
||||
psd = bci.psd([1,2,3,4], {fftSize: 2, truncate: true});
|
||||
assert(arrayAlmostEqual(psd, [3]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('signalBandPower and psdBandPower', function(){
|
||||
it('Computes the average power in a frequency band', function(){
|
||||
var bandPower = bci.signalBandPower([1, 2, 3, 4, 5, 6, 7], 256, 'alpha', 8);
|
||||
var expected = 19.2263;
|
||||
assert(Math.abs(bandPower - expected) < 0.0001);
|
||||
|
||||
bandPower = bci.signalBandPower([1, 2, 3, 4, 5, 6, 7], 256, 'alpha');
|
||||
expected = 19.2263;
|
||||
assert(Math.abs(bandPower - expected) < 0.0001);
|
||||
|
||||
var psd = bci.psd([1, 2, 3, 4, 5, 6, 7]);
|
||||
bandPower = bci.psdBandPower(psd, 256, 'alpha');
|
||||
expected = 19.2263;
|
||||
assert(Math.abs(bandPower - expected) < 0.0001);
|
||||
});
|
||||
});
|
||||
|
||||
describe('nextpow2', function(){
|
||||
it('Returns the ceil of the log2 of the abs of the passed number', function(){
|
||||
var actual = [-32, -30, 9, 8, 7, 4, 3, 0, 1, 30, 32].map(x => Math.pow(2, bci.nextpow2(x)));
|
||||
var expected = [32, 32, 16, 8, 8, 4, 4, 0, 1, 32, 32];
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('backwards compatibility tests', function () {
|
||||
describe('backwards compatibility tests and deprecated methods', function () {
|
||||
describe('signal', function () {
|
||||
describe('CSP', function () {
|
||||
describe('#project', function () {
|
||||
it('Should return CSP projected data', function () {
|
||||
var a = [[-1, -1], [1, 1]];
|
||||
var b = [[-1, 1], [1, -1]];
|
||||
|
||||
var csp = new bci.signal.CSP(a, b);
|
||||
|
||||
var ap = csp.project(a, 2);
|
||||
var bp = csp.project(b, 2);
|
||||
|
||||
assert(arrayAlmostEqual(ap, [[1.414213562373095, 0], [-1.414213562373095, 0]], 0.00001));
|
||||
assert(arrayAlmostEqual(bp, [[0, -1.414213562373095], [0, 1.414213562373095]], 0.00001));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('generate and getBandPower', function () {
|
||||
it('Should generate a signal and return the average power in a frequency band', function () {
|
||||
// Generate 1 second of sample data
|
||||
var sampleRate = 512;
|
||||
var duration = 1;
|
||||
var amplitudes = [1, 2, 4, 8];
|
||||
var frequencies = [
|
||||
1, // 1 Hz, delta range
|
||||
5, // 5 Hz, theta range
|
||||
8, // 8 Hz, alpha range
|
||||
17 // 17 Hz, beta range
|
||||
];
|
||||
|
||||
var signal = bci.signal.generate(amplitudes, frequencies, sampleRate, duration);
|
||||
|
||||
// Get frequency powers in signal
|
||||
var length = sampleRate * duration;
|
||||
var psd = bci.signal.getPSD(length, signal);
|
||||
|
||||
// Compute average power in each frequency band
|
||||
var power_d = bci.signal.getBandPower(length, psd, sampleRate, 'delta');
|
||||
var power_t = bci.signal.getBandPower(length, psd, sampleRate, 'theta');
|
||||
var power_a = bci.signal.getBandPower(length, psd, sampleRate, 'alpha');
|
||||
var power_b = bci.signal.getBandPower(length, psd, sampleRate, 'beta');
|
||||
|
||||
assert(Math.abs(power_d - 85.333333333) < 0.00001);
|
||||
assert(Math.abs(power_t - 128.00000000) < 0.00001);
|
||||
assert(Math.abs(power_a - 204.80000000) < 0.00001);
|
||||
assert(Math.abs(power_b - 113.77777777) < 0.00001);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('LDA', function () {
|
||||
describe('#project', function () {
|
||||
it('Should compute LDA projected data', function () {
|
||||
var class1 = [
|
||||
[0, 0],
|
||||
[1, 2],
|
||||
[2, 2],
|
||||
[1.5, 0.5]
|
||||
];
|
||||
|
||||
var class2 = [
|
||||
[8, 8],
|
||||
[9, 10],
|
||||
[7, 8],
|
||||
[9, 9]
|
||||
];
|
||||
|
||||
var lda = new bci.LDA(class1, class2);
|
||||
|
||||
var unknownPoints = [
|
||||
[-1, 0],
|
||||
[1.5, 2],
|
||||
[3, 3],
|
||||
[5, 5],
|
||||
[7, 9],
|
||||
[10, 12]
|
||||
];
|
||||
|
||||
var projections = unknownPoints.map(function (p) {
|
||||
return lda.project(p);
|
||||
});
|
||||
|
||||
assert(arrayAlmostEqual(projections, [
|
||||
-25.45927601809955,
|
||||
-14.623303167420817,
|
||||
-8.53846153846154,
|
||||
0.9638009049773757,
|
||||
14.633484162895929,
|
||||
28.8868778280543
|
||||
]));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('lda', function () {
|
||||
it('webbci.lda should point to webbci.LDA', function () {
|
||||
assert.equal(webbci.lda, webbci.LDA);
|
||||
it('bci.lda should point to bci.LDA', function () {
|
||||
assert.equal(bci.lda, bci.LDA);
|
||||
});
|
||||
});
|
||||
|
||||
describe('csp', function () {
|
||||
it('webbci.csp should point to webbci.signal.CSP', function () {
|
||||
assert.equal(webbci.csp, webbci.signal.CSP);
|
||||
it('bci.csp should point to bci.signal.CSP', function () {
|
||||
assert.equal(bci.csp, bci.signal.CSP);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
# TODO
|
||||
## General
|
||||
- Add deprecation messages and console logs
|
||||
- Documentation page
|
||||
- Update tests
|
||||
- Add examples to methods in docs
|
||||
- Add path checking to csvLoad
|
||||
- Faster bci.min.js compile and get working with babelify
|
||||
|
||||
## Methods
|
||||
- ICA
|
||||
- Filters (low, high, band, notch, etc.)
|
||||
Referência em uma Nova Issue
Bloquear um usuário