https://maori.geek.nz/the-unreasonable-math-of-type-1-diabetes-8c96bdf5b7fb?gi=a3b25a4cbeb0 Home Notifications Lists Stories --------------------------------------------------------------------- Write Maori Geek Published in Maori Geek * Follow Graham Jenson Graham Jenson * Follow Feb 17 * 13 min read The Unreasonable Math of Type 1 Diabetes This is not medical advice, don't base any treatments on this. In January 2022, our 18 month old son, Sam, was diagnosed with Type 1 Diabetes (T1D). This was stressful, sad, and scary as we spent 5 days in hospital with him while he recovered from Diabetic Keto Acidosis (DKA). Within an hour of him being diagnosed a wonderful diabetes nurse gave us a literal backpack filled with books and information we needed to learn to keep him alive. We started to read and try to understand what it takes to manage T1D. Immediately the massive cognitive overhead it takes to just survive with this condition hit us. I find the best way to learn something is to try explain it to someone else. This post is me trying to explain the maths involved in managing T1D, with a few small rants about how shit it is. Food Go Up, Insulin Go Down Insulin is a molecule created by the pancreas that lets glucose from blood enter cells to be used as energy. T1D is an autoimmune disease where the immune system attacks the insulin creating cells until the pancreas stops creating insulin altogether. T1D means you have a faulty pancreas; there is no cure, no diet that fixes it and you don't grow out of it. It is a lifelong condition that you have to manage 24 hours a day. Glucose enters the blood when you eat basically anything, but especially carbohydrates. Without insulin glucose will build up in the blood, eventually causing your body to enter a state called Diabetic Keto Acidosis (DKA), then coma, then death. Insulin must be added to lower the amount of glucose in the blood. Too much insulin and your glucose level will go too low and you go Hypoglycaemic (hypo), then coma, then death. Managing T1D is walking on a knifes edge between DKA and Hypoglycemia by balancing blood glucose levels with insulin. The units of T1D math are: 1. Insulin is measured in units (u), typically 100 units per 1ml. 2. Blood Glucose Level (BG or BGL) is measured in mmol/L (in USA its mg/dL which is mmol/L*18). 3. Carbohydrates are measured in grams (g). Successfully managing T1D means keeping BGL between 4-8 mmol/L (72-144 mg/dL). Between 4 and 8 is the goal, but a full day in that range almost never happens. The two main levers to achieve this goal are: 1. Eat carbs to make BGL go up. 2. Inject insulin to make BGL go down. Those are the basics of managing T1D, but there is so much more. Carbohydrate Counting Eating carbohydrates increases blood glucose, counting carbs to know how much you eat is a requirement. Fortunately, most food has a label like this bread: [1] This bread is 40.1g of carb per 100g (i.e. 40.1% carb) and in 2 slices of the bread is 25g of carb. Carbohydrates are absorbed by the body at different rates. For example, here is the rate at which pure glucose is absorbed compared to bread (glycemic response curve): [1] Dotted lines are glycemic response curves for different foods for someone without T1D [Bellman et al.] The glycemic curve for both glucose and bread peak at 30-40 minutes, but glucose rises BGL much faster. That rise is measured using the Glycemic Index (GI) where a higher GI food raises BGL faster. For example, the GI for white bread is 70, wheat bread is 50, so white bread will raise BGL faster than wheat. By knowing the total carbs and the GI of a food, we get an idea of the glycemic response curve and the impact on BGL. Insulin Curves Managing T1D means injecting insulin to reduce blood glucose. There are different types of insulin with different rates of release: [1] With the "onset of action", "peak of action" and "duration of action" we can get an idea about how these insulins work. [1] A unit of any type of insulin is equivalent. This means we can mix and match the different types to get the desired curves we want. The most common way to mix insulins is called the Basal-Bolus therapy: * a Basal is long lasting insulin (e.g. protaphane) taken 1-2 times a day. * a Bolus is fast acting insulin (e.g. novorapid )taken with each meal. Adding a basal and bolus together we can get an insulin curve closer to the glycemic response: [1] Everybody is different So know we know that carbs make BGL go up; insulin makes BGL go down. But by how much? Before we can do any calculations, there are three variables we need to define relationships between (insulin, carbs and BGL). Since "How much insulin do I need?" is the most common T1D question, it is practical to relate carbs and BGL to units of insulin: 1. The Carbohydrate Ratio (CR) is the ratio of 1 unit of insulin to grams of carb, e.g. a ratio of 1:25 (or just 25) means that if you eat 25g of carbs (2 slices of bread) you need 1u of insulin. 2. The Insulin Sensitivity Factor (ISF) is the ratio of 1 unit of insulin to mmol/L BGL, e.g. an ISF of 1:6 (or just 6) means if you take 1u of insulin your BGL will drop by 6 mmol/L. 3. Since ISF and CR are related to 1u of insulin, then ISF:CR is the third relationship. With ISF and CR we can answer the common questions for T1D: 1. How much insulin do I need for a 35g carb meal? grams of carbs/CR , e.g. 35g of carbs/25 CR = 1.4u of insulin. 2. How much insulin do I need to reduce my BGL by 3? BGL / ISF, e.g. with an ISF of 6 that is 3/6 = 0.5u of insulin. 3. How many carbs do I need to raise my BGL by 3? CR/ISF * BGL e.g. 25/6*3 = 12.5g carbs to raise blood sugar by 3. Every person has a different ISF and CR. The first thing you need to manage T1D is to find out your ISF and CR. This is not straight forward. The best way to find them is guessing their values and slowly increasing or decreasing them until you find something that works. There are a couple rules of thumb to make it easier though: 1. The 100 rule: take the mean total daily dose of insulin (TDD) from few recent days and ISF=100/TDD. 2. The 350/450/500 rule: same as above but for CR, e.g. CR=450/TDD. You just pick the rule that sounds about right. Another way to calculate these values is through self experimentation. By eating carbs or taking insulin after fasting, we can look at BGL change and derive ISF and CR. But this approach is still error prone and difficult (especially for hungry toddlers). The Loop [1] The T1D loop to get the target BGL of 4-8 mmol/L is: 1. Count the carbs you are about to eat, make sure glycemic index isn't too high so the insulin can handle it. 2. Measure BGL and if it is too high or low calculate a correction to add or remove insulin from the meal to bring BGL to within range. Calculate the correction dose with (BGL-target BGL)/ISF= correction insulin. 3. Calculate the insulin units from the carbs with grams of carbs/CR =meal insulin. 4. Inject the meal insulin + correction insulin units. 5. Wait a bit (20-40mins) so we can match the peaks of the insulin with the glycemic response. The higher the food GI the more important the timing. 6. Eat ALL the food. 7. Repeat for every meal. [1] Sam being distracted from the injection with cheese A real example of this loop is Sam's lunch today; Peanut butter on 2 slices of wheat bread: 1. Count carbs: There are 25 grams of carbs in a peanut butter sandwich. Wheat bread has a low GI of 50, so nice slow glucose rise. 2. Measure BGL: Get Sams BGL with a finger prick. It comes out at 12; we want him to be at 6. His ISF is 8, so the correction will be (12-6)/8=0.75u of insulin. 3. Calculate the insulin: Sam has a CR of 20 so the 25g of carbs in the sandwich require 25/20=1.25u of insulin. 4. Inject: So the total insulin is 1.25 + 0.75 = 2u of insulin for lunch. 5. Wait: Given novorapid insulin peaks in about 1 hour, and wheat bread has a low GI we give Sam the food in 15mins. Pro toddler tip: don't show him the food until he can eat it, patience is not a toddler's virtue. 6. Eat: We make sure he eats all the carbs, so the math is correct. 7. Repeat: start talking about what Sam is having for dinner. This is a lot of work. Now let's see why this isn't as straight forward as it seems. Everything is Hard. Nothing Makes Sense. WTF? [1] A person managing T1D will have to also think about a ton of different ways the above calculations are effected. Here are some day-to-day things you need to take into account: 1. Exercise can make BGL go UP or DOWN! Generally high intensity makes it go up, endurance makes it go down. 2. The liver produces glucose as well, which can mean BGL goes up even when not eating anything. 3. Adrenaline from excitement, stress, anxiety can raise BGL. 4. A hot bath or shower can raise (then lower) BGL. 5. Every food impacts BGL, e.g. a large low carb protein shake will quickly raise BGL. 6. Sickness (and all the horrible symptoms) throws off your ISF and CR. Rule of thumb is to measure BGL twice as often when sick. 7. ISF and CR change with time of day, e.g. many people have a higher ISF in the morning. 8. Sleeping changes ISF and CR; a nap can really throw off your day. 9. If your BGL is high for a while (with high levels of ketones) you will need more insulin. Rule of thumb is 1.5 times insulin. 10. Soon after diagnosis there may be a "honey moon" period where your pancreas can still produce some insulin so you need to inject less. This can last a few weeks or months. 11. ISF and CR change as we age, especially around puberty. Each day might be different than the day before so we must constantly adjust and evaluate. 12. Insulin types have crazy wide possible values, e.g. protaphane peaks between 3-12 hours (!!!). Planning for this is impossible and has resulted in a few hypos for Sam. Also managing T1D means you have to deal with practical and logistical concerns: 1. Carb counting while out, say in a restaurant, is usually a total guess. Even if you break out scales and ask for ingredients. 2. Insulin will lose potentness if it gets too warm or too cold. It might not even look any different, so the only way you find out is to inject it and hope. 3. Some insulins are a mixture that seperate (e.g. protaphane). If you don't premix them enough, their resulting curve will be off. But don't shake too hard, that can do weird things to insulin and make it less effective. 4. A person doing the above calculations may be suffering the effects of T1D while trying to fix themselves. 5. One day we gave too much insulin to Sam and he dropped pretty low. For the next couple days we were gun shy of giving him too much, so didn't give enough. Giving insulin is scary, not giving enough insulin is scary. 6. The horror that is the US health system forcing some people to ration insulin because of its high price. Even if a person has health insurance the price of the insulin needed for a Mc Donalds milk shake might be more than the shake itself. This is all made more difficult because Sam is only 18 months old: 1. Explaining to a toddler that they can't have food is impossible. Often we are doing all the math under duress of a screaming toddler. 2. We have to inject the insulin BEFORE he eats and we don't know if he will actually eat the food. Have you tried convincing a toddler to eat something they don't want to? If that happens we quickly find and prepare some food with the equivalent carbs, otherwise he will go into a hypo. 3. To actually measure BGL requires stabbing a finger and drawing blood, and injecting insulin is another stab. Causing pain to an infant that can't understand what is going on is horrible. 4. Sam is very small so his doses are minuscule. Our insulin pens can only dose at intervals of 0.5u of insulin; a significant % of his total dose. Overshooting and undershooting are common occurrence causing wild swings in BGL. 5. A symptom of being high or low is aggression and mood swings. A symptom of being a toddler is aggression and mood swings. Working out if a tantrum is because of diabetic Sam or toddler Sam is impossible. The final exception to note is that T1D is just a shit disease and it makes BGL do weird stuff all the time. Here is a poster explaining lots of these and more: [1] The Unreasonable Maths of T1D The worst part about it is that; If you are better at math you will live longer. Who makes a disease where the good math people live longer? -- Scott Hanselman T1D I call the maths of T1D unreasonable because I am finding all this stuff difficult and stressful. Even though I know all the relevant numbers, even if I have all the information, even if I am comfortable with the calculations, even if all the factors are accounted for; when we give Sam food or insulin (and sometimes when we do nothing at all) his BGL changes in wildly unexpected ways. Managing T1D is hard, even with a ton of support. I cannot imagine doing this alone, or managing my own T1D, or dealing with the US health system/insurance. If you are dealing with the physiological and psychological issues related to T1D, I want you to know that it is hard, and you are doing a great job. [1] Me and Sam in Wellington Hospital ICU Epilogue: Insulin Pumps + Continuous Glucose Monitors (CGM) = Artificial Pancreas The solution to all the unreasonableness of T1D maths is obviously to get a computer to do it. Computers doing hard calculations in a loop is what they do best. To automate the delivery of insulin we need three things: 1. A Continuous Glucose Monitor (CGM), e.g. the Dexcom G6, reads the BGL level of a person every 5 minutes and can report it to other devices. 2. An Insulin Pump, e.g. the Omnipod, continuously injects tiny doses of insulin throughout the day. 3. A system/algorithm, e.g. OpenAPS or Loop, that continuously reads the output from the CGM, predicts future BGL, and tell a pump to deliver doses of insulin. [1] These three items together create an artificial pancreas, or closed loop system. This removes the need for a human to do most calculations, and just set what value you want your BGL and let the system keep it there. So why should you still learn all the unreasonable math? 1. CGMs and insulin pumps are not always funded by New Zealand health care (even though it is highly recommended). A CGM can cost $400 a month, and a pump $200-$300. Even though patient outcomes have been shown to improve with these devices, the cost makes them out of reach for a lot of people. They are subsidised in Australia. 2. There are not many closed loop systems available in New Zealand, I only found Medtronic 770G pump + Guardian Sensor 3. The other option is to DIY your own with open-source. 3. Sam is 18 months old, most CGMs and insulin pumps can only be used on much older kids, e.g. the Medtronic 770G + Guardian 3 is for 14 year olds minimum. So, we have to wait for Sam to get older and the technology to improve to work with younger kids. 4. Over reliance on technology for your life, without any backup, is not a good idea. Pumps break, CGMs can be ripped off, software breaks, batteries die. Having a backup is always a good. [1] Dexcom G6 on Sam's hip We did just get Sam a Dexcom G6 CGM, and we are loving it. Before, we used to measure Sam's BGL at each meal, 3 hours after the meal and at 10pm and 2am to check he wasn't going low in his sleep. Now we can check our phones for his BGL and will get a notification from Dexcom and home assistant if he goes too low or too high. This has improved everyone's life. Thanks Thanks to doctors nurses and staff of the Wellington Hospital Emergency Department, ICU, children's ward and diabetes unit. Thank you to the family, friends, and coworkers who have reached out with support and experiences with T1D. Finally, thanks to the people in the T1D community for all the years you advocated for better healthcare and technology so that when we showed up there was so many choices. Useful links * Calculating and predicting blood glucose levels in T1D is an active area of research [here] and [here] * Glycemic index search index for finding the GI of different foods * Carbohydrates and Blood Sugar * Carbohydrate Counting in Children and Adolescents with Type 1 Diabetes (2018) * Calculating Insulin Dose * Scott Hanselman -- Solving Diabetes with an Open Source Artificial Pancreas * Detailed description of how OpenAPS a closed loop artifical pancreas makes its decisions * Home Assistant Dexcom integration * Loops algorithm for predicting glucose * News/Studies related to New Zealand funding CGMs and pumps [here] and [here] 98 98 3 More from Maori Geek Follow Tech, Programming, Whatever Read more from Maori Geek Get started [ ] Graham Jenson Graham Jenson 776 Followers New Zealand Programmer, Dad, DevOps, Data, Scale Everything Follow Help Status Writers Blog Careers Privacy Terms About Knowable