Anyone Tried using HTM to model blood sugar in diabetics?

Hello.

I hope I’m posting to the correct topic. – My apologies, if not.

I’m visiting my elderly Father who’s had a bout with pneumonia. He’s diabetic and I’ve been helping him with his medications while he gets back on his feet.

As a diabetic, his body doesn’t produce enough insulin to process the carbohydrates in his diet without artificial insulin injections. If the insulin we give him is too little, his blood sugar can get dangerously high. If we give him too much, the level can also drop to dangerously low levels…

As a chemist by training and a software engineer as a career, I’m looking at Dad as a process control problem where we’re trying to dial in the concentration of blood sugars in his bloodstream. – He gave me a funny look when I told him that I’m modeling him as a vat of chemicals…

As process control problem, he’s a pretty high-dimensional one…

I’m not a medical professional, but my surfing the diabetes sites and experience of the last week or show that the following are some (but not all) of the parameters that change with time and influence his blood sugar concentrations:

  • Carbohydrate intake (food)
  • Insulin dosage
  • Insulin type (some formulations have quick and slow acting components)
  • Physical activity
  • Time of day

I can’t help but wonder if something like the Hot Gym example might serve as a starting point to try and develop a predictive model we could use to ‘tune in’ a desired blood sugar reading…

If he really were a vat of chemicals, I’d probably start with something like a PID control algorithm to dynamically adjust insulin dosage throughout the day. These require a pretty dense sampling interval for rapidly changing systems and I think Dad would draw the line at my sticking him every 20 minutes!

I have a friend who’s a software engineer and diabetic. He said something funny in a recent email exchange:

“Diabetes is a thinking persons disease. Be your own pancreas.”

Any thoughts?

Thanks!

John Price

2 Likes

On the meal calculator, you also have to work out the glycemic index for the rate of release of the carbs. (bio-availability over time)

Also - emotional situations can affect this - being emotionally “activated” can end up in a low sugar condition even if everything else is accounted for.

One other very subtle factor is your glycogen loading in the liver. If you have been trending to the high side of your sugar number for a few days (or low) the buffer value of the liver saturates in the high or low direction. In my case that reduces my ability to withstand an insult. Most adults carry ~one days worth of fuel in the liver.

The various interacting fuel tanks are:
gut contents <–> blood contents <–> liver <–> body fat.
Each has different energy capacities.

There are some online calculators that should give you a look at what state-of-the-art is at the moment. You may want to look at these before you move forward in coding this.

https://dtc.ucsf.edu/types-of-diabetes/type2/treatment-of-type-2-diabetes/medications-and-therapies/type-2-insulin-rx/calculating-insulin-dose/

Give your dad my best - this is a very annoying disease to treat correctly. I can say first hand how much hypogylcemia sucks.

Thanks, Bitking!

I’m new to this and greatly appreciate the help. I’ll keep digging into what’s been done before I run too far off ‘into the weeds’!

My friend who gave me the quote also related the huge number of things that can effect the results. He said something along the lines of:

“It is idiosyncratic. Some meds work for some people. Same amount of insulin has different effects for the same number of carbs at different times of day. Sick? Changes. Mood/stress? Changes. Exercise? Really changes. Doing it for another person would be a b***h.”

It’s kind of funny, most of the models I’ve run across have a couple of ‘fudge factors’ in them that need to be tweaked for a given individual and circumstances. For example, the model in the spreadsheet you pointed me to has “sensitivity factor” and “exercise factor” as terms that go into the calculation.

These ‘factors’ are dynamic in nature and I wonder if an HTM model might capture that quality given the right inputs. For example, a time varying exercise factor might drop out if we included data from a FitBit as part of the SDR we used.

Would the ‘sensitivity factor’ fall out as the model learns how blood sugar responds over time to the administration of insulin?

Dunno.

The way the Hot Gym example handles data from the weekend vs. the work week is suggestive that it might be possible…

All thoughts appreciated.

Regards,

John