BenJabituya
Member since Dec 2020 • Last active Oct 2023Most recent activity
-
There are the .filt values that is bandpass filtered but it has issues with clipping out I guess because they are all 16 bit. It also bandpasses the wrong frequencies at 25Hz I think? I might have a better approach for filtering from the raw signal that I've put a write up on in more detail here:
https://www.majorinput.co.uk/post/bangle-js-2-dealing-with-noisy-ppg-signals
Basically you take a sample of .raw data then:
- apply differencing to remove low frequency noise (subract last value by current in each array element)
- apply differencing again (I didn't mention it in the blog post but it works better doing it twice)
- convolve with a gaussian filter.
With the above, you won't get clipping issues because the values reduce as it's filtered down and you get a much better fourier transform. You could derive the HR by FFT from this even with shorter windows or calculate by peak detection and then based on the average interval/gap in the window. I've got a javascript app that runs on the bangle alligned to this but step 3 in the above is running a bit slow, I'll try getting it to run faster or even try your test harness thing and see how it works at firmware level. To be honest I think the proprietary HR algorythm seems fine so wouldn't change it for HR but this could be useful for HRV if it works ok and replace the filter algorythm.
- apply differencing to remove low frequency noise (subract last value by current in each array element)
-
Hi I originally made a HRV app for the Bangle 1, which I can probably check and change if it's busted since I last updated it. I can definitely make it more efficient. I've been looking at making a similar one for the Bangle 2, which I recently got; it's a great watch but the PPG signal is definitely harder to work with either raw or filtered, signal moves around a lot probably because of the auto-adjustments it seems to make. Will try get something working for it though, I'm trying different options around polling rates and locking the LED auto-adjustment to see if I can get it more stable.
For Sp02, I doubt this would give anything useful - SP02 is usually red + IR light you need to measure not green because your blood absorbs green. I've seen notes on research using different shades of green but not green + IR. You basically do comparisons of the 2 signals to see light absorption at different wavelengths in the same kind of range but because green and IR are so far apart I'm not sure it would work. Datasheet doesn't suggest it has a red LED. It's possible they have a different similar model that uses a red LED instead of the green tailored more for Sp02.
For blood pressure, it looks like you need quite a clean, stationary signal for this. I actually think it's possible to get blood pressure from recorded data out of Bangle 1 easily. The caveat is the algorithm would probably have to be done outside of the watch so would need to use a phone or something that can handle more power and transfer the data by bluetooth or do it retrospectively. The easiest methods I've seen take PPG signals directly and run them through a neural net. The Bangle can run tensorflow so theoretically, if you get a small enough tflite model that can take a low 25Hz signal it could work but I think the pre-filtering you need to do beforehand as well with it might all be too much.
-
Hi, I've not done this myself but there are a couple of options listed in the quick start with guides on connecting to Raspberry Pi - I would personally try the Web IDE method if possible:
https://www.espruino.com/Quick+Start+BLEYou can then just copy the relevant file accross
-
- 10 comments
- 4,600 views
-
Interesting project, I have a Muse S headband, which seems to work well for sleep tracking and brainwave data. On the subject of tracking sleep and general hypnogram cycles I do think indirect data points such as changes in heartrate and movement provide decent info when I benchmark against the Muse - it's not 100% of course but I find it's more practical for regular use. I've been working on a sleeptracker for the Bangle.JS that takes HRM data and movement to attempt charting sleep cycles, it wouldn't take all that much more to put in a smart alarm feature as well as possibly a REM alarm in theory - REM and wakefulness would be towards the peaks of these cycles so you just need to detect peaks and trigger an alarm soon after the descent.
A REM alarm on this would probably need to be via bluetooth to another device as the sound wouldn't be loud enough on the Bangle, and I suspect the motor wouldn't have much effect because of sleep paralysis in REM.
-
Hope your new watch works ok when you get it, FYI on the HRM data exporter app specifically, the -2 doesn't relate to your heartrate directly but the signal from the sensor so it should oscillate somewhere between I think -4 and 4 in normal situations, so your log does look bad but only because it doesn't fluctuate much rather than there being low numbers. Sometimes with mine I do have to adjust the position etc to get good readings at times and it can be sensitive to movement.
-
Hi, some of the code in that should help yes, you can also look at the hrm data exporter, which records the raw signal over a defined time period: https://banglejs.com/apps/#hrm%20data
There is a link in the readme file for that to some more signal processing stuff on my github to process the exported file, that might be a good start point also.
-
@DrBard yep that's basiscally it. BTW there's actually another app that does specific sun and moon calcs which you might want to look at also: https://banglejs.com/apps/#astroc
I'm not getting correct metrics from that app though but again I think it's just because of the acos issue; I've actually found a better function for that now than the one I gave before (Don't know what voodoo magic they do to work these out!): https://developer.download.nvidia.com/cg/acos.html
-
@DrBard should be there in the next few days once it's gone through all the checks etc. You can get it directly from my repo in the meantime also:
https://jabituyaben.github.io/BangleApps/#astral
I've not put the ISS aspect in because I need to think about which API to use, it might work better as a seperate app because this one is already trying to do a lot. -
@DrBard One thing to watch out for is the acos part, which is one of the last calculations you have to do - there is an issue in the Bangle firmware with that function on negative values and you'll get strange results. There are several ways to estimate acos you can find online and I've used one of those for now myself and it's close enough for this kind of thing. It's a known issue but fairly new so fixed for Espruino but it's not in the latest standard Bangle firmware.
function acos_estimate(x) {
return (-0.69813170079773212 * x * x - 0.87266462599716477) * x + 1.5707963267948966;
}
hardware hacking hobbyist, projects vary wildly at times but mainly concern biofeedback/health and game dev