Jitterbug
Hack Diabetes. Commit crimes. Eat Goose.
In November of 2010, life was a joy. My son, let’s call him “Thumper,” had just turned 4, and my daughter, “Tigger”, was toddling through toddlerhood. I had launched my second ed-tech company, and amazingly, Bill Gates’s personal office cold-called me to request a demo. My family was planning[1] a lovely Thanksgiving meal with goose and chestnut soup[2]. Life had an undeservedly wonderful trajectory. And then…Thumper threw up in the bath.
Now, a kid throwing up in the bath is hardly remarkable. Little kids seem to extrude a wide variety of disgusting substances from various orifices on a semi-regular basis. Some are sticky, others slick. Some are both at the same time with chunky thrown in for good measure. Worst is when things are extruded from the “wrong” orifices. Spend enough time with enough kids, and a little vomit in the bath becomes an unsurprising part of their care and feeding. Besides, it was flu season. What’s the worry?
Thumper didn’t have much of an appetite the rest of the evening, but seemed a bit better the next morning. Then, after finally eating some plain bread, he threw up again. Nothing to panic about. We checked in with his pediatrician, and they said it sounds like the flu, “Just keep us updated.”
Thumper was still sick on Tuesday, but cheery and gamely failing to keep food down. He seemed to get better and worse in turns over the next couple days, and we stayed in touch with the doctors.
By Wednesday afternoon, he couldn’t stand. Much later, reviewing medical charts, we saw that he’d lost 25% of his body mass. It all happened so fast[3].
Our pediatrician’s office squeezed us in late Wednesday afternoon, before the 4-day holiday would send everyone home. The doctor on call took one sniff of Thumper and said she needed to run a quick blood test. We waited, expecting the standard advice about “plenty of fluids” and “bed rest.” Instead, the doctor returned to deliver a very different classic line, “You may want to sit down for this.” She broke the news, the truth she knew by the sweet smell of his sweat alone, “He has diabetes.”
Type 1 (“juvenile”) diabetes is an autoimmune disease. Thumper’s own immune system was destroying the beta cells in the pancreas that create insulin. Without insulin, sugar cannot pass from the bloodstream into all the other cells of the body. You can eat all you want, and your digestive system will convert the carbohydrates (starches and sugars) into glucose, but it just builds up in the bloodstream. Eventually it is excreted through sweat and urine, but not before forming damaging deposits throughout the body. More dangerous at the moment, without access to its regular source of energy, Thumper’s body was eating itself, turning his own muscle and fat into energy. That may sound bad enough, but it turns out this autocannibalism turns blood acidic through a process known as ketoacidosis[4]. That’s why he’d seemingly shriveled up and couldn’t stand. It was also why my little boy was now growing increasingly incoherent and confused.
Neither my wife or I had family histories or direct experience with diabetes of any kind, but in an instant we were parents to a child with a chronic, life-threatening illness.
The next hour was a demented merging of the mundane and the existential. The doctor told us we were expected at the emergency room at Oakland Children’s Hospital, but not to worry. “You have plenty of time.” Well, I followed our doctors’ orders, apparently too well, and discovered that it’s possible to be too calm under pressure. I took my son to pick up our pre-ordered Thanksgiving meal from the market while my wife collected our daughter from daycare. It seems insane in retrospect, but a qualified expert told me not to worry or rush. She obviously assumed I’d be a frantic mess, a danger to myself and others on the road. Instead, I picked up a goose.
I arrived at the emergency room half an hour later to discover that the hospital had called the sheriff's department to look for our, presumably, smoking wreck somewhere along MLK Blvd. Thinking back, I try not to over-dwell on the fact that I almost killed my child so that dinner wouldn’t be cold; in the moment, however, Thumper’s growing delirium was sufficient distraction. Plus the doctors and nurses and tears… There were plenty of distractions. Also, once the doctor had pointed out the rancid fruit smell of his sugary sweat, I couldn’t unsmell it.
ER staff ran their own test to measure Thumper’s blood glucose (BG from now on[5]), the amount of sugar in his blood, but the results were above the range of their equipment. A healthy value might be 90 mg/dL, and BG above 140 mg/dL suggests a problem—Thumper’s BG was above 700 mg/dL. And yes, they measure blood sugar in mg/dL, milligrams per deciliter. This has always seemed bizarrely arbitrary to me. With some basic transformations on the units, 100 mg/dL is the same as 1g/L. That means “1 gram per liter” is identical to “100 miligrams per deciliter.” “Aim for 1” could be the motto of diabetes patients around the world[6]. Instead, the motto is more like, “Do I need to know what a deciliter is to live?”
In short order, Thumper and I were moved up to the pediatric intensive care unit (PICU, or “pic-u” as they call it) where I would spend the hardest 24 hours of my life[7]. Thumper’s astronomically high BG was an immediate threat to his life, but they couldn’t just flood his body with insulin—too much, too fast and the shock might kill him. Instead, they needed to slowly titrate Thumper’s blood-glucose levels down to a normal range, closely monitoring vitals the entire time. It’s somehow Wednesday night when this process begins, and I’m exhausted and possibly a touch terrified. Every 30 minutes, the nurses brought a screaming, struggling Thumper back to semi-consciousness with needles, tests, and unanswerable questions. Then I would hold and calm him until he’d finally pass out again. At this point, I’d grab a few minutes of sleep on a cot next to his bed in the middle of the bright and noisy PICU. After half an hour it would start all over again. The cycle lasted for approximately forever, though in reality it must have ended sometime late on Thanksgiving day.
Despite the best efforts of the staff, the experience was truly awful. I do not recommend spending any major holiday in an ICU of any kind. I suspect non-holidays may not be much of an improvement—four days of fear and chaos are never as good as they look in the brochure.
Our long Thanksgiving in the PICU substituted cafeteria turkey and stuffing for goose and chestnut soup, but it also brought perhaps the most honest and brutal thanks giving I’d ever felt. As hard as those four days were, my whole family left together on Sunday. Many of the families with whom we shared that holiday would never be whole again. We met the kids who lived at the hospital, attending classes between treatments. We watched as every member of an enormous family passed through the PICU in pairs to say one last goodbye to their daughter. It is a terrible thing to see how fortunate you are in the body of a tiny infant with tubes coming out of their chest, or the little boy who spent the entire four days I was there asking for family that never came.
On Sunday afternoon, Thumper’s BG levels were back in a survivable range and his personality was beginning to return[8]. My wife and I attended a “care-and-feeding class” for newly diagnosed kids. Two other families were part of the class, having also tuned into the same Type 1 Diabetes Thanksgiving Holiday Special[9]. It turns out that many families receive their diagnosis via a trip to the ER; one of the other parents even had type 1 diabetes, and they were still taken by surprise. This diagnosis-by-fire seemed absurd to me at the time, and unconscionable today. In the upcoming episode “East Coast Swing,” I will explore the possibilities and challenging ethics in more detail of AI in public health.
After the inevitable yet pointless wait for discharge orders, the Mings were ready to go home. The staff helped load my little(r) boy into the ceremonial wheelchair, a throne of pillows and teddy bears. You can see him looking thoroughly worn and wasted in the image above. You may also notice that one pillow is not like the others. The mother of one of the PICU nurses makes holiday pillow cases for all the children spending their Thanksgiving or Christmas in intensive care. We still have the pillow case, and it still touches me that someone offered such simple and sweet gestures to frightened strangers they will never meet again.
We arrived home late Sunday evening and shared our Thanksgiving meal, the first in our new reality. Felix ate 89 grams of goose and 168 grams of mashed potatoes. We weighed everything to the gram, looked up the nutritional information on the FDA’s website, and ran numerous computations to figure out the right insulin dose. It turns out that jabbing needles filled with a potentially deadly substance into my child did not improve our already struggling Thanksgiving. But not giving the injections would lead us right back to the PICU. This is the life of the newly diagnosed.
By the way, I know the precise weight and composition of that first meal because the Ming kids have the misfortune of having scientists for parents, and like any mad scientist worth their salt, we frequently run experiments on them. As soon as we got home from the hospital, we started recording everything we could track. We collected so much data we repeatedly crashed Google Docs with our enormous spreadsheets. Everything Thumper ate down to the gram went into our records. All of his activity levels tracked in steps and heart rates. All our notes and observations on his emotional states, every blood glucose level, every sneeze, every complaint. We built our own little cyborg with Fitbits, Basis Bands, wireless insulin pumps (PDM), and continuous glucose monitors (CGM). At our peak, we proudly collected thousands of data points every day.
And in my mind, I thought, “The doctors are going to love us!”
Not so much, as it turns out.
The Ming family’s first month with diabetes was spent much like any other family, terrified. But our terror evoked a behavior peculiar to Californicus scientificea mingolioucious—we collected every scrap of data we could wring out of the devices attached to our son. Within four weeks, we had thousands and thousands of BG readings, heart rates, step counts, sniffle sightings, and masses of carbohydrates, proteins, and fats from every meal. We wanted to be part of the solution to Thumper’s new burden...or at least not feel entirely helpless.
I had assumed that squirreling away every number or observation would make us treasured partners to Thumper’s endocrinology team. How often do they stumble across such thoughtful, detailed, proactive, charming, and good-looking parents?[10] As we approached our first outpatient visit, I collected all of our data together and emailed a copy of the spreadsheet to their office. Strangely, I didn’t hear back from anyone at the hospital, but then I realized my mistake. “They’re old school!” Of course! So, I printed up a phonebook’s width of spreadsheet[11] and headed out to glory.
When we brought those pages of data in with us for his first outpatient visit, the staff wasn’t just uninterested—they were angry. “How dare you waste our time with this? What am I supposed to do with all of this data[12]?” Instead, the staff gave us a photocopied form with 15 empty boxes–morning, afternoon, and evening, for five days–and told us to write a blood glucose reading into each box. We had thousands and thousands of data points; they only wanted 15. When we were done, the staff then squinted at the paper for a few minutes before offering a treatment plan for the next month. I truly like and respect Thumper’s doctor, but in that moment, fueled by frustration and anxiety[13], I thought, “You’ve got to be fucking kidding me. I build models of the brain. You’re telling me diabetes is more complex than the brain?”
It was crazy that my son was wearing an entire wardrobe of sophisticated technology, yet his pump would be set by hand once every few months based largely on intuition. On that day, I began building Jitterbug, my personal codename[14] for a machine learning system to monitor my son’s diabetes and help us with his treatment.
The first and biggest problem with this project struck almost immediately: All of the data captured by those wearable devices was being sent to some blackbox database. Not one of those companies allowed me to directly access the data that was literally coming out of my son’s body. So, I hacked them. If you go to Github, you can find open source code for almost everything. For example, thanks to the NightScout project (started by another parent), with a little Python code, a couple of USB cables, and an old Android phone, I was streaming live data from my son’s continuous glucose monitor to a server I spun up to track his health in real time. Throw in heart rate data from a proto-smartwatch (the basis band), steps from Fitbit, and nutritional data scraped from the FDA, and now I had something I could actually model.
My original idea for Jitterbug was to slowly adjust the parameter setting on his insulin pump over time. Rather than wait for a review by the doctor every few months, the pump would continuously adapt in days or even a few hours. I built a Bayesian model that took in all of the data and spit out estimates of the right settings for the various pump parameters: carb ratio, correction factor, basal rate, and more. The easiest way to make that work was to have the system recommend specific doses and then track how his BG levels deviated from the model’s predictions over time. To accomplish this, I adapted a model of predictive coding from the retina. It turns out that the most efficient way to see the world is to predict it. Then your brain only needs to code for the bits it got wrong. If it can predict well, it can transmit more information about the visual world. I needed to make small changes, such as modeling BG velocity rather than its absolute value, but all in all, the algorithm works surprisingly well. Alternating between the Bayesian model for parameter updates and the predictive model for dosing was a bit like the expectation maximization algorithm used in machine learning[15].
I built this two-part algorithm and began piloting it on my son. As we changed his treatment based on the data we collected, I found that he spent 40% less time with too much sugar in his blood without any increase in dangerous low blood sugar episodes. In fact, in the past 10 years, Thumper has not had a low BG emergency.
I was thrilled, but the most amazing and unexpected thing Jitterbug did was actually predict his BG levels not just in the moment of a meal, but an hour or more into the future. When the system made those predictions to update the insulin pump, it was trying to keep his BG levels maximally flat. If the predicted and actual levels diverged, it always meant his levels were almost certain to go too high or too low within the next few hours. The standard monitors used by most patients are about 20 minutes slow. When those monitors buzzed a “low blood glucose” alarm, that meant he’d gone low (or high) 20 minutes ago. When Jitterbug’s alarm went off, it meant he would go low 10, 20…50 minutes in the future.
I set up the system to send warnings to my Google Glass so that I knew immediately if my son needed help. That was the superpower I built for Glass that meant I’d even wear it to a party at the White House. I received a notification in the East Wing that Thumper would go low and I texted my sister back in San Francisco to give him a cracker. He didn’t go low. I would literally have worn Glass anywhere[16].
My early hope was to build a little app and share Jitterbug with the world. As it turns out, however, I’m only the fake kind of doctor. It is illegal for a tool like Jitterbug to give medical advice without years of testing, and medical advice is unambiguously what it offers. It’s understandable, but also tragic. In the years since we developed Jitterbug, only my son has benefited from it directly.
Quite frankly, though, the kinds of parents who could implement my code, track all of the necessary data, and truly benefit from Jitterbug were already a rare breed. However, I had another option: Just give it away. Instead of building apps or taking out patents, I got on the phone with any scientists or engineers at the major diabetes device-makers that would take my calls and told them exactly how to implement my algorithms. There were no strings attached or licencing deals, just the knowledge of how to do it. At the same time, I talked with parent groups and anyone else that willingly stood still long enough to listen about what I’d built and what was possible for their children, too. I’d already helped Thumper, which was my only goal. Every other family this might reach was gravy, a cherry on top, a bonus...a disgusting mix of all three. So, I let the knowledge enter the market and do some good.
Eventually, diabetes device-makers began announcing their own systems for predicting blood glucose levels the way Jitterbug had already been doing. It only took them 4 years and $40 million more than it took me :)
One of the most exciting examples I’ve heard of implementing this technology was during a visit to Eli Lilly. I had been invited to their headquarters in Indianapolis to speak on the future of work and the impact of AI on bias. I also had the chance to sit down with teams from across the company working in HR, data, and research. At one point, the CIO and head of research introduced me to a young man applying deep neural networks to diabetes. He was working on what’s called an artificial pancreas. They are basically thermostats, turning up the insulin as your blood sugar goes up and turning it down as sugar levels drop. Artificial pancreases are in human trials right now, but this young man had followed up on my models to turn an artificial pancreas into a deep neural network-driven smart pancreas. Instead of reacting like a dumb thermostat, his model adjusted insulin levels to shape the future[17]. His work was in very early stages and only in simulation, but in those simulations, his smart pancreas worked better than the real thing. How long before people with family histories of diabetes have prophylactic pancreas replacements? How long before the Paralympics are more interesting than the mundane Olympics? It’s exciting, but it means more hard choices are ahead.
Diabetes has been hard; so many nights, I have been driven from my bed and into my son’s room by terrible fears. Yet we’ve been incredibly fortunate, and those fears have never come true. In the years since his diagnosis, we haven’t had a single emergency. This horrible experience has turned into something wonderful, an opportunity I wish every parent could experience: being a superhero for your child. It’s that feeling that you are the one person in the world who can truly change the course of your child's life. When Thumper struggles with the unfairness of diabetes, I remind him that our family was perfectly suited for this challenge, and that because of him, thousands of others might live.
[1] Note the use of the word “planning” rather than cooking. There was a time in my life, as a postdoc, when I would shop at Berkeley’s three weekly, year-round farmers markets and prepare near-gourmet meals for my wife. I was a legit cook. After many years of picky kids and needy startups, I consider heating two bags of miscellaneous frozen substances in the same pan to be “home cookin’”.
[2] We no longer eat goose for any meal. It’s not for any traditional reason of ethical treatment or sustainability; rather, my kids have a goose stuffed animal, or “stuffy” as they call them. For similar reasons, we also don’t eat cows, pigs, goats, or seemingly hundreds of other species represented in their ever-welcoming ark. My kids have so many stuffies that they’ve dedicated an entire bed to them and frequently choose to sleep in makeshift cots rather than disturb the flock. They absolutely refuse to eat anything represented in this collection. Fortunately, they don't find fish to be particularly lovable.
[3] Or so we thought. It turned out we’d likely been on this terrible journey for months.
[4] Autocannibalism and acidic blood sound like qualities of sci-fi horror villains, a mashup of Borg, zombies, and Alien xenomorphs. It turns out the reality is its own horror story.
[5] New acronyms are fun!
[6] I’m an American; of course I assume Americanglish.
[7] For readers who are already familiar with my life, you might appreciate the weight of that statement. For those who aren’t, just wait for the next book—I have some stories to share.
[8] “Flat affect” is a fascinating and subtle symptom found in many conditions. I was told that a lack of emotional responsiveness was an expected part of ketoacidosis, but finding your child’s personality absent after a trauma and then watching it gradually return days later was a terrifying trip, especially for someone who studies brains. A person disappeared and then slowly returned while their body remained the whole time; it’s an existential wrecking ball.
[9] Does anyone tune in to anything anymore? It feels a little sad to think that we don’t really have that same shared network television holiday experience anymore. Then again, network TV sucks ass (that’s a technical term used by quantitative economists to describe preference incongruity under monopolies).
[10] It is possible my self-congratulations ran away with me a bit on this one.
[11] A phonebook was an early version of the internet that didn’t need to be turned on but was woefully short on hot takes.
[12] If you ever find yourself saying anything like this during the course of your workday, it’s likely that someone is already building an AI to turn your job into the modern equivalent of an elevator operator. We’ll discuss this more in later episodes.
[13] And, let’s be honest, a heaping bucketful of arrogance.
[14] My wife introduced me to ballroom dance when we were dating in grad school. Ever since, I’ve used dance names as working titles for projects.
[15] For you nerds (like me) that just needed to know.
[16] Proven by my wearing it years longer than anyone at Google, despite the regular and unsolicited “Glasshole” mutterings I’d hear around San Francisco.
[17] My own model showed correlations in blood glucose levels spanning more than 24 hours. It wasn’t just about the biophysics of insulin and digestion; it was picking up on my son’s behavioral patterns throughout the week. Experts thought only in terms of the back dynamics of insulin release and digestion, but these models needed to understand the whole child.