Thursday 22 June 2017

GSoC 2017: First Evaluations

My other two blogs were short and sweet. You aren't that lucky this time!
Two months into Google Summer of Code 2017 and First Evaluations being just around the corner, a detailed blog is in order.

As I've mentioned in the introductory blogs, my task, along with Dipankar, is to work on the Biometric sensor's interface for astronauts (though we have very independent roles to play in the same project). The overall project revolves in interfacing the various sensors that measure astronaut's biometrics with the Mars Society's central control system that is built using Tango Controls.

The device we chose for the astronaut (mentioned in the previous blog) took care of most of the sensors we needed.

Now it was time to get dirty with code.
We decided to have good abstraction between various components of the system.
As of now, we have the following modules:
1) anomaly_detector
2) health_monitor
3) hexoskin_helper



These three modules act as packages that the main Health Monitor Tango Device Server would use. So the work on building these three components began, keeping the Tango Device Server for later.

My work was focused on making the Health monitor package and Hexoskin Helper packages.

The hexoskin helper package solely deals with polling the smart shirt and getting the  data from various sensors on-board the shirt in real-time.
The health monitor package acts as the backbone of the system and an interface for the various components and the device server.

The anomaly detector is the pure geek stuff done by Dipankar that contains various algorithms for detecting anomalies in the astronauts' biometric data. Two algorithms has been implemented so far - atrial fibrillation and ventricular tachycardia.  This calls for method in the hexoskin helper that needs to get the desired measurements from the shirt in real-time.
The Atrial Fibrillation requires RR-Intervals and HeartRate Quality, and the Ventricular Tachycardia requires ECG, RR-Intervals,
HeartRate Quality, RR-Interval-Status and Heart Rate.

The Atrial Fibrillation interface in the health monitor - to use the methods and functions from the Anomaly Detector module - was straight forward approach, but the same for the Ventricular Tachycardia was a tricky business because of the complex flow that it follows. Different functions from the Anomaly Detector were run on different threads to get the interface ready. Details about this complex procedure can be found here.

The hexoskin helper is split into 3 parts:
  • Utility helper:- That takes care all non-biometric related stuff like authentication for polling the smart shirt, accessing various records (a live session), etc. Also all the datatypes (the hexoskin biometrics) are defined along with their IDs. This makes it easier to extend the system for more sensors without having a need to dig into the hexoskin documentation, which is excellent.
    The data sample rates are also defined, in 256/samples/second, which makes sure that the data is collected properly from the hexoskin server in batches and with correct sampling rates.
  • Resource helper:- This has all the methods that is used for the data collection - previously collected data as well real-time. Real-time data is collected using generator functions in python, that yield the biometric data every, say, 5 seconds.
  • Database helper:- A small helper file that facilitates the database usage for storing the detected anomalies. 
The database used is SQLAlchemy (ORM - Object Relational Mapping).

Health monitor contains a a simple file that will be imported by the Tango device server. This file acts as an interface between the device server and all the components. It also contains the database where the anomalies are stored.

With the not-so-basic skeleton and the prerequisites for the device server being done, the next phase will be getting these components hooked up with a device server. Also various other anomaly detection algorithms are in queue and will be incorporated into the system.





Sunday 11 June 2017

First week as a GSoCer

Since the amazing birthday present I received last month, life as a GSoC-er has been amazing. Selected under Italian Mars Society (IMS), a sub org. under Python Software Foundation, my task for the summer is to aid missions to mars by working on a Biometric Signal Sensor's Interface.
This project is part of the current studies on the simulation of Astronaut’s Health Monitor Systems.

 When astronauts travels to Mars, or even other planets, they will be exposed to a number of hazards e.g. radiation, microbes in the spacecraft, planetary surface toxic dust. This project mainly revolves around configuring biometric signal sensors.

 The project has an initial phase of surveying the commercial sensors available, and selecting one, or many, after extensive research. The sensors are selected such that they read the biometrics like Heart Rate, Accelerometer data, Respiration rate, body temperature, Pulsioximetry data,Respiratory Volume, ECG, etc.

After the survey, it was found that Hexoskin - a wearable body metrics smart shirt fit the bill.
As their website says, it measures heart rate, HRV, breathing rate, cadence, steps, ECG, sleep positions and a lot more.

The hexoskin smart shirt is used as the device that the astronauts will primarily wear and using which their health will be monitored.

The astronaut wears the smart shirt, plugs in the hexoskin device to the shirt, sync his/her android/iOS mobile (with the hexoskin app installed) and starts exploring Mars. The application on the phone, collects the data in real-time from the shirt and sends it to their server.
This is the data we exploit to monitor the astronaut and detect any sort of anomalies that occur.
The data accessed in real-time from the shirt is sent to a Anomaly Detector - another project under IMS taken up by a friend and a fellow GSoCer - to detect various kind of anomalies, Atrial Fibrillations for starters.

The initial weeks as a GSoCer - after acquiring the device - was quite exciting, especially in the Community Bonding period. Interaction with mentors, fellow GSoC-ers and everyone else in the community has been great.

With a couple of merged pull requests, initial work around getting the data from the smart shirt has been going well.

It's time to speed up development with the first evaluations coming around in a couple of weeks.

As said before, the summer's going to be interesting!