Skip to content

Sending Electroencephalography(EEG) data over Socket.io using Muse EEG headset

Notifications You must be signed in to change notification settings

jeandlouis1/MuseEEG-socket.io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MuseEEG-socket.io

Sending Electroencephalography(EEG) data over Socket.io using Muse EEG headset

This is an example built on the muse sdk example code and socket.io java client code, modified to communicate EEG data to a web server using socket.io.

Installation

create new Constants class due to git ignore for the Constants file. place your ip for port 3000 for socket .io in the android javafile Constants

change public class ConstantsExample to public class Constants

public class Constants{
    //replace with your ip/server address :portserver is listening on
    public static final String CHAT_SERVER_URL = "http://your ip addres:3000";
}
  1. If you are running the the server on your local computer make sure your mobile device is on the same network
  2. Your network setting is set to private instead of public
  • Run the index.js file on the server
  • launch the app

Usage

Server Side snipit

//add other listenners for other signals if you want
	socket.on("alphaData",function(data){
    //send back to requesting client

    //calling function in adroid app to plot the data point on android graph
		socket.emit("alphaDataEcho",{
      point: data
    });
		//console.log(data); for testing
	});

Android Side

emit message from client

mSocket.emit("alphaData",alphaBuffer[0]);
//or 
//perfered
//use the built object wich holds all the main eeg vals
mSocket.emit("alphaData",mEEGdata.getAlphaRef().getelem1());	

recieve message from server

private Emitter.Listener onAlphaDataEcho = new Emitter.Listener() {
        @Override
        public void call(final Object... args) {
            MainActivity.this.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    JSONObject data = (JSONObject) args[0];

                    String point;
                    try {
                        point = data.getString("point");
                    } catch (JSONException e) {
                        Log.e(TAG, e.getMessage());
                        return;
                    }
                    mDataEchoTx.setText(point);
					//plot data if plot is true
                    if(plotData && plot){
                        if(point.equals("NaN")){
                            addEntry(0);
                        }
                        else{
                            addEntry(Float.parseFloat(point));
                        }
                        plotData =false;
                    }
                }
            });
        }
    };

Misc

Problems faced

Extra reff

About

Sending Electroencephalography(EEG) data over Socket.io using Muse EEG headset

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published