Latest release is v1.8.0. You can view the release notes at releases
Documentation is available at https://bci.js.org/docs/
npm install bcijs
For a complete list of methods, see the docs.
|Signal Processing||Machine Learning||Data Management|
|Bandpower||Feature extraction||Load and save CSVs (Node.js only)|
|Welch's method||Linear discriminant analysis||Load from EDF (Node.js only)|
|Periodogram||Confusion matrices||Epoch / window data|
|Independent component analysis||Metrics (precision, recall, F1, MCC, etc.)||Partition datasets|
|Common spatial pattern||Array subscripting (colon notation)|
More examples can be found in the examples directory
const bci = ;// Generate 1 second of sample data at 512 Hz// Contains 8 μV / 8 Hz and 4 μV / 17 Hzlet samplerate = 512;let signal = bci;// Compute relative power in each frequency bandlet bandpowers = bci;console; // [ 0.6661457715567836, 0.199999684787573 ]
let samples = 12 34 ... // 2D array where rows are samples and columns are channelslet samplerate = 256; // 256 Hz// Epoch data into epochs of 256 samples with a step of 64 (75% overlap)// Then find the average alpha and beta powers in each epoch.let powers = bci;
const bci = ;// 5 samples of data from 3 channelslet signal = 123 534 456 758 442;// Select the first 3 samples from channels 1 and 3let subset = bci; // [ [ 1, 3 ], [ 5, 4 ], [ 4, 6 ] ]
Linear discriminant analysis
const bci = ;// Training setlet class1 = 0 0 1 2 2 2 15 05;let class2 = 8 8 9 10 7 8 9 9;// Testing setlet unknownPoints = -1 0 15 2 7 9 10 12;// Learn an LDA classifierlet ldaParams = bci;// Test classifierlet predictions = bci;console; // [ 0, 0, 1, 1 ]
Check out https://bci.js.org/examples/lda for a visual demo of how LDA works
Usage in the web
BCI.js can be loaded from the jsDelivr CDN with
You can also find
bci.min.js at releases.
BCI.js methods are accessible via the global object
If building a web distributable using a tool such as browserify or webpack, require
bcijs/browser.js to load only methods that are browser compatible. Node.js specific methods such as networking and file system methods will not be included.
const bci = ;
Requiring specific methods
You can require specific methods as well. For example, if you only need fastICA, you can use
const fastICA = ;
BCI.js methods can be found in the src/ directory.
Files are transpiled from ES6 import/export (in
src/) to CommonJS (generated
Deprecated methods can be found at deprecated.md
See dev.md for info on how to modify and build BCI.js
BCI.js began as WebBCI, a library developed to aid in my research at the Human Technology Interaction Lab at the University of Alabama Department of Computer Science. If you use BCI.js in a published work, please reference this paper
P. Stegman, C. Crawford, and J. Gray, "WebBCI: An Electroencephalography Toolkit Built on Modern Web Technologies," in Augmented Cognition: Intelligent Technologies, 2018, pp. 212–221.
Logo uses icon from Font Awesome.
If you have a commercial use case for BCI.js and would like to discuss working together, contact me at firstname.lastname@example.org