Giter Site home page Giter Site logo

junjunjd / rustymind Goto Github PK

View Code? Open in Web Editor NEW
45.0 3.0 7.0 795 KB

A driver, parser and real time plotter for NeuroSky MindWave EEG headset

License: MIT License

Rust 85.63% Python 14.37%
rust brainwave neuroscience mindwave neurosky plot eeg eeg-headset bci eeg-signals-processing

rustymind's Introduction

rustymind

crates.io api_doc

Rustymind is a driver and parser for NeuroSky MindWave EEG headset written in pure Rust. You can use it to connect, interact, and plot real time brainwave data measured from the headset.

The parser is based on the mindwave mindset communication protocols published by NeuroSky.

See below for a screenshot of real time mindwaves plotted by rustymind-plot CLI based on rustymind parser.

Real time plot screenshot

Getting Started

rustymind-plot takes two arguments to run:

  • MindWave device path. On Mac, the path would be in the format of /dev/tty.usbserial-10000
  • Headset ID (printed inside the battery case)
cargo run --bin rustymind-plot "/dev/tty.usbserial-10000" a05f

If you don't pass in the headset ID argument, the dongle will auto-connect to any headsets it can find.

To use rustymind as a library, you need to use connect_headset function and Parser struct. For example:

use rustymind::{connect_headset, PacketType, Parser};

let mut port = connect_headset("/dev/tty.usbserial-10000", b"\xa0\x5f")?;
let mut buffer: Vec<u8> = vec![0; 2048];
let mut parser = Parser::new();

loop {
    let bytes_read = port.read(buffer.as_mut_slice()).unwrap();
    for i in 0..bytes_read {
        if let Some(x) = parser.parse(buffer[i]) {
            for r in x {
                match r {
                    PacketType::Attention(value) => {
                        println!("Attention value = {}", value);
                    }
                    PacketType::Meditation(value) => {
                        println!("Meditation value = {}", value);
                    }
                    PacketType::AsicEeg(value) => {
                        println!("EEG power values = {:?}", value);
                    }
                    _ => (),
                }
            }
        }
    }
}

This software is not intended to be used in medical diagnostics or medical treatment.

rustymind's People

Contributors

junjunjd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.