Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Every Breath You Take – Heart Rate Variability Training (github.com/kbre93)
348 points by kbre93 on Sept 16, 2023 | hide | past | favorite | 118 comments
Through controlled breathing it is possible to regulate your body's stress response. I've built an app to measure and train this effect with a Polar H10 Heart Rate monitor.

With every breath you take, you can set the pace of your breathing rate, measure your breathing control with the chest accelerometer, and see how heart rate variability responds.




Thanks for sharing. I've been dealing with health problems since a covid infection and have been experimenting with breath work. I haven't been able to find something that shows raw, realtime HRV data like this. I tried a HeartMath product at some point, but it was unclear what exactly it was showing and I didn't find it helpful.

The Polar H10 connects to your computer via Bluetooth?


You might want to have a look at this lot. They all have their own little angle on the matter, but there could be one there that would work for you:

https://www.movesense.com/showcase/


Interesting, thanks for sharing. It's cool they do it as a platform, but I'm not sure what the benefit over using a Polar H10 would be, which are widely available, I guess it would be custom branding of the hardware


Yep it's via bluetooth


I have a H10 and i am a tech geek. Just trying this out now will update with my findings.

failed at installing, Collecting pyobjc-core==9.2 Downloading pyobjc-core-9.2.tar.gz (923 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 923.8/923.8 KB 42.8 MB/s eta 0:00:00 Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [2 lines of output]
      running egg_info
      error: PyObjC requires macOS to build
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.


I made two PRs to get the app running on Linux. Unfortunately I now run into bleak/bluetooth errors (maybe related to bluez or missing firmware?)


Thanks ar-jan I’ve merged those and I think the Bluetooth issues are related to security permissions


> error: PyObjC requires macOS to build

Looks like this depends on macOS.


This should be fixed now. Let me know if you still have issues


What's your os? Only been test on macOS so far


I'm on Linux Mint (21.2) and get the same error. Probably macOS only. A quick reading in readthedocs confirms it is macOS only, no Linux, no Windows.


This should be fixed now. Let me know if you still have issues


wow. This is incredible for multiple reasons.

I've seen apps that somehow read what looks like an ecg from the h10, so maybe there's further pretty pictures to be made. Not sure why they'd be helpful, but this is certainly cool to look at.

It's amazing how much information this device throws off, and it all usually gets simplified down to Heart Rate only.

Thanks at the very least for a sample project that I can use to mess with some data acquisition in the future.


Hey no worries and thanks. It was a break-through for this project to find the H10 gives accelerometer data as well as heart rate, so that it would be possible to estimate breathing rate, which I haven't seen other apps do


Isn't it possible to estimate breathing rate with any optical heart rate monitor? See https://en.wikipedia.org/wiki/Photoplethysmogram#Monitoring_..., afaik that's how Fitbit, Apple Watch etc do it


Yes it's common to estimate breathing rate based on the oscillations in the heart rate pattern. But estimating it from the chest expansion is a more direct method


I never knew the H10 used an accelerometer, I wonder if they use it to help remove false reads during intense movements like those found in running.


Polar heart rate monitors work very well; a lot of them also have "5Khz" output which cuts out the whole bluetooth/ANT+ stack - basically they send out a short range inductive pulse at 5KHz on each heartbeat. For a simple demo, plug an old-school telephone pickup (or any old coil) into a soundcard and listen - you'll hear a short click or chirp on each heartbeat (this how most gym kit that is compatible with polar HRM's work).


I'm curious, have you explored compatibility with other hardware as well, like the Polar H7 or even other types of physiological monitors? We've conducted a study comparing Aidlab physiological monitor’s accuracy of heart rate variability measurements with the Polar H7 and found a high correlation in the data. It would be interesting to know how your app performs when paired with various hardware.


The H10 is the gold standard for HRMs and the one most commonly used by anyone doing experimentation with HRV. I don't have the specs memorized off hand, by my recollection is that it does a better job of capturing the entire waveform.


Yep that's right, and the H10 is able to stream the ECG waveform. For this project I used the inter-beat-interval that is sent however, as it means I don't have to run peak detection on the ECG to get heart rate.


The H10 is a newer and better version of the H7. Because breathing rate is measured from chest expansion that is pretty easy to verify (there can be noise in the estimate of course due to movement artefacts). Heart rate estimation from the H10 is widely considered to be reliable, The H10 also offers to ability to stream the raw ecg to check this.


This looks great, I really want to try it!

When trying to run it on my Mac, it crashes with the error message "Info.plist must contain an NSBluetoothAlwaysUsageDescription". I've created an issue: https://github.com/kbre93/every-breath-you-take/issues/9


Hi stenmorten try going into Settings > Privacy & Security > Bluetooth, and adding your terminal application or development environment to the list of applications that are allowed to use Bluetooth


This looks super cool! I just tried it out and am having a hard time following the README.

> The blue circle shows your breathing control

What does this mean?

What should I be looking at?

What should I be aiming for with HRV?


The blue circle is your chest expansions and so when it follows the gold circle you’re controlling your breathing well. Good hrv is above 150 ms and is shown as a green band on the bottom graph


This looks amazing. Have you seen benefits from HRV training? Would it work with other chest strap pulse meters?


Thanks, I've personally found benefits from being to learn to control my breathing in stressful situations.

Right now it only works with the Polar H10, but it would be possible to adapt it if other chest strap monitors have an accelerometer in them.


what about an Apple Watch ? would it be possible to create an app for it ?


You might be interested in this https://www.59breaths.app/


The Apple Watch measured HRV when using the Breathe function in the Mindfulness app. Apps like Health, Training Today, and HRV Tracker can help visualize these readings.


Doesn’t let you measure HRV (so easily, as an application). If you mean using the Apple Watch as the sensor.

There’s a couple of HRV apps for iOS though.



You can get HRV data after a “mindfulness” session, but not in realtime during the session, at least as far as I know. That’s what I meant with not so easily.

I also found that the results don’t match measurements with a HR strap very well, at least for me.


Do you wear this chest strap under your clothes every day?


No, this is just for biofeedback training, so just for a session once a day


The literature is not particularly confident on the benefits of breathwork. A recent meta study found limited positive evidence. They conclude it can probably help some people, but the mechanism is unclear (and I read that as could be placebo). At least it's pretty safe. There's a lot of hype and the few studies that exist are potentially biased.

https://www.nature.com/articles/s41598-022-27247-y


Nice work!

How do you calculate HRV from the series of heart rates? Is it taking the min and max from the latest cycle?


Yep it's taking the difference between peaks and troughs in heart rate, for plotting with the breathing rate it looks at the min and max over the breathing cycle.


So having a very high max and very low min would equate to higher HRV, and better health? Seems a bit perfunctious


It's probably good rule of thumb as the fitter you are the lower rest HR you have and your heart rate recovery rate is also higher.


Exactly. Generally the best athletes have very high max HR and low resting HR but by measuring how quickly and how low your HR goes back down after an exercise is a decent indicator for stress, overtraining etc. If your normal rHR is 55 but it only goes back down to 90 after exercise it most likely shows that you are untrained, stressed or overtraining.


This is measured over a very short time scale though – so not a persons absolute max and min heart rate, just how it varies over a few seconds. And yes, higher HRV is generally healthier and points to a better balance between the fight-and-flight response, and rest-and-digest response.


Has anybody used the H10 to monitor Atrial Fibrillation (aka "afib")? I'd like to use the H10 to collect data that I can share with my physician.


This would be possible I with the Polar H10 I think. The H10 sends raw ECG and analysis on this waveform could be used to find anomalies like afib. I haven't done this myself though.


What do you expect your doc to do with the data? Are you trying to capture very infrequent events or trying to quantify your afib burden?


Just show him what I'm experiencing. Sometimes it's hard to describe in words; try saying this to your cardiologist: "my heart goes thump-thump and then pauses for a second and then goes thump-thump-thump in rapid succession"


Get a Kardia 6 leed ecg device (around 150 USD). They even have one that fits in your wallet.

Heart rate is not enough. You need to look at the QRS and P wave via ECG.


I thought an apple watch identify afib history too.


You have to know if you have afib though, which can be tough to detect for people with infrequent and self limiting cases.

Example; I get bigeminy PACs, which apple watch flags as possible afib when there is noise that obscures the p-wave. But my cardiologist has seen the pattern on a more sensitive device and says it’s not afib.


Also one can have arrhythmia that is not afib


Extremely interesting, this kinda makes me wanna buy a Poler H10 just to keep it monitored.


So, can this monitor heart rate — entirely without smartphone apps or proprietary desktop apps — using “Every Breath You Take” and other open-source apps?

EDIT: Seems like a “no”: https://support.polar.com/en/support/can_i_record_my_heart_r...


I think that link is referring to going for a workout with just the monitor itself to record your heart rate - no other devices present. You can use/build your own mobile or desktop apps without needing their software if that's what you're wondering.

I made a custom iOS app for my wife and I to monitor our workouts using their SDK and I really happy with it


That article is referring to the internal memory that the Polar H10 has, which can be used to store some data. But you will eventually need to connect the device to retrieve that data. You can access this data programatically with a blue-tooth-low-energy client like my application is doing (using python)


I have found HRV to be remarkably accurate at 'predicting' illness (seeming to indicate that HRV is impacted before I notice symptoms). Do others see the same?

I do need to account for 3 other variables:

+ did i drink alcohol that night

+ did i eat a large meal right before bed

+ did i go on a long run (20+ minutes) that day

Those 3 significantly decrease my HRV (alcohol the most). On the other side, not eating within ~6 hours of bedtime significantly increases my HRV, and moderate exercise increases my HRV.

Curious what others are seeing? I have measured with watches and rings - both which only measure at night.


for me:

- alcohol --

- long run or ultra race --- (takes a week to recover)

- early to bed ++

- short to moderate run +

my resting heart rate, sleep respiratory rate, and HRV are highly correlated


I have seem multiple times my HRV indicate my sickness as a leading indicator for strep, food poisoning and altitude sickness, and even for COVID. Anecdata of course


It's an interesting fact that the heart rate increases during inspiration, and decreases during expiration, which is why you can see the red dots following the blue curve on the graph

So if you breathe in a more regular way, it's also normal that your heart rate will vary a little less, since it follows your breathing cycle.

There's definitely also an effect where slow, regular respiration can help with anxiety. But I'm not sure how much of what the tool is measuring is really tied to stress response, versus just demonstrating this direct inspiration/heart rate correlation


The term is “cardio respiratory coupling”. Basically inspiration increases intrathoracic pressure which triggers the CV control mechanism to think BP is higher via the baroreflex and therefore lower HR. If you take an FFT/PSD of pulse waveforms you will actually see a distinct peak at the breathing frequency. This is how a lot of the finger sleep measurement devices work to track breathing without a chest strap.


> inspiration increases intrathoracic pressure which triggers the CV control mechanism to think BP is higher via the baroreflex and therefore lower HR

It seems CRC raises HR during inspiration.

From https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4052709/ "The increase in HR during inspiration is referred to as respiratory sinus arrhythmia (RSA) and the increase in BP as Traube–Hering waves."


This is awesome. I love when people can find a signal in ostensibly disconnected data. This finally answers the nagging question I've had of how my watch can measure my rate of breathing. Thanks for sharing!


> inspiration increases intrathoracic pressure which triggers the CV control mechanism to think BP is higher via the baroreflex and therefore lower HR

But HR is higher during inspiration.


As you breath more slowly, heart rate oscillations (i.e. the variability) increase, which is a reflection of the parasympathetic nervous system activating (the "rest and digest" response). This can help to mediate the stress response, which from the sympathetic nervous system or the fight-or-flight response.


It is interesting that I, and many others, experience our digestive cycle as anxiety.

At certain points in my digestion, my HR spikes, anxiety spikes, impending doom sensations occur.

These are also sensations that happen with pre-stroke SNS responses.

Rest and digest, indeed!


I get something similar in that I start to feel a tiredness come on about 2-5 mins before I start to get gas pains. If I don't help that gas along (by moving or pushing on my stomach) in short order, it turns into me needing to run for the toilet. It's as if the trapped gas, left untreated, triggers a rapid digestive emptying. Or, the cases where I can receive the gas, there's no other contents in the way. The cases where I can't relieve it, well, there's lots of stuff in the way.

Anyways the thing is that I get super tired before the pain in my stomach is even noticed. I've become attuned to it where it now gives me anxiety when it comes on.


Your hyper sensitivity to the gas’s might actually cause the stress, which in turn causes more symptoms. Find a way to relax and let the gas be. Find what works for you: mindfulness, sports, hypnosis, medication… However, try first to focus on normalising your perception of the gas.


I think the "hypersensitivity" line is BS, or at least it's not a complete explanation. In my and others' cases, the "psychiatric" GI symptoms precede the physiological ones. The only time I ever got a straight answer is when I ended up at the hospital because I was passing out, and they said it was likely some combination of low blood pressure and vagus nerve overstimulation.


It is well established that vagus disruption during digestion has all sorts of side effects.

Including anxiety.


Right, point being that's not a psychological hypersensitivity, it's a lower level subconscious physiological process.


Hmm interesting! Maybe I can try measuring my blood pressure during these times of tiredness.


This is called IBS, and is caused by bacteria digesting certain carbs very rapidly. Identify the foods with a low Fodmap diet, figure out the quantity that doesnt trigger issues, and live mostly normally. I cant eat fructose at all, and only small amounts of garlic or onions.


Could this be some kind of food intolerance?


Sounds like it. I found I was gluten and dairy intolerant and removing those foods helped.


I don't interpret that heart rate increase as anxiety, but as the extra workload of digesting food.


It isn't about assigning meaning, it's about your nervous system having an involuntary anxiety reaction to various physiological changes during food digestion.


If you insist. I'm saying I don't have any of the other indicators mentioned -- just the elevated heart rate.


This phenomenon is known as “respiratory sinus arrhythmia” (RSA).


Has anyone here looked at the Movesense(1) hardware / SDK from Suunto? I have seen some claims(2) that its better than the Polar H10.

There are quite a few products based on Movsense (see the showcases) but my experience with two of them is mixed. There seems to be way too much "secret sauce" involved in the processing and presentation of the results. This project looks very interesting from that perspective, but I'm unsure if it would work for the 24x7 monitoring for Cronic Fatigue I'm looking for. (never mind that it's not an app yet :-)

1 https://www.movesense.com/

2 http://www.muscleoxygentraining.com/2020/06/movesense-medica...


Hi, you are welcome to drop us a note directly via [email protected] if you want to discuss the device use in more detail. In general, there is no secret sauce at all: the sensor API is open and you get full access to raw data (ECG, 9-axis IMU at different sample rates). If you want to run your own algorithms on board, you can modify the sensor firmware (C++) with our developer tools.

Companies that use Movesense sensors as a platform to develop their own commercial products naturally have their own ways of analyzing and visualizing the data they measure with the sensor. In commercial projects, companies rarely publish the algorithms they have developed, but some such cases can be found in the Movesense community.

As it comes to sensor accuracy & scientific projects, here is a list of publications and validation studies: https://www.movesense.com/publications/

Best regards, Terho Lahtinen /Movesense


Thanks for dropping by! Yeah it's hard to think of a way to analyze and present the data that would be both 100% "transparent" and useful for all applications. Realistically, With all the data available from these sensors, that's probably not possible :-)


Interesting, thanks for sharing, it looks like it has similar core sensors to the Polar H10, but I'm not sure how it compares overall


Well, the MD I linked to in [2] above, claims that it's more precise for HRV IIRC. Something about sample rates and filters and skewing of the waveform impacting HRV measurements since they depend on precisely locating waveform peaks. (he has a bunch of posts about the Movessense sensor, so I might not have linked the best one)


I've found my HRV (measured by a Garmin watch) directly correlates with my anxiety levels. So much so, that I use it as a marker to check in with myself, because stress and anxiety can quietly creep up ... but my HRV status is always reflective.

It's magic. Like having an accurate anxiety metric, even if the anxiety is purely unconscious.


I've it's quite common for fitness trackers to predict the onset of sickness from heart rate variability. I've found they don't offer much real-time feedback, and don't have breathing detection though which was what I wanted to explore for this project, to train hrv


> don't have breathing detection

FWIW my Garmin watch reports a breath per minute metric. Dunno if this is what you were alluding to.


Right, but I don't think they measure it directly (could be wrong), I think they measure it based on change in heart rate


I can tell I'm sick by looking at my resting heart rate. If it goes up (generally by 5-10 bpm) and I didn't do a hard workout in the past 12-18 hours, I'm pretty likely to be coming down with something.


Is this a feature that some trackers offer? When I worked at Fitbit I noticed this correlation (along with resting heart rate) and developed a model that could predict onset of illness a few days in advance with fairly good accuracy. But unless the accuracy is perfect it can be difficult to offer it as a product feature without a lot of validation and experiments showing that your health related claim is accurate.


They probably are but I’m confused as to how you’ve measured your anxiety level to determine correlation with HRV.

Depending on your answer this leads to the follow-up of why not use that measure?


I have other signals that creep up when my background anxiety levels are high. By anxiety I mean nervous system agitation, not usually conscious.

I wash my hands more, engage in displacement activities, avoid unfamiliar situations or those that trigger perceived emotional stress or threat.

I become snippy and agitated, again, without being conscious of it.

My HRV matches my partners perception of my anxiety levels, which is a reliable measure imho. When it becomes unbalanced and I reflect, I can see that the other signs have ramped up.

If I'm not aware, or told, my HRV tells me and saves anyone pulling me up.


Garmin also has a “stress” metrics but I’ve found it unreliable.


As with all things measured from a wrist worn sensor, and ove the course of the order of a decade of essentially continuous wearing, I've found that the device may be wrong (and completely off the mark at times) but is also mostly right most of the time.

I don't expect anything else for a device I wear loose most of the time (and snug+proper placement when working out) yet it still gives me eerily accurate metrics to work with.


Basically my question is how we’re measuring anxiety to determine correlation.

The OP mentions “unconscious anxiety” which is confusing me, wondering if they are using a questionnaire or something else neat.

If “unconscious anxiety” is being diagnosed based solely on HRV that‘s not how correlation works.


It isn't, as answered elsewhere.

When I mean unconsciously, I mean being unaware in that moment. However reflective hindsight reveals not only correlations in habit, behaviour, and so on but also in hindsight from a calmer frame of mind you can be aware of just how anxious you had become.

Solely based on HRV would be daft. I'm saying it correlates strongly with many other indicators which together are an indicator of my anxiety, realised or not, at that moment.

Ad HRV is a number and other indicators are not, its a great way to have a more quantitative measure which I've found is very helpful. Anecdata and qualitative measures sure, but it works for me.


It def knows when I'm hungover


Oh absolute. Or any number of other chemicals after effects!


Welltory


How does Welltory measure anxiety? Their website just talks about HRV.


This is explicitly part of biofeedback practice, learning to recognize and manage your emotional state through your heart rate.


Do you use the watch or the garmin app? Is it the instantaneous reading you’re looking at or some sort of average?


Mainly during sleep in the morning report.

If I'm anxious during the day, if I realise it or not, my HRV is unbalanced.


Mine correlates directly with sleep, alcohol, and overtraining


It's pretty amazing how much data this relatively cheap device makes available over BLE, and how easy it is to access that data.

Is there a list of health monitoring devices that can be read programmatically without requiring proprietary software or uploading data to the cloud?


I was hoping to intercept and reverse-engineer the protocol of the Oura rings.

For some reason, I thought this kind of device would attract a lot of hackers given the platform capabilities but I could not f8nd any other documented attempt except the really thorough iFixit (destructive) teardown : https://www.ifixit.com/Teardown/Oura+Ring+2+Teardown/135207


I know the device uses BLE - I'd start with seeing if there is any data included in the BLE broadcast


I think most bluetooth low energy devices can be connected to quite easily programmatically as long as you know the data specification. Polar use to publish their data spec on their website but took it down a few years ago so I had to search around to find it.


This is really great! Thank you.

I developed a breathing app (https://www.lungy.app) last year - we're actually doing a study at the moment looking at how heart rate variability changes with breathing exercises. We're using a polysomnograph for gathering the data at the moment - using a Polar H10 may be much simpler. Is it possible to get the raw ECG lead data, or is it just BPM at each time step?


You should probably also look at the Movesense sensor I brought up elsewhere in this thread. Signs are indicating (right here!) that you would find it much better supported for a case like yours :-)


Very nice, yeah the Polar H10 sends raw ECG, as well as the calculated heart rate, so could be what you're looking for.


Amazing - thanks! And for respiratory rate, are you just taking the chest rise and fall from the accelerometer? Would it be obscured by general x,y,z body movement or are you filtering it in some way?

It actually looks much smoother than the trace we get from respiratory inductance plethysmography...


Yes basically, I remove the gravity component by high pass filtering, and then take just the component of acceleration which is along the axis of chest expansion (i.e. pointing out from the sensor) off the top of my head this is the z axis. But this only works when you are sitting quite still, movement introduces a lot of noise to the acceleration


Thanks, now I am manually breathing.


I'm glad


This is really cool! I have a Wahoo Tickr sensor already, is it possible to use with that or is something missing in these other sensors that the Polar has? I'm going to try picking up a Polar for this.


It currently only works with a Polar H10, which has a heart rate monitoring (ECG) and an accelerometer (for measuring breathing rate through chest expansion)


Naming it after a song about a stalker is an interesting choice...


I would not interfere with autonomos rythim of breathing. Do check with someone that knows before you start experimenting with such a primordial and delicate system of your body! Also work on the reasons you get stressed rather than trying to supress it symptoms (is fine to be stressed if a lion is about to eat you by the way)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: