Thursday, October 30, 2014

Installing the NightScout CGM Remote Monitor on Heroku

It's again one of those nights... Max went to the movies and came back, you guessed it, a bit high. Since he is quite motivated to keep his blood sugars under control, he decided to inject a 1U correction and exercise a bit. So far so good. Bravo Max. Of course, he got a bit enthusiastic and overdid it. Since dad is condemned to a night watch, he might as well be productive.

Heroku? (

Heroku is a cloud application platform. Just like Azure, it can run Node.JS based applications (and many others). That means that it can also run the remote-monitor (web page) part of NightScout, the remotely accessible real-time interstitial glucose monitoring tool.

While I run my normal monitor on a local system and a private server, it never hurts to have a backup. Why Heroku instead of Azure? Here are my reasons.

  • the free Heroku plans don't seem to be as prone to failures, blue screens or other availability issues as Azure.
  • the free Heroku plan doesn't expire. No mandatory transition to paying plans (at least currently).
  • the free Heroku plan comes with SSL by default. (that doesn't add much confidentiality since the connection from the uploader to the database and from the portal to the database aren't encrypted).
  • Heroku salespeople don't bug you.
  • Access to the Heroku portal can be controlled after installing an add-on.
  • the portal can be installed through the command line (this last point may be a problem for a lot of users, but that is my preferred way of working)

Let's roll

This assume you have created a Github account and forked the cgm-remote-monitor project, as described in the NightScout setup guide.

1. Account creation

 Create a Heroku account on You'll need to enter an e-mail address, click on the confirmation e-mail you receive and choose a password.

2. Getting started

open your heroku account, locate the Node.JS icon in the "Get Started" section. Click on it.
3. Toolbelt

download and install the heroku toolbelt from the Set Up part of the tutorial.

The toolbelt contains the command line utilities and support tools required for interaction with Heroku.

4. Log in

when the install is complete, open a command window, move to the location of your choice on your computer and log into your heroku account by typing

heroku login

enter the e-mail address and password you entered to register with heroku. If you haven't used Heroku or other services using SSL based authentication, you will asked if you want to generate a key, answer "Y" for YES. You'll receive a mail notification that a key has been added to your account.

5. clone your github fork locally (replace xxxxxxx with your Github user name)

git clone
 that will create a local copy of the git repository (that you can eventually also use for experiments). Once the cloning is complete, change to that directory so the Heroku toolbelt knows which repository you are working with.

cd cgm-remote-monitor

6. create a heroku application 

heroku create --http-git
you will get a message and a name such as nameless-owl-3456.git. This will be your app identifier (you can change later) and a part of your connection url.

7. push the application on the server

git push heroku master
you'll see a lot of messages - they should succeed. Heroku has now linked the code of your portal to an application. The application should immediately be visible. Log into your heroku control panel to check.You'll see your application. Click on it and then go to its settings. This is now, before we start the application, that we add the config variables (or "strings") that you saved in your mongo database creation and entered in the uploader. They are the glue between the monitor and the database. Define your "mongo" string and your "mongo_collection" as shown below, with your information of course.

8. Starting the portal
When the strings have been entered and double checked, you can start the application by typing.

heroku ps:scale web=1
you'll get the message below. It means that your application started on one "dyno", a dyno is a kind of small virtual machine.
Scaling dynos... done, now running web at 1:1X.

9. Opening the portal
Open the portal by typing
heroku open

This should open the web site in your default browser.
Your NightScout portal is now running. Congratulations!

Wednesday, October 29, 2014

Tennis - experimenting a bit

Some more data in our quest for decent training sessions while keeping good control. All afternoon sessions in relatively similar conditions, same trainer, same intent. Maintaining the same intensity throughout was of course difficult in the presence of lows.

Tennis Training Oct 29 -2014 from Pierre Vandevenne on Vimeo.

 First case - standard meal, including 60/70 grs of carbs as rice. Normal meal-spike. Pre-loading with 60 additional grams of fast carbs in prevision of a 1 hour training. Coming from a lowish pre-meal 70 mg/dl. Pre-training spike perfectly timed. IG complete collapse after 35 mins, BG after 15. Post training too high.
Lantus 15 - 7:15 PM       Novo  4 - 1:30 PM

 Second case - standard meal, including 60/70 grs of carbs as rice. Flat meal-spike. Pre-loading with twice 60 additional grams of fast carbs based on previous experience. Coming from a frankly lo pre-meal of 55/70 mg/dl. Pre-training spike perfectly timed. IG collapse after 45 mins. BG after 25. Post training too high!

Lantus 14 - 7:15 PM     Novo 4 - 1:30 PM
Third case - standard meal, including 60/70 grs of carbs as rice. Lowered Novo to 3. Flattish high meal-spike (not good!). Still Pre-loading with 60 additional grams of fast carbs in prevision of a 1 hour training. Coming from a high pre-meal 140 mg/dl. Pre-training spike perfectly timed. Complete collapse after 35 mins. Post training OK
Lantus 15 - 7:15 PM     Novo 3 - 1:00 PM
 Fourth case - standard meal, including 60/70 grs of carbs as rice. Normal meal-spike. Pre-loading with 20 additional grams of fast carbs only based on the fast rising levels. Coming from a pre-meal of 110 mg/dl. Pre-training spike well timed. Complete collapse after 35 mins. Previous day lantus was advanced by 45 mins. Huge post-training spike. Probably attributable to the previously established 22 hours of Lantus activity. There's that two hours window where he apparently has no insulin left on board. Extremely tired and cramping a bit after the training. 2 units of Novo given as correction as soon as we got home.
Lantus missing 15 - 6:30 PM     Novo 4 - 1 PM
 Fifth case - earlier standard meal, including 60/70 grs of carbs as rice. Normal meal-spike, almost leading to a post-meal low. Pre-loading with 30 additional grams of fast carbs in prevision of a 1 hour training and 1 unit of Novo to prevent the previous lack of insulin. No collapse. Best performance during training. Still a post training rebound, at the limit of the acceptable.
Lantus 15 - 6:30 PM      Novo 5 - noon    Novo 1 3:00 PM

Conclusion - try to fine tune case 5. Advance pre-meal insulin by 15 mins to tame meal spike and post meal low? Try 2 additional units of insulin pre training with slower carbs? Well see...

Saturday, October 18, 2014

A very dark reminder...

Yesterday morning, an 11 years old diabetic girl - the age of my daughter - was found "dead in bed".

We didn't know that girl. She was a member of the extended family of Max's tennis partner. We didn't know what her treatment was. Just that she did not want a pump in August. She must have been on MDI. We don't know what exact circumstances led to her death. Just that she was fine when she went to bed on Friday.

But we know that, on the morning of the most warm and beautiful 18th of October Belgium had known since 1901, she was found by her mother. Cold and gone...

We know very little about her. And yet we know way too much. 

We know what her life of constant worries, checks and constraints must have been. We know how unpredictable Type 1 Diabetes can be. We know how exhausted her mother probably was. We know we can't be tired and forget to check, can't be far and can't be careless or even distracted. We know, if you are lucky enough to have a CGM, you can't afford to miss alerts. We know how it feels to go to bed every night thinking about the sword of Damocles...

My thoughts have been with you all day, little girl. All day.

Saturday, October 11, 2014

Of lows and Lantus


We've had a few issues recently that, I believe, are related to our Lantus...

Here's our average glycemic profile over the last 15 days. Even for someone like me who likes "good control", it seems we are running a bit low. "Lower your insulin!" would be the standard answer, except for the fact that we're using at a total dose of 0.58 U/kg (0.28 U/kg of Lantus and around 0.30 U/kg of Novorapid) - according to "Think Like a Pancreas, page 129", we are already at the very bottom of the dose for a "very active adolescent".

We have a few options here

  • increase the amount of carbs: in our meals (except that we aren't on a low carb diet)
  • lower the rapid insulin doses: that's a bit hard to fine tune when you are running a schema of 5-6-4 units and you are still getting a fair amount of post-meal spikes. Half units Insulin pens will hopefully be discussed during our next appointment.
  • lower the Lantus dose: that would be the sensible thing to do with any T1D who seems to be running low but...
There's also another reason why we should lower the Lantus dose: we do seem to have Lantus related lows (see arrow 1) starting around 10:30 PM and lasting until 1:30 AM well after the 6:30-7:30PM Novorapid has stopped its action. But, and that's a big but, starting at 3:00 AM, we have an dawn phenomenon so pronounced that 7:00 AM is actually the time of the day where our average is the highest (arrow 2). And that happens despite a frequent 4:30 AM corrective dose of 2 units that we give if the CGM indicates a value above 140 mg/dl at that time. That dawn phenomenon can only be tamed by higher doses of Lantus but those make the 10:30 PM to 30 AM lows even worse. This remains an open issue, to be discussed with our endos next month. Options seem to be
  • switch to Levemir
  • start pumping
  • delay the Lantus dose
  • split the Lantus dose 
The "split the Lantus dose" strategy is somewhat controversial. Exploring it led me to some interesting facts that illustrate the complex interactions of big pharma's interests, doctor's default attitudes and patient well-being.

What's the rationale for splitting the Lantus dose?

Lantus, introduced by Sanofi on the market in 2000, is an insulin analog that is supposed to be almost peakless and lasts for 24 hour. The often shown chart below, extracted from its FDA application (source), shows a very minor peak of activity, about 5 or 6 hours after injection which fits quite well with the lows we observe. The medical litterature also reports that around 10-15% of the patients on Lantus seem to experience more severe early night lows than others. But it is hard to be 100% certain as those studies predate widespread CGM use.

Interestingly enough, Novo Nordisk, the makers of Levemir seem to disagree a bit with that profile: according to the studies they cite, Lantus has a much higher peak at the 8 hours mark. (source)

In fact, there's a simple explanation for the long action profile of Lantus: a couple of arginine additions and the replacement of the terminal asparagine by glycine in one of the Insulin chains change its solubility at normal pH. Before the injection, Lantus has a pH of 4.0 (that's why it stings when injected). After the injection, the pH progressively rises and the Insulin analog is slowly released from the Zinc Chloride stabilized hexamers it has formed at low pH.

Assuming a simplified spherical model for the Lantus injection, it is obvious that release can not be perfectly even and is somewhat dose dependent. A bigger injection will start its life as a bigger sphere, with a bigger surface that will release less and less insulin over time as it shrinks (and conversely, release more Insulin at the start). That geometrical issue is the rationale for splitting the Lantus dose: instead of injecting one single large dose that has a bigger peak, inject two smaller ones that have smaller peaks. That "size of bolus" effect is also true for Levemir, see the chart below, where the dose dependent peak is quite visible. Unfortunately, I wasn't able to find a similar dose dependent profile for Lantus.

And that brings us back to our initial options list: splitting the Lantus dose logically makes sense and has been reported to be effective by many Internet users. However, since the main benefit of Lantus is that it only requires a single injection, we might as well go for two Levemir injections. This will eventually be discussed at our next appointment. 

Thoughts on big pharma, endos and common wisdom...

When I first enquired, based on our CGM data, about the possibility of a Lantus peak, the near Pavlovian response of our endocrinologist was "Lantus has no peak." That message has probably been so heavily hammered by Sanofi's marketing department since 2000 that is has become common wisdom (and to be fair, it was comparatively peakless in the 2000 context). However, both Novo Nordisk and user reported experiences paint a more nuanced picture. 

And here comes the icing on the cake: starting in 2015, Sanofi will not only agree that Lantus has a significant peak but will also have a solution for that peak: U300/Commercial Name Toujeo

And can you guess the reason behind their sudden change of mind? The welfare of diabetic patients?Well, maybe a bit. But not only. Remember, Lantus was introduced in 2000. It is Sanofi's cash cow, raking in €7.0bn ($9.0bn) per year. Other companies, such as Eli Lilly, are ready to jump on a slice of that cow, with cheaper analogs, when Sanofi's patents expire (November 2014 in Europe and February 2015 in US). Sanofi is now protecting its cow through lawsuits (automatic patent extension in the US until the case is resolved) and on the product front (rushed U300 approval in Europe). 

I am willing to bet that a lot of endos will soon be hammered by Sanofi's marketeers and re-conditioned to address an issue they were told, until now, was inexistent.

But you never know, it may incidentally address our small problem. Meanwhile, I might have another go at delaying the Lantus - it could be that its peak can be synchronized with the dawn phenomenon.

Wednesday, October 8, 2014

Training - and the consequences...

Max had a relatively intensive one hour training today.

Training from Pierre Vandevenne on Vimeo.

 According to the otherwise excellent "Think Like a Pancreas" book by Gary Scheiner, a carbohydrate replacement of 50-55 grs should have been enough for a boy of Max's weight (50 kgs) playing an hour of tennis . We barely made it through (low alert after 45 minutes) with a 100-120 grs load, about twice the recommended load. This has been a frustrating constant recently: we go as low as we can with insulin (4 units for a total, including the previous meal, of 200 grams of carbs) and he keeps crashing during training anyway...Carbohydrate loading with gels began at 15:12 precisely, then 15:45, then 16:10, in the hope of synchronizing glucose absorption and exercise. BG started to fall in the middle of the session and Max became mildly symptomatic at 16:45.

To be honest, I am starting to think that the available published data about carbohydrates replacement for young T1D diabetics is only valid for casual sport... not for the real stuff. It's a touchy topic: one can't obviously tell people "your sport session was a joke". But all the advice found in books or on the net seems to be intended for what's actually low intensity exercise. Studies at 60% VO2Max fall in the same category...

And, to add insult to injury, despite a very quick reaction and carbohydrate reload post exercise (see how the IG curve recovers relatively quickly), we are still getting an awful, fairly typical, "delayed lows" night. No quick fix here as I have no idea what his net glucose debt is.

So, that's another night of watch duty for dad. But, thanks to the CGM and the Nightscout Project (by a bunch of truly remarkable volunteers), I am fortunately able to monitor the situation as I write this post.

With the CGM + Nightscout combination, Max
  • can play tennis as he likes to play it.
  • will go through the night relatively undisturbed (correction + a finger prick or two)
  • will not overshoot to 350 mg/dl just because we would have to be on the safe side.
Without the CGM, we would have had
  • to skip tennis altogether "Max, we are sorry, but diabetic kids can't do that".
  • or to overload carbohydrates blindly to be on the safe side.
  • to finger prick multiple times during the night, and possibly miss lows anyway.
Without Nightscout, I would be camping in his room doing nothing but worrying.

Can't help wondering how this would have unfolded if we didn't have those tools...

Friday, October 3, 2014

Going CGM

Maintaining a 8-10 hours per week tennis training schedule, dealing with delayed hypos, checking every meal and trying not to sacrifice diabetes control implies finger pricks. Tons of them. Until March, we were averaging 10+ tests each day. Long tennis games would often require 8+ tests. Obviously, we couldn't go on like this.

As soon as Maxime had been diagnosed, I hit the Internet looking for solutions, tips and tricks that would improve is diabetic life. One of the first things I discovered was that Continous Glucose Monitoring devices existed (CGMs). These things are expensive: you typically need a receiver (approximately 900 EUR), a transmitter that should last 6 months (approximately 300 EUR) and one 75 EUR sensor each week. Assuming you run everything by the book and change your CGM every two years, you end up with a significant bill

  • 1 receiver 900 EUR
  • 4 transmitters 1200 EUR
  • 104 sensors 7800 EUR

or roughly 4950 EUR per year.

In practice, sensors can be run for a couple of weeks on average and that lowers the cost a bit, to 3000 EUR per year. This is still a significant amount of money that is, of course, "out of pocket" in our almost free but strained European social security systems (although this recently changed in Belgium for kids on a pump).

While there was no therapeutic obligation (very good control at 5.3 and 5.5% HbA1c), the damage done to Max's fingers and the mental fatigue induced by the constant stress of keeping sparsely sampled curves in our minds at all time decided us to give CGM a try.

We chose to go for the Dexcom G4 system which seemed to have good reputation on the Net but was also described as one of the two best performing CGM in artificial pancreas studies (here for example

There's a lot to say about CGM, delays between the interstitial glucose they measure and the actual blood glucose level, their precision, calibration strategies and other pitfalls. But let's not go too fast...

One of the first thing I did was to write a small program that checked if the average of the results given by the CGM was roughly equivalent to the average results of the blood tester we used. I was pleased by the result. As you can see from the numbers below, on average, the CGM tracks quite closely the results we would have had from the blood glucose finger pricks, including tests not used for calibration. Those charts and stats reassured me fully: the CGM could be trusted for global goals in the long run.

CGM vs BG Tester - average basic stats
The average glucose values are quite close and so is the standard deviation and the profile do match closely. One could nitpick about the bigger standard deviation observed with the BG tester, but that's explainable by the fact that we check more often when Max is a bit lower or higher than usual.

Note 1: the hole in the July CGM data corresponds to a period where the CGM wasn't used. Hot weather and abundant sweat are sometimes difficult to deal with.

Note 2: the May-June hole in the BG tester data corresponds to a period we were using another BG tester. Adding that second BG tester data does not alter the overall result.

Tennis season write up

The tennis season has come and gone: the time has come for a summary. Unfortunately, T1D reared its ugly head too often and the post-mortem is a mixed bag.
Serving Low
Max T1D's emergence in the summer  of 2013 led to several unexpected and catastrophic losses. As a result, Max did not earn enough points to be allowed to play a higher category, where he belonged based on his technical abilities. This had one good side: we would have somewhat easier matches and some time to learn how to manage T1D, prepare for the games, address the recovery issue, etc...

The winter season was extremely difficult to manage, but went well in terms of results. Max won the first tournament he played with victories against a couple of much stronger players. But we had a lot of issues...
  • if we lowered pre-game insulin too much, he would tire and cramp after an hour or so.
  • if we did not lower insulin enough, he would drop like a stone and automatically lose the second set of his matches before recovering in the third set when massive carb intake would finally take effect. 
  • we discovered that it was extremely difficult to predict the type of exercise he would go through. Long rallies from the back would drain crazy amounts of carbs. Quick attacking games would not.
  • delayed nightly lows at 4AM were extremely annoying after either evening games or late practice.
  • the number of finger pricks quickly became excessive.
These issues led us to use a continuous glucose monitor (more about this later).

The summer season, on the other hand, was a bit of a nightmare. While winter tournaments are played indoor, summer games are played outdoor. The worst delay you can expect when playing indoor is around 45 minutes to an hour. The adversary might be a bit late. The previous game might be a bit long. But when you are playing outside on clay courts, the delay can be absolutely anything, from an hour to six, depending on the weather and other matches. When you have timed your food and insulin for a 14:00 game, you'll be way too high if you don't play until 18:00. If you correct and the rain stops at 15:30, you'll have too much insulin on board and will drop like a stone when you start playing. If you are delayed for more than a few hours, the cycle restarts. On MDI, this is completely unmanageable. So much that we decided to join a tournament if and only weather forecasts indicated no risk of rain for the coming week... In Belgium, such a weather dependence does limit playing opportunities. In 2012, Max played 49 competitive games. In 2013, a season truncated by the T1D diagnosis, 35 games. This year, 18 only... Winter season was 6 wins 1 loss, against higher rated opponents.Summer season was 6 wins 5 losses, against equally rated opponents, with 4 losses that can be directly attributed to diabetes (bad timing, running out of insulin, crashing low...)

As much as I hate to say it, our first year saw the victory of Type 1 Diabetes over Max's decision to continue to play tennis...