nightscout / cgm-remote-monitor

nightscout web monitor
GNU Affero General Public License v3.0
2.36k stars 71.35k forks source link

Adding sports/exercise, heart rate and sleep information to the NS database #5635

Open juehv opened 4 years ago

juehv commented 4 years ago

Is your feature request related to a problem? Please describe. We at Technical University Darmstadt are researching CGM prediction algorithms. We used NS Datasets in the past, and supporting people often offer NS database dumps. We figure that it's helpful to consider readings from fitness trackers such as sport, exercise, heart rate, stress, and sleep information that is sadly not available in NS. We think it would be beneficial to combine the data at one point and we think NS is the right place, as some apps (such as xDrip) already reading that information but not uploading (as it is not supported).

Describe the solution you'd like We would like to have a plugin (or multiple depending on the design) to save the sport, exercise, heart rate, stress, and sleep information. We propose the following format for the entry table:

[ { "type": exercise, "dateString": ISO string, "date": unix timestamp, "duration": duration of exercise whereby date is the end point, "load": [low, mid, high, null] } ]

[ { "type": [hr, stress], "dateString": ISO string, "date": unix timestamp, "value": [heart rate in hz or stress as integer from fitness tracker usually between 0 and 100] } ]

[ { "type": sleep, "dateString": ISO string, "date": unix timestamp, "duration": duration of sleep whereby date is the end point, "phase": [light, deep, rem, null] } ]

According to the developer guide, we open this issue first, to get feedback from the community and find people to help us developing the plugin.

miriamkw commented 8 months ago

Hi @juehv, I see I am three years late for this post, but are you still interested in adding these features? I am willing to contribute in the development.

bewest commented 8 months ago

Howdy all, I'll add this as a project/discussion. Would anyone be interested in helping to lead a regular digital meeting for people interested in this topic? I've talked to 4 or 5 folks over the last year who are interested in this in addition to other metrics. There are three other major themes that also require some major work: profiles (make suitable for modern AID expectations), reports: reproducible and accuracy, security and authentication. This area discussing additional data is worthwhile and requires a fair amount of collaboration to make it successful.

If someone can volunteer to lead a meeting, I can make sure the variety of folks I've talked to that are interested in this are invited.

miriamkw commented 8 months ago

Sounds interesting, Ben! I see you (?) have already created a route for /activity in the API.

I could lead a meeting in terms of scheduling and planning an agenda. However, as I am new to the repository and not yet proficient in implementing best practices, I would prefer to follow instructions rather than giving them.

juehv commented 8 months ago

@miriamkw @bewest I'm still interested in the feature, but I thought back in the day, with the low feedback it won't have any chance to be merged to master. Let me know when you start the planning and meeting phase!

miriamkw commented 8 months ago

@miriamkw @bewest I'm still interested in the feature, but I thought back in the day, with the low feedback it won't have any chance to be merged to master. Let me know when you start the planning and meeting phase!

Did you ever develop this, although it did not get merged?

I am working on some code for this. However, the purpose is only to run some experiments just for fun, to test real-time CGM prediction algorithms (on myself), not for large-scale research projects. My solution consists of (1) writing a python api defining schemas for reading and writing to the "/activity" route in NS, and (2) developing an iOS application that uploads my Apple Watch data to the NS API in real-time. Let me know if you are interested in the code.

juehv commented 8 months ago

No I didn't develop any of this. I hat some tries in AAPS which never got merged as the features where not welcome. Since then I ask first to make sure the work is not wasted.

Your plan sounds very interesting. I'd love to hear more about the cgm prediciton algorithms :)

miriamkw commented 8 months ago

Your plan sounds very interesting. I'd love to hear more about the cgm prediciton algorithms :)

The prediction algorithms were just off-the-shelf models and others implemented models (for example from KDH). I created an iPhone app and tested different algorithms in my treatment, using input features also for physical activity, sleep etc. Looking forward, I want to prototype new models, based on the weaknesses I found.