Hacker News new | past | comments | ask | show | jobs | submit login
On Building My Own Artificial Pancreas (liamz.co)
115 points by liamzebedee 49 days ago | hide | past | web | favorite | 54 comments



So, for those of you that feel that this is worthy of hacking: Diabetes is one of those diseases that seems right where your average hacker would like it to be. A single value (Blood Glucose Level) which you can read using some sensor and an automated delivery method. Connect A to B using some 30 lines of Python and call it a day. But it is not that simple. The manufacturers of these devices have to go through some pretty strict testing regimes in order to ensure the devices work well when produced in quantity. And that is where the trick lies. Doing this once, for yourself with nobody at risk but you if you fuck up and getting away with it is easy. Doing it repeatably for 10's of millions of people with all your risks analyzed and regulators happy is very, very hard.


That's not the point.

There are three things to an "artificial pancreas": glucose sensor,insulin pump, and the control logic. The difference between an artificial pancreas and the "manual" operation is just that the control logic is automated.

You even can't "fuck up" very easily, unless you add other diabetic stupidities on top of a malfunctioning control logic. Two failure conditions: a) Too little (or no) insulin delivered. b) Too much insulin.

The second one is the more dramatic/short term. The insulin pump has a limited supply of insulin. The speed of injection is limited. There are probably additional safeguards in the pump's software around knowing you are not an elephant breaking into a candy shop. And you feel the pump acting. You can pull it out if it behaves strangely.

Too little insulin delivered may be trickier, but you still have to check the glucose levels occasionally, probably multiple times a day.

Patients already use "algorithms" for insulin delivery. But they are comparatively shitty and designed for example to deliver insulin as a bolus after a meal. Continuous administration of insulin over a pump already has a lot of benefits. A continuous monitoring already has benefits.


Although I would highlight - there is additional high risk now if the sensor becomes faulty, in which case, more insulin could be delivered for incorrect levels while you sleeping, etc.


I don't know if insulin pumps are used while sleeping. After all, there's a needle inserted in your skin.

You wake up from hypoglycemia, long before there is more trouble. And the sensor doesn't post glucose levels for example if it gets detached.


Insulin pumps (and their cannula; not a "needle") are installed 24/7. They can be "suspended" and the insulin delivery hose unhooked, but they are generally there, and active, at all times. Likewise, a CGM (continuous glucose monitor) will provide, as the name says, continuous monitoring. Both use adhesives to keep them attached and generally remain so, even while sleeping.

Hypoglycemia also may not lead to "waking". After all, a diabetic coma may result from low blood glucose, depending on how quickly it crashes.

Source: my girlfriend is Type 1.


Diabetic coma is caused by prolonged hyperglycemia (too much blood sugar) and diabetic ketoacidosis. Many diabetic patients go through months of hyperglycemia and even ketosis before they even know that they have diabetes.

Hypoglycemia in healthy adults mainly results from not eating and develops rather slowly. It's hard to recognize at first, but it will get a lot more obvious before it gets serious.

Hypoglycemia in diabetic patients is more often caused by too much insulin delivered at mealtime and this happens more quickly. Patients can become unconscious before they notice the problem, but usually they recover even without treatment. The goal of diabetes treatment is to avoid this hypoglycemia, also because the body reacts with increased glycogenesis leading to an overshoot of blood sugar.

There are sometimes suicide attempts with insulin. This rarely succeeds, it can result in brain damage, but mostly the patients wake up sometime later.

At night an insulin pump would not need to deliver that much insulin. There are also very long-acting types of insulin, which may be preferable to the short-term insulin in the pump to achieve the "baseline" during the fasting period. Or not. That's a strategy question, I guess. I had type 2 for a short time, and I used long-term and short-term insulin at meal times, with the finger-pricking type of measurement.

I don't think insulin pumps would carry enough insulin or are able to deliver enough.

My point is that there is a relatively large margin of error for any algorithm or software before serious harm occurs, and that the continuous monitoring and delivery is already superior in achieving good glucose curves, regardless if the control loop is manual or automatic.

I've read that continuous sensors help patients to have fewer incidents of hypoglycemia.


Haha, I'm the OP, I use the insulin pump ;)

> You wake up from hypoglycemia, long before there is more trouble

And this is one of the main styles of diabetic death - not waking up (diabetic comatose).

> And the sensor doesn't post glucose levels for example if it gets detached.

I was more referring to the circumstance when you're lying on your sensor in a funny way, and it begins reporting incorrect levels.


You can loose consciousness from hypoglycemia, but normally the body will do everything it can, even autophaging your heart muscle proteins to bring it back up. Unless you have been fasting for a really long time, it will just release glucose from glycogen reserves and you recover quickly.

The diabetic coma thing is the opposite spectrum when the blood sugar is extremely high but the cell metabolism has to run on ketogenic fuel because it gets no glucose. Which leads to ketoacidosis, which can ultimately lead to a coma.


meh still it seems extremely trivial for pretty much any well funded startup to do... and extremely surprising that it does not exist. i mean if theranos can exist, why the hell is this problem not solved?


Well funded start-ups (and established players) are all working on this. Given that the market is huge and Diabetes is yours for life you can bet that a lot of clever people have spent a lot of time on this. Not all of the companies that work on this problem have made it, on top of that it is a patent minefield. It will take you a few 10's of millions of $ or Euros to get to market and you would need to do everything right the first time. Then you still don't know much about how your device will function in the field until enough time has passed that you can judge by the returns where you got it wrong. Doing a respin is expensive.

So, Theranos can exist, and if the money that had gone to Holmes and then this indeed would be a solved problem. But it didn't. Note that there are pumps with a closed loop option on the market today, but they are neither convenient nor simple to use. It is work in progress. I fully expect a simple to use closed loop system to be available in quantity somewhere in the next year or two based on recent market research. The time is indeed ripe. The basic tech is there and the pumps have achieved a level of miniaturization and reliability that it is feasible, there are still problems to overcome but those are all within the realm of the possible, do not require unobtanium and enough parties are working on it (competition is fierce) that at least one of them will solve it within that time frame.


Continuous glucose sensors are relatively new.

It's surprisingly tricky to measure chemical concentrations continuously without replacing the "sensor". Blood and other liquids attack and clog everything.

Without continuous glucose monitoring, you can't do artificial pancreasing.


It is, closed loop system are about to be legal in New Zealand, and the pumps the govt supplies will support it.

It has just taken time.


See Boeing MCAS for an example of how a seemingly simple fix is actually not.


Note that glucose is only a proxy for the actual thing we want to control, which is insulin.


Um...no. Excess glucose kills you slowly with tissue damage and ketoacidosis. Too little glucose kills you quickly by starving your brain of something it needs. So glucose is very much the stuff we want to control. The mechanism for regulating glucose is insulin.


Excess glucose doesn't cause diabetic ketoacidosis, but rather too little insulin. You can run high blood sugar for literally years without going into DKA (although it does damage your body). It's even possible in certain, rare circumstances to enter DKA with normal blood sugar.


You're right. DKA is the result of the body burning fat for fuel when insufficient insulin prevents it from burning glucose. I should have remembered that. My patients with DKA always had a BGL of 500 or more (5x normal), so that's why I mistakenly associated DKA with high sugar.


Insulin controls blood glucose. So how do you figure blood glucose is merely a proxy for insulin and not the actual thing an artificial pancreas is intended to control?


My guess - where does the target blood glucose level come from in a non-diabetic? The thing the body can't produce is insulin. Higher than target blood glucose is a sign that not enough insulin is being produced. I can roughly see the logic there.


As I understand it, target blood glucose levels for diabetics are based on normal blood glucose levels in healthy (non-diabetic) individuals. So presumably a healthy body has some internal mechanism for determining when and how much insulin to produce/release into the blood stream.

As far as I know, we haven't figured out what that mechanism is. But I'm not diabetic and I'm much less prone to being hypoglycemic than I once was, so my reading on the subject is fairly casual compared to when I did things like wrote a research paper on Functional Hypoglycemia in part for my own edification.


That's wrong.


It's a damn shame that years after this became a thing we are still waiting for a proper commercial product to hit the market at a reasonable price, I had a male relative with T1 diabetes and it was a complete burden on his life, We have the technology to improve peoples lives markedly (because we already did) but because of what the author mentioned in the article and the lack of "skin in the game" manufacturers are still dicking about and a lot of this only works because those manufacturers couldn't secure a blowjob in a brothel.

$8000 is just insane (yes I know FDA approval, testing all that jazz) but there ~1.3m Americans with Type 1 diabetes alone, there is a massive demand for a cost effective product at scale.


Someone who can and will build their own is very committed to understanding a great many things. This guy has gone and read what doctors with diabetes have to say because doctors without diabetes are not an adequate source of information for his purposes.

To build one you can sell to anyone who has diabetes (and the money or insurance to cover it) you have to do a lot of "idiot proofing." You can't assume they will keep up with all the information, best practices, etc.

They want it to just work and that's not what you are seeing with the build-your-own crowd.


Making a hardware product that is validated in a regulated market is non trivial. At least part of the cost goes to reducing overall risk to a large market, which open source projects aren't really resourced to address.


Isn't it possible to design the product such that its risks are greatly reduced? E.g. by limiting the amount of insulin it can deliver in a given timeframe?


This comment falls under the "why don't you just..." cluster. Even implementing a feature like that (assuming it made sense) carries risk (imagine if your limiter's sensor broke and it failed open).

Designing reliable systems is incredibly hard. It requires a ton of resources (money, lawyers, engineers) And experience and long time frames with relentless effort to document everything so that when somebody does die, you can root cause it and fix the problem without regressions.

I've been continuously impressed with what open source hackers have done with open biology projects, but that doesn't mean any of these products are reasonable replacements for the products that are used by tens to hundreds of millions of people.


> This comment falls under the "why don't you just..." cluster.

It does, but just this once it is spot on, the best pumps on the market do just that.


yes, it's spot on, but only a tiny part of a much larger system. And even implementing that feature is devishly complicated. Hence my statement "why don't you just".


Agreed - open body-hacking projects are amazing feats of community and perseverance, but the systemic cost and access issues that plague high-end medicine will persist until they’re addressed systemically.


A bit of elaboration on the risks you could encounter here:

- CGM sensors can be faulty, depending on the rate of change of glucose (they’re actually not measuring blood directly, but interstitial fluids, which are generally lagging by about 15mins and can be inaccurate with large swings)

- battery dying out isn’t so bad, since the pump will just default back to its previous basal delivery settings - there are safety maximums on insulin delivery, which prevent among other things, your typical overflow/precision errors

- maximums over time though is a more complex issue, something I haven’t yet dug into


And then there are... pump actuator failure, syringe seal failure (on syringe based pumps), valve failure (on valve based pumps), user error (on all systems), reservoir running out, occlusion, air bubbles and a thousand other things that can go wrong. This is not exactly easy material in the best of cases and most sensor packages do not have redundancy and will at best address only a small fraction of all possible failure modes.


Delivering something fast, accurate and under wildly changing conditions in the human body is far more complicated than most people assume.

I still remember when I had to be hooked up to an infusion pump for many hours at a time. In theory this was all pretty simple - I had a port (a permanent link to my blood system), the machine was hooked to the port, the machine was configured to deliver x ml per hour. Easy, right? Well ... moving my arm had a non-zero chance to trigger the alarm (alarm means "the machine has a problem to deliver the configured amount", please do something), moving in the bed had a higher chance, walking over the hospital corridor I could almost guarantee that at some point in a single walk (i.e. one length of the corridor) it would freak out and again start the alarm. And that's for a far easier system in very easy conditions. An insulin pump has to change what it delivers all the time and it has to work always. Sport, work, driving, running, ...


Adding to what others said, too little insulin can be dangerous, so if users don't know/notice that it stopped delivering more insulin, they might not manually add the requisite amounts.

Forgetting to take medication is dangerous, overdosing medication is dangerous. It is just not that easy to design a system like this.


Making a class 3 medical device (really it's a system of devices, infusion + cgm) that works off the shelf versus something that a hobbiest can throw together are two different games.


Seems to me this is a principle-agent problem, really. Manufacturers and the FDA are only liable for one part of the system's safety - immediate injury or death attributable directly to a specific error. They're not liable for the gradual systemic damage caused by not using closed loop algorithms (due to worse blood glucose control).

Hence hobbyists home brewing this stuff. Only when you're making things for yourself are incentives properly aligned.


Spoken like someone with little knowledge of what it takes to get a medical device approved by the FDA.

As an FYI, you can’t “move fast and break things” when it comes to medical devices.


They apparently do, though.


One would think that insurance companies would jump through flaming hoops to get their diabetes clients the best possible treatment. It is such an expensive condition (I would guess the most expensive), which just gets worse with time.

My sister has T1, and it's a sh!tty disease. She's young, lives a very healthy lifestyle, but still these complications keep creeping up.

I (and my sister) are very lucky to live in a country with socialized healthcare, so there's no financial burden on her - but I can only imagine how expensive it would be for those without that option - worst case the uninsured; more so in the long run.


> It's a damn shame that years after this became a thing we are still waiting for a proper commercial product to hit the market at a reasonable price

How many people is the device allowed to kill when it fails? Who pays the bill when that happens?

The answer to those questions defines the price and availability of a medical device.


Except that you forgot profit.

Also once the device is built and certified subsequent devices are at the cost of materials, support and production (and some profit) ... which I suspect is a bit a bit less than 8000.


I'm curious what the build-your-own-pancreas people have to say about Tidepool's plan to build an iOS app to do the control logic, and at the same time developing standard interfaces to insulin pumps and glucose monitors. Any comments?

https://www.tidepool.org/blog/tidepool-loop-medtronic-collab...


Yes! I think this is fantastic. Tidepool’s employees actually have worked on many of these open-source projects, are funded a lot by the JDRF (one of the biggest T1 Diabetes NFP’s) ans seem to be the most aligned with diabetic’s interests.

Personally I’ve been using their Tidepool software for two years before this and it’s very good. The Tidepool Loop is actually based off of another FLOSS APS called Loop - so it’s likely the efforts will not go to waste. That being said, there’s still possibility that the pump manufacturers have interest to stifle their development - but we’ll see.


> Any comments?

I hope they don't mess up the encryption on the pump commands. Especially with pumps that can deliver high doses that can be really problematic.


Is it possible to have interlocks whereby a pump will refuse to dose more than X ml over Y hours or is a fatal dose for some people in some scenarios less than a therapeutic does for others in other scenarios?


Yes, dosages vary by your size, weight, gender, stress, and other factors. Part of type 2 diabetes is often insulin resistance, but people with type 1 can also suffer from it as well (although it's not the cause of type 1). Some people even need to use highly concentrated forms of insulin, ie U-500 instead of the standard U-100.


Body weight is a huge factor, so what is fine for an adult can kill a child. There are a lot of factors at work here that influence this so there is no easy answer as to what is a 'safe dose'.


This is absolutely amazing!

One thing that's unclear, and perhaps I didn't read carefully enough, is how you're connected to this system.

Do you wear it? Or are you only connected while sitting, sleeping, etc?


Most insulin pumps are worn 24/7 or very close to it (some people will disconnect briefly when showering, plus switching out tubing/etc). Insulin pumps often use a faster acting type of insulin, so that within 3-4 hours, it's all gone, and from there, you quickly enter diabetic ketoacidosis. You can take it off for short periods of time if you make sure to dose for it or take shots periodically while you're disconnected.



OK, I guess. But I was looking for something in TFA.


Hey Vlad - I added some pictures of what I actually wear day-to-day at the bottom of the post. Hope this helps!


Thank you!

So really that's not much at all. Impressive. So I'm guessing that there's a strap/pouch for the pump, right? Are the CGM and injection port adhesive?

And for sure, you're a cyborg now ;) With a body area network (BAN). And with much more stable insulin and glucose levels than you could achieve manually. Very cool.


Body Area Network! Hahahaha love it, going to use this :)

The pump is actually just in your pocket usually, with a big cord hanging out ready to catch on things hehe. The CGM/pump sets are adhesive but not as much as you'd want sometimes.


I'm a bit annoyed people keep calling this an artificial pancreas. The pancreas does a lot more than producing insulin.




Applications are open for YC Winter 2020

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

Search: