EmBCI Applications

A full list of current applications


TODO: write doc for working flow of embci.webui & embci.apps

Getting started (developers)

EmBCI has an example project at embci.apps.example link, which is a good place to start developing your own app. Also there are some basic apps in this folder. Once you’ve found a similar app like yours, you can copy that project folder and go through the source code, modify them and build yours.

Let’s see some basic apps come with EmBCI:

  • auth: Authentication system (under developing).

  • baseserver: Simple HTTP server used to host static files.

  • recorder: Record and save stream data into .mat or .fif file.

  • streaming: Create a global data-stream as a data broadcaster.

  • system: Some commands deeply relied on operation system.

  • DisplayWeb: HTML & JS based realtime signal visualization tool.

  • DBS: Deprecated in v0.2.0. Assistant application to rehabilitate Parkinson’s Disease patients after Deep-Brain-Stimulation operation.

  • MotorImagery: EEG classification applet by Motor Imagery (under developing).

  • sEMG: Hand gesture recognition by classification on sEMG bio-signal (legacy).

  • Speller: SSVEP-based mind-typing system.

  • SignalInfo: Display information of biosignal marks by Matplotlib.

  • WiFi: Search, display and connect to WiFi hotspots through WebUI (mostly used on EmBCI device).

WebUI

You see the awesome webpages of apps in EmBCI like Speller and Visualization? If you want to integrate an user interface into your application, EmBCI provides you a easy-extenable web-based one! Simply create a ``bottle` <https://bottlepy.org/docs/dev/>`_ loadable HTTPServer to handle HTTP requests and assign this server object to a variable named application in __init__.py. And that’s all! Just leave all other jobs to embci.webui apps auto-loader.

Note

  • bottle loadable HTTPServer means:

    • bottle built-in HTTP development servers based on bottle.ServerAdapter

    • paste, fapws3, bjoern, gae, cherrypy… ..

      run python -c "import bottle; print(bottle.server_names)" to see more supported servers.

    • any other WSGI capable HTTP server

  • URL of user apps will be http://${EmBCI_WEBUI_HOST}/apps/${MyApp}. If your server will respond “helloworld” when index.html is requested, you will see the “helloworld” string by GET http://${EmBCI_WEBUI_HOST}/apps/${MyApp}/index.html

  • Neccessary files used in web application must be added to correct folder, such as js/* and css/*. You can use either local resources or embci.webui global resources, for example:

    • use syntax <script src="js/common.js"></script> to access file at ${MyApp}/js/common.js.

    • use syntax <img src="/images/logo.png" alt="EmBCI logo"> to access file at ${embci.webui.__basedir__}/images/logo.png.

Example of bottle built-in server

# content of NewApp/__init__.py
import os
import bottle
__basedir__ = os.path.dirname(os.path.abspath(__file__))

@bottle.route('/index.html')
def index(name):
    name = bottle.request.get_cookie('name', 'new_guest')
    if name == 'new_guest':
        bottle.respond.set_cookie('name', 'testing')
    return bottle.template(os.path.join(__basedir__, 'index.html'), name=name)

application = bottle.default_app()
<!--# content of NewApp/index.html-->
<html>
<head>
    <meta charset="utf-8">
    <title>example</title>
</head>
<body>Hello {{name}}! Welcome to my WebApp!</body>
</html>

Result of accessing URL http://${EmBCI_WEBUI_HOST}/apps/newapp/index.html will be string Hello new_guest! Welcome to my WebApp!

Example of Flask

# content of MyApp/server.py

# content of MyApp/__init__.py
from .server import server as application