Skip to content

Latest commit

 

History

History
80 lines (57 loc) · 2.65 KB

README.md

File metadata and controls

80 lines (57 loc) · 2.65 KB

NeuroSky Experiments

Analyze sleep using "NeuroSky Thinkgear" EEG sensor.

Device

I was using the "MindCap XL" (MindTec, Amazon) which measures a single EEG signal with NeuroSky's TGAM EEG sensor, and sends data over Bluetooth.

Thinkgear Connector

On OSX Download and install: http://developer.neurosky.com/docs/doku.php?id=thinkgear_connector_tgc

Start ThinkGearConnector.app. It might be easier to run the binary from a terminal, to see the debug output regarding the Bluetooth connection:

/Applications/ThinkGearConnector.app/Contents/MacOS/ThinkGearConnector

Library Code

Files in lib/.

ThinkgearClient

Client for the Thinkgear Connector server. Emits data as specified by the TGSP protocol.

ThinkgearClient.createClient({appName: 'record'}, function(thinkgear) {
  thinkgear.on('data', function(data) {
    console.log(data);
  });
});

Streams

Most files implement a NodeJS Stream. All streams operate on objects of type Sample.

Readable streams:

  • thinkgear/reader: Read EEG values from ThinkGear Connector
  • mongodb/reader: Reads samples from the given collection
  • fft/sine: Generates a sine wave (for testing)

Writable streams:

  • mongodb/writer: Writes samples to the given collection
  • stream/printer: Prints to STDOUT

Transform streams:

Examples

Files in bin/.

record.js

Read samples and store them inin a MongoDB collection

plotRaw.js

Load raw samples from MongoDB and plot them in a web page:

plot.js

Load raw samples from MongoDB, run an FFT frequency analysis, and plot the frequency bands:

sef.js

Load raw samples from MongoDB, run the algorithm from A Low Computational Cost Algorithm for REM Sleep Detection Using Single Channel EEG and plot the "SEFd":