Sleep Tracking #1918
Replies: 8 comments 28 replies
-
Shameless plug: https://github.com/thiswillbeyourgithub/sleep_tracker_pinetime_wasp-os |
Beta Was this translation helpful? Give feedback.
-
I am wondering, I found nothing on Github about this topic before this post, has this idea never come up before? |
Beta Was this translation helpful? Give feedback.
-
Just adding my 2 cents: There's a nice paper on the subject by Olivia Walch, specifically on the topic of sleep tracking with wearables using "raw" sensor data, intended to get some sleep tracking algorithms out in the free open source world: https://academic.oup.com/sleep/article/42/12/zsz180/5549536 Quick summary: they subjected a bunch of people to polysomnography (the gold standard for sleep tracking, in her words) while wearing an apple watch, which they managed to pull raw accelerometer and heart rate data from. They then run a bunch of different classifiers on the data collected with the watch, comparing their performance using the data from the polysomnogram as the "ground truth". They put a lot of work into comparing how well the classifiers work depending on how many data sources they use (accelerometer, heart rate, circadian clock estimate). As far as I recall, the accelerometer data holds the most information and actually goes a long way by itself. Heart rate alone is not worth much, but combining the two is a good improvement over accelerometer alone. There's a slight improvement in also including an estimate of the users' circadian clock, for instance through an activity sensor such as the step counter. I hacked together a small Python script using bleak to collect data from my PineTime. I had to buy an external bluetooth adapter and a long usb extension cable to get a reliable enough connection between my computer and watch throughout the night, my laptop internal adapter was simply too poor. It then worked without a hitch, though. The logging here is on the extreme side, since I'm getting every single update on both the accelerometer and the heart rate: Walch has been kind enough to make both the data they collected and her code publicly available: https://github.com/ojwalch/sleep_classifiers I tried plotting a few of her datasets, and they do resemble the plot above. I think the PineTime heart rate could use a bit of filtering, though (or perhaps it's just because my sample rate is a bit high). Her code is mainly focused on generating the figures for the paper, and I had to spend some time getting the right versions of dependencies and such. My idea was to dig out the actual preprocessing and the parameters of their model after being trained, then try repeating that processing on my data and running the classifier. Of course I don't have any ground truth to compare with, but I think I could borrow a Garmin watch to compare with if nothing else :) A couple more papers I noted as candidates for future reading: |
Beta Was this translation helpful? Give feedback.
-
I created a repo to gather all the information, measurements, codes etc. https://github.com/MelvinRedondoTanis/SleepTracking-PineTime I haven't put much into it yet |
Beta Was this translation helpful? Give feedback.
-
In the end I didn't manage to compile. I could not yet do a test over a long period. for the moment I have not yet bought the adapter but in the meantime I tried to do a little function to detect a significant movement as simply as possible |
Beta Was this translation helpful? Give feedback.
-
Hi! |
Beta Was this translation helpful? Give feedback.
-
I ultimately think that the best thing is to work on an application dedicated to pinetime, even if simplified, sleep monitoring is too demanding for the power of pinetime |
Beta Was this translation helpful? Give feedback.
-
Do you think it could be possible to add this functionality according to the following points ? :
score depends on :
low heart rate + weak movements = deep sleep
down
high heart rate + high movement = light sleep
example formula:
bpm * (movement/2)
Beta Was this translation helpful? Give feedback.
All reactions