TechnionYearlyProject / DailyPulseMe

A tool that tracks and analyzes your heart rate data during your calendar events, helping you live a healthier life.
https://dailypulse.azurewebsites.net
0 stars 1 forks source link

HRV analysis - time estimated 25 hours #128

Closed yoshoqaz closed 6 years ago

yoshoqaz commented 6 years ago

In this issue I will explain my work and research on the topic of HRV.

At this semester we wanted to add more value to the users experience. In this search for added value I consulted an expert psychologist, she explained the high importance of HRV and that an analysis of it can add a lot of value to our customers. More on HRV and the importance of it can be read here: https://en.wikipedia.org/wiki/Heart_rate_variability https://www.hrvcourse.com/blog Now that the added value of HRV was clear, I started researching the toping and ways of implementing it in our site. The first obstacle I encountered was that for the most accurate HRV measurement, a measurement of the time elapsing between every two consecutive pulses is required. With our measurement watch of xiaomi, this is not possible. So after researching the topic I understood that even without this accurate measurement, the measurement of the change in rate over time says quite a lot and has an effect of a close enough approximation of the accurate HRV measuring for an analysis to be effective. The approximation will be better the smaller the interval the user sets in the application for the measurement. From this knowledge, I wanted to create a graph of HRV stats that will be calculated from the change in the measured heart rate over time with modifications an statistic fixing. This lead to a research of HRV and statistic libraries that may help. I found very few good libraries for this, the one most relevant was in python. Because of the frontend structure, the only option to run python was from the back and from the send the data to be presented in a JS graph. From that I started to write python code to see if I could do what I planned and I manage to create in python an HRV graph with the help of the libraries that made statistic adjustments:

image

But after this work and research we discovered that there were major problems with running python from the back and sending from the back, some of which were solved much later in the NLP part. But the amount of data and events with the general dawdling nature of python made the network traffic time not feasible in this case and so I had to try another direction. There was only one real option, to take the raw data from the backend and make all the necessary calculations in the front. That meant I couldn't use the python libraries so instead I made the calculations and statistic adjustments in JavaScript. But this was still to slow for our website and the HRV graph wouldn't load at all, like many rendering problems we had in the front, but this time f12 and changing the window size didn't help. So I tried to reduce the amount of calculations performed in this stage and add optimizations, untill finally the page managed to load and the graph was presented: image