Wednesday, September 19, 2018

Hexoskin App Overlay - Real time display and data recording

The monitoring of respiratory rate and ventilation has value in both power zone demarcation as well as pacing and recovery.  In prior posts multiple examples have been presented as well as supporting literature.  
To that end, I did not want to give up on the real time visual monitoring of respiratory data.  The Hexoskin shirt does have a smartphone app, but as explored previously, there are major issues.  
  • The heart rate can no longer be measured by your usual bike head unit (bluetooth pairing limitation).  
  • The data downloading and formats are not very user friendly.  
  • Scaling of data in the web site is very truncated.
  • Display data size is relatively small so is not very visible on a bike while riding.

My new project was getting around these limitations and create a better front end display as well as generating a very simple .csv file containing the elapsed time, heart rate, breathing rate and ventilation.  Yes, there is an api and a good programmer could write one from scratch, read the bluetooth output of the device and put that into a data storage script. The problem is that although the heart rate is easily seen on the bluetooth output, the ventilation is not.  
Here is the bluetooth spec from Hexoskin for the respiratory data:
Not very user friendly (unless you are a bluetooth programmer)

On the other hand, this is the bluetooth output from a Polar OH1, the Hexoskin heart rate data is identical but the ventilation is in hex and needs substantial math conversion for the result.


The next level of "programming" is more of a scraping and scripting technique.  Trying to get the data through logs, "intents", and notifications.  The logcat was empty and there is no obvious logging to files that I could see.  If the data was sent to the notification bar (in android), it would have been very easy to intercept that, even with the app in the background.  Unfortunately, the Hexoskin app displays a notification but no data is shown.  What I ended up doing is to "scrape" the data from the Hexoskin app display. There is a plugin for the android scripting app Tasker called "autonotification".  This plugin will create a variable for each field on the screen display.  The data can then be "lifted" off the display if the target app is active in the foreground.  So in this case, I need to have the Hexoskin app running in the foreground, then activate my "overlay" which will scrape the data from the display and place it into a .csv as well as showing it in a more user friendly fashion (as an overlay).  Tasker is also able to adjust the display sleep time and brightness for optimal usability while outside.


Notice underneath the black overlay is the regular Hexoskin app in blue (Recording, Show Sensors, 79%).
Using Tasker with autonotification, I was able to get the elapsed time, ventilation (Q), HR, breathing rate.  Then it's just a matter of looping every 1-2 seconds to get a continuous output.  I also placed a "maximum" field to the right of each data point (in color).  The graph in green is the ventilation rate (L/min) and was done with Google graph api (internet connection required) and the last 6 minutes of data.
Here is what the .csv looks like:

Once in this format, it would relatively easy to run numerical averages, range of values over a particular interval, etc. 

After getting your full session of data you can then graph it out with better visual dynamic range than on the Hexoskin web site.
There is a helpful web site called Ploty that one can use to graph out the results.  

Here is an example
First the full ride in one of the created charts:



I circled the 5 min fast start, 1 min max and a 4 min 250 watt interval.  Ventilation is purple, HR is red.  Everything is able to be customized in ploty:


In this case, the 5 min fast start is zoomed in for a better look.  The ability to scale the axis for better discernment is very helpful.
You can also save the graph to a file:

The Hexoskin web display is of course not affected by doing this.  In fact, if there is an artifact (in yellow) it will be present in both overlay data as well as the web page.
For example:



The scaling is a bit different but the flat (?drop out) in ventilation is present in both.
Also, since the scaling is adjustable in ploty, one can better appreciate the rapid swings in ventilation rates

I am still in the process of streamlining the data collection loop, improving the graphing and interface.  Another potential feature could be text to speech over bluetooth.  This could be useful for folks who are running, skiing and therefore can't see the display.  They then can get ventilation/HR data in real time over a wireless bluetooth earbud.
In addition, one could also have the overlay send a notification (of data) which would be displayed on your Garmin watch (since the watch will flash incoming notifications).  A minor issue is that the Hexoskin web app ventilation (L/min) is a "raw" figure but the smartphone app is corrected for size.  I need to clarify what the conversion formula is.

According to Hexoskin tech support it is more than a simple conversion: 
"In fact, there isn't a conversion from the data on the app to the dashboard. The raw data is processed by "lighter" algorithms on the app and "more robust" algorithms on the servers to be displayed on the dashboard.
And the algorithms cannot be shared as they are proprietary to Hexoskin."


Even with this situation, the data is on par with the fully processed web app.


The bottom line is that it is possible to both display the Hexoskin data in a more visually friendly way as well as create a simple .csv file with your data to analyze after the session.

With a little imagination and the power of some clever android apps, real time respiratory data display and data recording can happen.


  • Better on bike visual readability.
  • Extend display time out to hours, increase brightness
  • Show max values (could also potentially show last 10 second average for example)
  • Simple .csv for graphing and spreadsheet calculations


No comments:

Post a Comment