-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zenodo.json
14 lines (14 loc) · 6.57 KB
/
.zenodo.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"description": "Biosensor Framework: A C# Library for Affective Computing\n<p>C# library that handles the full process of gathering biometric data from a body-worn sensor, transforming it into handcrafted feature vectors, and delivering an inferencing result in thirty-five lines of code.</p>\nNuGet Gallery Link\n<p><a href=\"https://www.nuget.org/packages/Biosensor-Framework/\">NuGet Package Link</a></p>\nBasic Usage\n<pre><code> public static ServerClient Device1;\n static ServerClient client;\n public static MLContext mlContext;\n public static ITransformer Model;\n public static DataViewSchema ModelSchema;\n // TODO: Fill these out with your own values\n public static string APIKey = \"\";\n public static string ServerPath = @\"\";\n public static string WesadDirectory = @\"\";\n public static string SessionOutputPath = @\"\";\n</code></pre>\n<p>For each project, a client connection is established using the ServerClient class. This handles the TCP initialization, command communication, and error handling. Each device will have its own ServerClient instance, so Device1 is represented by a device name and a TCP connection. Additionally, the API key and the path to the server executable need to be defined. The API key can be found by following Empatica's directions from the Installation section. The path to the server is found in the installation directory for the server (i.e. @\"{installation path}\\EmpaticaBLEServer.exe\").</p>\n<p>Next the Microsoft.ML variables are created.</p>\n<pre><code> static void Main(string[] args)\n {\n mlContext = new MLContext();\n Train.RunBenchmarks(WesadDirectory, out ITransformer RegModel, out ITransformer MultiModel, out Model);\n Console.ReadKey();\n</code></pre>\n<p>In this example, the models are trained on the WESAD data using the RunBenchmarks function. The best performing models for each class are output. For this example, the binary classification model (BinModel) is used.</p>\n<pre><code> Console.WriteLine(\"E4 Console Interface - Press ENTER to begin the client\");\n\n Console.WriteLine(\"Step 1 - Start Empatica server\");\n Utilities.StartE4ServerGUI(ServerPath);\n</code></pre>\n<p>The E4 server is started through a Process call. This will open the GUI for the server, if that is not desired, the command line variant of the command can be called.</p>\n<pre><code> client = new ServerClient();\n Console.ReadKey();\n client.StartClient();\n Utilities.StartE4Server(ServerPath, APIKey);\n</code></pre>\n<p>The E4 server can also be started through the command line variant as shown.</p>\n<pre><code> Console.WriteLine(\"Step 2 - Getting connected E4 devices\");\n Utilities.ListDiscoveredDevices(client);\n Console.ReadKey();\n Console.WriteLine(\" Available Devices:\");\n Utilities.AvailableDevices.ForEach(i => Console.WriteLine(\" Device Name: {0}\", i));\n Console.ReadKey();\n</code></pre>\n<p>Listing the connected devices will show all devices connected through the Bluetooth dongle. These are managed internally.</p>\n<pre><code> Device1 = new ServerClient();\n Device1.StartClient();\n Device1.DeviceName = Utilities.AvailableDevices[0];\n Utilities.ConnectDevice(Device1);\n Console.ReadKey();\n</code></pre>\n<p>To connect a device, it needs to be assigned one of the available devices. Once that's done, the ConnectDevice function can be called and its TCP connection will be established.</p>\n<pre><code> Utilities.SuspendStreaming(Device1);\n</code></pre>\n<p>Since there are configurations to be done on the device, the streaming needs to be suspended.</p>\n<pre><code> Console.WriteLine(\"Step 3 - Adding biometric data streams\");\n\n foreach (ServerClient.DeviceStreams stream in Enum.GetValues(typeof(ServerClient.DeviceStreams)))\n {\n Thread.Sleep(100);\n Console.WriteLine(\" Adding new stream: \" + stream.ToString());\n Utilities.SubscribeToStream(Device1, stream);\n }\n</code></pre>\n<p>Each available device stream is assigned, but any number of streams can be assigned.</p>\n<pre><code> Utilities.StartStreaming(Device1);\n var timer = Utilities.StartTimer(5);\n Utilities.WindowedDataReadyEvent += PullData;\n\n Console.WriteLine(\"ENTER to end program\");\n Console.ReadKey();\n }\n</code></pre>\n<p>When the device has streaming restarted, it will begin collecting data as quickly as the server sends it. The window size for this example is 5 seconds, but can be any length. An internal timer will trigger an event at each expiration and then reset. Ending the program can be done by pressing the 'Enter' key.</p>\n<pre><code> private static void PullData()\n {\n var watch = Stopwatch.StartNew();\n var WindowData = Utilities.GrabWindow(Device1, Path.Combine(SessionOutputPath, \"Readings.data\"));\n var pred = Predict.PredictWindow(mlContext, Model, WindowData);\n watch.Stop();\n Console.WriteLine(\"Time: {0} | Prediction: {1}\", DateTime.Now, pred.Prediction);\n Console.WriteLine(\"Processing Time: {0}\", watch.ElapsedMilliseconds);\n }\n</code></pre>\n<p>The data can be manipulated once the timer expires for the window size. The data can be grabbed by the GrabWindow function, which also can be fed a filepath to write the readings to a data file. Predictions can be done on the raw data using the PredictWindow function and a prediction is returned in a simple structure that contains the output bool.</p>\nClass Documentation\n<p><a href=\"https://github.com/Munroe-Meyer-Institute-VR-Laboratory/Biosensor-Framework/blob/main/BiosensorFramework/BiosensorFrameworkDoc.md\">Biosensor Framework Documentation</a></p>\nContact\n<p>To address issues in the codebase, please create an issue in the repo and it will be addressed by a maintainer. For collaboration inquiries, please address Dr. James Gehringer ([email protected]). For technical questions, please address Walker Arce ([email protected]).</p>",
"license": "MIT",
"title": "Munroe-Meyer-Institute-VR-Laboratory/Biosensor-Framework: Biosensor-Framework",
"creators": [
{
"name": "Walker Arce"
},
{
"name": "James Gehringer"
}
],
"access_right": "open"
}