Biosensor-Framework 1.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Biosensor-Framework --version 1.0.0
NuGet\Install-Package Biosensor-Framework -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Biosensor-Framework" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Biosensor-Framework --version 1.0.0
#r "nuget: Biosensor-Framework, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Biosensor-Framework as a Cake Addin
#addin nuget:?package=Biosensor-Framework&version=1.0.0

// Install Biosensor-Framework as a Cake Tool
#tool nuget:?package=Biosensor-Framework&version=1.0.0

Biosensor Framework: A C# Library for Affective Computing

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.

Basic Usage

        public static ServerClient Device1;
        static ServerClient client;
        public static MLContext mlContext;
        public static ITransformer Model;
        public static DataViewSchema ModelSchema;
        // TODO: Fill these out with your own values
        public static string APIKey = "";
        public static string ServerPath = @"";
        public static string WesadDirectory = @"";
        public static string SessionOutputPath = @"";

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").

Next the Microsoft.ML variables are created.

        static void Main(string[] args)
        {
            mlContext = new MLContext();
            Train.RunBenchmarks(WesadDirectory, out ITransformer RegModel, out ITransformer MultiModel, out Model);
            Console.ReadKey();

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.

            Console.WriteLine("E4 Console Interface - Press ENTER to begin the client");

            Console.WriteLine("Step 1 - Start Empatica server");
            Utilities.StartE4ServerGUI(ServerPath);

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.

            client = new ServerClient();
            Console.ReadKey();
            client.StartClient();
            Utilities.StartE4Server(ServerPath, APIKey);

The E4 server can also be started through the command line variant as shown.

            Console.WriteLine("Step 2 - Getting connected E4 devices");
            Utilities.ListDiscoveredDevices(client);
            Console.ReadKey();
            Console.WriteLine("     Available Devices:");
            Utilities.AvailableDevices.ForEach(i => Console.WriteLine("     Device Name: {0}", i));
            Console.ReadKey();

Listing the connected devices will show all devices connected through the Bluetooth dongle. These are managed internally.

            Device1 = new ServerClient();
            Device1.StartClient();
            Device1.DeviceName = Utilities.AvailableDevices[0];
            Utilities.ConnectDevice(Device1);
            Console.ReadKey();

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.

            Utilities.SuspendStreaming(Device1);

Since there are configurations to be done on the device, the streaming needs to be suspended.

            Console.WriteLine("Step 3 - Adding biometric data streams");

            foreach (ServerClient.DeviceStreams stream in Enum.GetValues(typeof(ServerClient.DeviceStreams)))
            {
                Thread.Sleep(100);
                Console.WriteLine("     Adding new stream: " + stream.ToString());
                Utilities.SubscribeToStream(Device1, stream);
            }

Each available device stream is assigned, but any number of streams can be assigned.

            Utilities.StartStreaming(Device1);
            var timer = Utilities.StartTimer(5);
            Utilities.WindowedDataReadyEvent += PullData;

            Console.WriteLine("ENTER to end program");
            Console.ReadKey();
        }

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.

        private static void PullData()
        {
            var watch = Stopwatch.StartNew();
            var WindowData = Utilities.GrabWindow(Device1, Path.Combine(SessionOutputPath, "Readings.data"));
            var pred = Predict.PredictWindow(mlContext, Model, WindowData);
            watch.Stop();
            Console.WriteLine("Time: {0} | Prediction: {1}", DateTime.Now, pred.Prediction);
            Console.WriteLine("Processing Time: {0}", watch.ElapsedMilliseconds);
        }

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.

Class Documentation

Biosensor Framework Documentation

Contact

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 (james.gehringer@unmc.edu). For technical questions, please address Walker Arce (walker.arce@unmc.edu).

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated