A client providing MEA buckets of spike data, where each bucket contains the number of spikes since the last transmission. This is served through a websocket connection. The user can specify how often it should receive data, which again defines the resolution of the data. The client is written in golang.
golang.org/x/net/websocket and guithub.com/satori/go.uuid are needed to run the application.
go get golang.org/x/net/websocket
go get github.com/satori/go.uuid
You also need to have an MEA server running. If you do not have one, a simulator can be found at https://github.com/cyborg-client/offline-server
In order to install the client, simply use go get
go get github.com/cyborg-client/Remap-server
Assuming proper gopath setup, start the application with
go run $GOPATH/src/github.com/cyborg-client/Remap-server/main.go
Configuration is done by editing config/config.go. The entries should be self explanatory.
In order to retrieve data, you must open a websocket connection to the server.
ws://<serverip>:<websocket-port>/data/<every-ms>/
websocket-port
is defined in config/config.go, WebSocketPort. Default is 6480
every-ms
specifies the interval (in millisec) of received data packages
For every-ms milliseconds, the client sends an array with the number of spikes per time interval.
[<ch1>, <ch2>,<ch3>, ... , <ch60>]
Example:
If every-ms is 60 000, represents the number of spikes in channel 1 the last 60 seconds, the number of spikes in channel 2 the last 60 seconds and so on.
You can stimulate a given channel by sending a POST request.
POST /stimulate
Host: <serverip>
{
"frequency": <frequency>,
"duration": <duration>,
"channel": <channel>
}
If you wish to test if the client is running properly, you can use the following javascript code snippet.
(() => {
let ws = new WebSocket('ws://129.241.187.141:6780/data/1000/');
ws.onmessage = (msg) => {
console.log(JSON.parse(msg.data));
};
ws.onclose = () => {
console.log("Server closed connection.")
};
// Closes the connection after 5 seconds
ws.onopen = () => {
setTimeout(() => {
ws.close();
console.log('We closed connection.');
}, 5000);
};
})();
Please note that this script must be run from a website not using https, as the client does not support SSL.
The source code is documented with GoDoc. An offline version of the documentation can be found in the docs folder.
You can read these by opening index.html
or navigating to https://cyborg-client.github.io/Remap-server/.
Please note that GoDocs does not really support offline docs as of now, and some links are not functioning.
If you want to use all the GoDocs features, you can run a local GoDocs server by running the following
go get golang.org/x/tools/cmd/godoc
godoc -http=:6060 -goroot=$GOPATH/src/github.com/cyborg-client/Remap-server
In any web browser, navigate to http://localhost:6060/pkg/github.com/cyborg-client/Remap-server/
Note: When using the local godocs server, in order to show unexported functions, you must pass the ?m=all URL
parameter. For instance http://localhost:6060/pkg/github.com/cyborg-client/Remap-server/websocketserver/?m=all
- Establish connection with MEA server
- Process data from the MEA Server
- Create a websocket interface serving the MEA data
- Add support for stimulation of the MEA server