hemokit: Haskell port of the Emokit EEG project

[ bioinformatics, library, mit, program ] [ Propose Tags ] [ Report a vulnerability ]

This package allows reading raw data from the Emotiv EPOC EEG devices.

It is inspired and based on the code of the Emokit project (https://github.com/openyou/emokit), but entirely written in Haskell.

It contains an extensive, well-documented library for connecting to devices, decrypting the stream, and parsing the relevant data out.

Data can be read from a given device via HIDAPI-hidraw or a dump file; reading from multiple devices is supported and when only one EEG is to be used, the correct device is automatically selected.

There is also an executable, hemokit-dump, that can print out

  • raw data

  • incremental packets as sent from the device

  • the cumulative state of the EEG

in both their plain form and as JSON, and optionally serve any of this via Websockets.


[Skip to Readme]

Flags

Automatic Flags
NameDescriptionDefault
fft

Enable apps that use FFT. Needs fftw installed.

Enabled
headmap

Build the headmap. Needs GUI libraries installed.

Enabled
mouse

Build the app that controls the mouse with the gyroscope. Needs Xorg and related libraries installed (so it only works on Linux for now).

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.4.0, 0.4.1, 0.4.2, 0.5, 0.5.1, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.6.6
Dependencies aeson (>=0.6.1.0), base (>=4 && <5), base64-bytestring (>=1.0.0.1), bytestring (>=0.9.2.1), cairo (>=0.12.4), cipher-aes (>=0.2.0), conduit (>=1), deepseq (>=1.2), deepseq-generics (>=0.1), gtk (>=0.12.4), hemokit, hidapi (>=0.1.2), mtl (>=2.1.2), network-simple (>=0.4.0.2), optparse-applicative (>=0.11), pretty-show (>=1.0), robot (>=1.3.0.1), split (>=0.2.2), svgcairo (>=0.12.1.1), text (>=0.11.1.1), time (>=1.4), transformers (>=0.3.0.0), vector (>=0.9), vector-fftw (>=0.1.3.1), websockets (>=0.8.0.0) [details]
Tested with ghc ==7.6.3, ghc ==7.8.1
License MIT
Copyright 2013 Niklas Hambüchen <mail@nh2.me>, Patrick Chilton <chpatrick@gmail.com>
Author Niklas Hambüchen <mail@nh2.me>, Patrick Chilton <chpatrick@gmail.com>
Maintainer Niklas Hambüchen <mail@nh2.me>
Category Bioinformatics
Home page https://github.com/nh2/hemokit
Bug tracker https://github.com/nh2/hemokit/issues
Source repo head: git clone git://github.com/nh2/hemokit.git
Uploaded by NiklasHambuechen at 2015-08-19T03:36:56Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables hemokit-headmap, hemokit-fft, hemokit-dump-conduit, hemokit-dump, hemokit-mouse
Downloads 8612 total (31 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-08-19 [all 1 reports]

Readme for hemokit-0.6.6

[back to package description]

hemokit

Haskell library and tool suite for the Emotiv Epoc EEG, inspired by the Emokit code.

It currently only works on Linux and Windows - patches for other platforms are welcome, they should be trivial.

Download

You can download pre-built binaries here, or build it yourself via cabal install hemokit.

Library Features

  • device discovery via hidapi
  • decryption of the raw data (one-to-one port from from Emokit)
  • convenient access to sensor values, gyro, qualities, battery, and raw data

Programs

Hemokit comes with example programs to

  • hemokit-dump print out the current EEG data
  • hemokit-mouse move the cursor using the gyro

Note that we have to use sudo in most of the cases because the HIDAP-hidraw implementation reads directly from a device file.

hemokit-dump - Examples

hemokit-dump can print EEG data, format it as JSON, serve it via TCP or Websockets, and read from real devices and dump files.

  • Output EEG cumulative state for an automatically found device:

    sudo hemokit-dump
    
  • Select one of many connected EEGs by serial number:

    sudo hemokit-dump --serial SN...GM
    
  • Output only the data the device sends (no cumulative state), and format the output as JSON:

    sudo hemokit-dump --mode packets --format json
    

    The --format flag allows you to change the way the output is printed. The output of --mode state --format spaced is especially easy to work with.

  • Instead of from a real device, read data recorded to a file, and serve it via JSON over a TCP server on port 1234:

    sudo cat /dev/hidraw1 > encrypted.dump  # Dump data to a file
    sudo hemokit-dump --from-file encrypted.dump --serial SN...GM --serve 0.0.0.0:1234 --format json
    

    Here you have to specify the serial since HIDAPI is not used to obtain it automatically.

    If you prefer a Websockets server over a raw TCP server, use ws://0.0.0.0:1234 instead.

  • Output decrypted raw data to stdout:

    sudo hemokit-dump --mode raw
    
  • Both print the data from the EEG and store the original data for later use:

    sudo cat /dev/hidraw1 | tee >(hemokit-dump --from-file - --serial SN...GM --format json) > encrypted.dump
    

    We use tee and shell process substitution to duplicate the data stream, and tell hemokit-dump to read from - (stdin).

Connecting with other Programs

  • To use Hemokit as a data source from OpenVibe, check out the corresponding entry in the Wiki
  • To read Hemokit data from Matlab, I recommend publishing the data on a local socket in text format using hemokit-dump --format spaced --serve 127.0.0.1:1234. Then you can read it with code like:
t = tcpip('127.0.0.1', 1234);
fopen(t)
data = fscanf(t, '%d');