CPAP for COVID

Research notes on using sleep apnea machines as ventilators

Update: Discuss this topic on the cpap-covid-discuss@groups.io forum.

Also see: More CPAP for COVID

What is the idea?

Mass reclamation and reprogramming of the home mechanical ventilators prescribed to treat sleep apnea, for relieving ICU pressure by handling less severe cases during the current crisis.

Possible solutions for virus aerosolisation are discussed. Max capabilities of hardware are analysed and the potential for rapid upgrade via firmware modifications is examined. Software for monitoring fleets of CPAP machines via radio is proposed.

Is this stupid?

The Israeli military is already researching it. And a professor of pulmonary and critical care is also exploring the concept. So probably not, albeit there are challenges to solve. Caveat: I’m a computer scientist, not medically trained. As we shall see this proposal is partly a software problem.

Sleep apnea CPAP devices are mechanical ventilators, designed for home use. They have fewer features and aren’t designed for acute care. However there is growing evidence they’re more useful than previously thought for severe respiratory stress and especially, they can be useful for less severe cases.

Terminology

There is some overlap and confusion with respect to terminology in this space. Here, I will use the term CPAP generically to cover any electric home ventilation device designed for the treatment of sleep apnea. Some medical articles call this NIPSV instead and use the term CPAP for simply connecting the mouth to a pressurised oxygen supply, with no specific machine controlling airflow.

Ventilators both home and hospital support a feature that goes under many different names:

Bi-level

Bi-flex

A-Flex

BiPAP

It means a computer tracks your breathing and increases pressure when you breath in, then reduces it when you breath out. This greatly increases comfort and appears to also increase therapy success. Some manufacturers use “BiPAP” to mean a device that can alter intra-breath pressure by more than a normal Auto-CPAP, but as we shall discuss in a moment that might be an easily overridden software limit.

How many usable machines exist?

This idea is interesting to research because sleep apnea is a common condition and CPAP is the standard therapy for it. There are a large number of CPAP machines in circulation. They have friendly interfaces and are designed to be used and configured by non-experts.

In the UK there are approximately 330,000 people receiving therapy for sleep apnea, or about 0.5% of the population. Apnea is not an acute condition and sufferers can often go years before being diagnosed and treated — many never are. In an emergency almost all of those machines can be requisitioned.

If even a fraction of them can be put to work treating the less severe cases, that could yield an immediate and massive turnaround in the situation.

Another advantage is that CPAP machines are already mass manufactured in much greater quantities than hospital ventilators are, with multiple competing producers. Production lines could likely be scaled up far faster than for the specialist low volume lines used normally by hospitals.

Finally the huge number of machines means they could be distributed to hospitals grouped by brand, reducing the already minimal training costs.

Need for reprogramming

Modern CPAP machines have simple hardware attached to a relatively sophisticated computer running advanced proprietary algorithms. Manufacturers spend a lot of money on software R&D to differentiate their products.

As a consequence, the difference between a cheap machine and an expensive fancy one might be primarily a difference of installed software. I’ll support this assertion with evidence in a moment. In an emergency the manufacturers could be asked or required to release firmware upgrades to convert every machine to its physical maximum set of capabilities. Once the epidemic is over the machines could be down-converted again to restore licensing compliance (or simply replaced).

CPAP firmware upgrades are straightforward to apply and can be done by untrained people.

How many less severe cases could be treated?

This is hard to say but initial research is encouraging. An analysis from Imperial College states:

when applied to the GB population result in an IFR of 0.9% with 4.4% of infections hospitalised (Table 1). We assume that 30% of those that are hospitalised will require critical care (invasive mechanical ventilation or ECMO)

So they’re working from 1/3rd requiring critical care, not 2/3rds. How many people might require non-acute breathing assistance with the Imperial numbers then?

Take the UK population of 68 million * 70% infected * 4.4% hospitalised * 66% requiring non-critical care = 1,382,304 people or ~4.2x the number of available CPAP machines. However these people won’t all get sick at once but rather over a period of months, and the average hospital stay for non-acute cases is only a few days to a week — so it looks plausible that we could provide mechanical breathing assistance to all non-acute cases, if CPAP machines can be adapted in time.

On the other hand in the paper “Care for critically ill patients with COVID-19” it says:

The most documented reason for requiring intensive care has been respiratory support, of which two-thirds of patients have met criteria for acute respiratory distress syndrome (ARDS).

So it seems there’s confusion about the true split of acute vs non-acute, but even taking the higher Imperial figure it’s still within the right order of magnitude for what’s feasible. The paper says people exist at all points on the severity slope, as they get worse gradually:

The median duration between onset of symptoms and ICU admission has been 9 to 10 days, suggesting a gradual deterioration in the majority of cases.

In the 2014 paper, “Noninvasive ventilation in acute respiratory failure” the topic of using non-invasive ventilation (NIV) for respiratory failure is explored. NIV stands in contrast to invasive ventilation, called tracheal intubation, involves inserting a tube down someone’s throat and into the lungs. NIV includes CPAP machines:

NIV is currently used in a wide range of acute settings, such as critical care and emergency departments, hospital wards, palliative or pediatric units, and in pre-hospital care. It is also used as a home care therapy in patients with chronic pulmonary or sleep disorders.

It can be useful for patients prior to severe lung failure:

In settings with limited access to invasive ventilation or prior to patients developing severe hypoxemic respiratory failure, there may be a role for high-flow nasal oxygen or noninvasive ventilation

So it stands to reason that a lot of people may benefit from less-than-the-best ventilation, especially if access to ventilation earlier than ICU admission aids the body with fighting the disease.

Via small modifications it appears CPAP machines can even form the basis of more acute care, e.g. they can be connected to oxygen supplies (see below).

Why isn’t this being discussed more?

I don’t know. Perhaps there’s some killer problem obvious to most except me. The Israeli army may be going down a dead-end.

Or, they might be ahead of the curve. As far as I can tell based on a day of research there’s no obvious dead-end with this approach, and other people are proposing less practical ideas. And there is a little bit of pre-COVID discussion from doctors about using it to treat pneumonia.

The current low levels of discussion might be due to:

Lack of familiarity with what hospital ventilators do. Lack of familiarity with CPAP machines (which are obscure outside the community of sleep apnea sufferers). Long-term under-diagnosis of sleep apnea due to its non-critical nature and consequent lack of deep familiarity with the capabilities of modern machines, even in the medical community. Lack of prior interest because intubation is considered the correct, tried-and-tested treatment for pneumonia. Concerns over aerosolisation of the virus via the exhaust ports (see below for ideas on how to handle this).

With respect to a lack of prior interest, the medical community already has a tried-and-tested way to save lives in case of pneumonia — endotracheal intubation (EI) — which means less aggressive techniques are controversial (what if they fail?). Nonetheless the medical world is coming around to the usage of it thanks to evidence from controlled trials. The 2014 research paper states:

The utility of NIV in patients with community-acquired pneumonia (CAP) is controversial because some data suggested that delaying EI with NIV could increase mortality; however, several randomized clinical trials have compared the efficacy of NIV over conventional oxygen therapy in patients with CAP, reporting a significant reduction in EI rate, shorter ICU stay, and lower mortality, mainly in patients with chronic obstructive pulmonary disease. Therefore, a trial of NIV may be recommended in these patients.

Intubation is a complex and risky procedure, which can itself severely damage the body. Given the predicted imminent exhaustion of invasive ventilation capacity around the world, there are huge reasons to rely on NIV as much as possible and allocate the remaining hospital-grade ventilation to the patients most in need.

With respect to point 3 (lack of familiarity) I’m starting to suspect that CPAP technology has been outpacing propagation of information about its capabilities. This can often happen with rapid progress in consumer electronics, which is what CPAP machines are. In recent years there’s been a huge increase in awareness and diagnosis of sleep apnea, yet most people with the condition are still undiagnosed. This has led to a competitive market for the machines and because many features require only software upgrades, a very rapid increase in their feature set has occurred.

I can only justify my comment about lack of familiarity in the medical community with an anecdote: my own sleep specialist in Switzerland didn’t configure bi-level pressure for me, despite the huge improvement this feature makes. I had to learn that it existed, what it was, how to unlock the device into “doctor mode” and how to activate it myself. Activating it immediately and massively improved my therapy — when I told the doctor what I’d done he was approving and happy that I’d figured it out on my own.

Requested features

The UK medical community has issued via the government a specification for rapidly manufactured ventilators. A small company called G-Tech has already produced a prototype of a purely mechanical ventilator powered by air pressure (no electricity).

CPAP machines require electricity. Why did G-Tech build a machine without electricity requirements? Possibly to reduce complexity, but I suspect it may also be because the government provided with the request to manufacturers a paper from 2010 that studied how to rapidly manufacture ventilators. The authors of this paper designed a machine that could run without electricity. Their motivation was deployment in military settings, irrelevant at the moment. Running without electricity will be considered a non-goal.

The UK spec says:

The [system] must: Be reliable. It must work continuously without failure (100% duty cycle) for blocks of 14 days — 24 hours a day. If necessary, the machine may be replaced after each block of 14 days x 24 hours a day use. Provide at least two settings for volume of air/air O2 mix delivered per cycle/breath. These settings to be 450ml +/- 10ml per breath and 350ml +/- 10ml per breath. Provide this air/air O2 mix at a peak pressure of 350 mm H2O. Have the capability for patient supply pipework to remain pressurised at all times to 150mm H20.

CPAP machines are highly reliable. They support bi-level pressure with automatic pressure determination within pre-set ranges.

Peak pressure is important — more acute cases need higher pressures. Consumer CPAPs have a peak pressure of 20 cm/h2o but the spec requires at least 35. This is a safety limit and isn’t a limitation of motor strength. Evidence for this comes from two places. Firstly, a DreamStation service manual:

When assessing the relative risks and benefits of using this equipment, the clinician should understand that this device can deliver pressures up to 20 cm H2O. In the event of certain fault conditions, a maximum pressure of 40 cm H2O is possible.

So the motor can go up to 40cm/h2o and from this warning it seems likely there’s no kind of hardware interlock preventing it — probably only firmware control. Secondly, someone took apart their CPAP machine and measured the max strength of the blower, obtaining 45 cm/h2o at full blast.

It seems likely that at least some CPAP machines can be re-programmed to go to 35 cm/h2o via firmware hacks, or with manufacturer assistance.

Some requested requirements seem to be for the most acute cases. I don’t know how far away CPAP machines are from meeting them:

“Be capable of breathing for an unconscious patient who is unable to breathe for his or herself”

Complete inability to breathe rather than just difficulty isn’t true for all COVID-19 hospitalisations, so meeting this requirement isn’t strictly necessary — less severe patients can be treated with machines that just assist, freeing up pro-grade ventilators for these cases.

However, some of the more expensive BiPAP machines do advertise this as a feature, and as we’ve seen the motors in even cheaper machines can create extreme pressures. So is this just a matter of a software patch to provide for all machines?

Oxygen supplies

The UK spec says:

Be able to supply pure air and air O2 mix at a range of concentrations including at least 50% and 100% Oxygen. Support connections for hospital Oxygen supplies — whether driven by piped or cylinder infrastructure.

CPAP machines can be attached to oxygen flows (more instructions here).

It’s currently unclear to me if that means they can tolerate 100% O2, as oxygen is a highly reactive gas and can damage some kinds of components.

However most users of the machines don’t need oxygen support and thus won’t have the necessary valves (“bleed adapters”). They are readily obtainable. Additionally it appears valves may be fabricated quickly using 3D printers. As far as I can tell nothing fancy is required for this: the adapters are ultimately just T-pieces.

Be compatible with standard COTS catheter mount fittings (15mm Male 22mm Female)

I don’t know but this looks like another pipe interop requirement that could potentially be fixed with a wide variety of materials or 3D printers.

Fail safe, ideally generating a clear alarm on failure. Failure modes to be alarmed include (but are not limited to) pressure loss and O2 loss.

My DreamStation can be connected to an oximetry sensor. I don’t know what it does with this data. However, I think this requirement should be treated as a nice to have. The current problem is an impending lack of any ventilation at all: a ventilator that may break without triggering an alarm is still better than not having one.

Nonetheless, we can potentially address this need quite quickly (see below).

Visualisation and alarms

Acute hospital ventilators provide sophisticated real-time diagnostics and a variety of alarms to attract attention when something goes wrong. Home devices log a lot of data but show relatively little in the user interface, as it’s designed for home use — they primarily care about a score called “AHI” which is probably irrelevant for pneumonia patients.

A key visualisation is a loop diagram. Here’s an example taken from “Notes from chatting with a pulmonologist”:

This visualisation is used in combination with watching the patient to incrementally increase or decrease the pressure as lung conditions change. Changes in situation can trigger alarms.

A Puritan Bennet ventilator. Loop diagrams are visible on the right.

In an equipment shortage advanced monitoring may become a luxury, but can we quickly replicate this with consumer CPAP machines anyway?

Modern CPAP machines log data to SD cards. The data is exceptionally detailed and typically contains a complete waveform of every breath taken. This is sufficient to compute loop diagrams. Flow rates and tidal volumes are available. Accessing it requires switching the machine off and removing the card.

However, switching the machine off to gather data is a non-starter. Can we tackle this?

Some machines make that same data available via Bluetooth. For the machines without Bluetooth a wireless SD card can be used to grant access to the logged data without needing to move the card around and (probably, with some hacks) without needing to turn it off. There’s a bit of a software engineering challenge here: the requirement to turn the device off before removing the card isn’t there just to be annoying.

The data formats have been reverse engineered by the SleepyHead project. Thus we have open source code that can read the logs from many different manufacturers.

My Phillips DreamStation exports the following timeseries:

Flow rate / breath waveforms

Pressure (which varies because the machine can auto calibrate within a pre-set range)

Leak rates, e.g. to detect the mask falling off

Respiratory rate

Tidal volumes

Inspiration/expiration times

Amount of air displaced per minute

And maybe more.

Fleet monitoring

Existing software is all designed for post-hoc analysis, not real time monitoring. Building a real-time monitoring solution for a fleet of CPAP machines would close some of the gap with industrial-grade ventilators. Such a program would constantly download fresh log data from the machines over radio connections and compute loop diagrams on the fly. It would trigger loud alarms using the larger volumes of laptops or attached speakers, could be rapidly upgraded to assist with directing care (as it’d be a standard desktop app) and could be used to monitor fleets of patients simultaneously from a central location, reducing the need for staff movement.

Virus aerosolisation

One reason hospitals insert a pipe down people’s throats to treat viral pneumonia is that endotracheal intubation involves inflating a small balloon to seal the throat around the pipe. This means airflow in and out of the lung is completely controlled by the ventilator which can filter out virus particles, keeping the surrounding air clean.

CPAP machines vent air directly into the atmosphere surrounding the mask via small exhaust ports, to get rid of CO2. Combined with high pressure this means infected phlegm would be effectively sprayed into the air where it is maximally infectious. Hospital ventilators exhaust air through high grade N100+ filters. Some doctors seem to be reluctant to use CPAP to treat COVID-19 for this reason: that’s clearly the right call whilst hospitals still have pro-grade ventilation available.

I can see three quick approaches to tackling this problem:

Don’t tackle it. Assume medics are already exposed to aerosolised virus, and are wearing masks or using other techniques like negative pressure rooms to avoid this being a problem.

Cover exhaust ports with chopped up surgical mask. The theory behind protective masks is that they’re made of tiny fibers that are able to let air through whilst catching infected material. Masks are semi-flexible. By chopping a mask up and then lightly glueing or sticky-taping the pieces to the mask exhaust port, CO2 would still be able to escape but virus material would be contained. Once a mask piece was fully saturated it could be removed and replaced.

Cover existing exhaust ports with masking tape and create a new one. The difference between a hospital ventilator and a CPAP is where the air comes out and what it comes out through. The exhaust ports in a CPAP don’t involve any fancy mechanical valves, they’re just perforated surfaces or small slits. Pro-grade ventilators take the exhaled air and push them through N100 filters.

If filters can can be quickly obtained then T-pieces designed to hold them in place can be 3D printed and attached to the mask/hose interface, ensuring exhaled air is forced through the filter. These sorts of small plastic solid-state parts are ideal for 3D fabrication labs. Here’s an Italian group that made hospital connectors for a snorkeling mask:

How quickly can filters be obtained? As they’re a component of ventilators, more quickly than ventilators themselves for sure. Ramping up filter material production is difficult due to the need for specialised manufacturing machines, but asking mask manufacturers to redirect some mask material to build small filter plugins seems reasonable.

Protect medical workers using CPAP machines too. This is a variant of “don’t tackle it”. Rather than try to stop virus escaping into the air, accept that it will and try to stop it entering medical staff. CPAPs create positive air pressure within the mask environment, meaning air from the outside can’t get in except via the CPAP’s intake port. These ports already come with small replaceable air filters that need to be replaced monthly, so they are mass manufactured already.

A protective device of this kind is called a “powered air purifying respirator”. Here’s how it’d work:

Medics carry a small backpack with the machine inside, attached to a regular 12V DC battery.

Medic straps on a CPAP mask like this one. The hose attaches to the top of the head via a swivel mount and is fed straight into the backpack, so it doesn’t dangle in front of the medic and get in the way. The air then flows via a comfortable rubber fit straight into the nose and mouth.

The machine may or may not have been fitted with an upgraded filter (e.g. from chopped up surgical masks), but even the standard filters are better than nothing because they’re easy to replace and sleep apnea patients have long-term supplies that could be quickly requisitioned.

The medic starts the machine. With eye gear they’re now somewhat protected from airborne viruses because external air can only reach them via the filter.

Johnny Lee, “Building a PAPR”

Some types of CPAP headmask only attach to the nose, leaving the mouth free. With these masks you can still talk, which is useful. Even at low pressures talking can be awkward and your voice sounds weird, but it’s possible. At higher pressures talking gets progressively harder because opening the mouth causes air to come out of it, but because some modern masks are entirely rubber the nose mount can be momentarily lifted to restore normal pressure and allow unimpeded speech. If speaking regularly is needed a standard surgical mask would still be required to cover the mouth.

This is not the same kind of portable breathing device you might see in the movies. It still takes air from the surrounding environment. And obviously these machines are not designed to actually let you work in contaminated air. However if all you need to do is ensure you’re breathing lightly filtered air, it’s probably better than nothing.

Next steps

Feedback from medical experts (i.e. outside the Israeli military) would obviously be great.

If the idea isn’t useless then the simplest next steps are:

Figure out the best way to attach chopped up mask or filter to exhaust ports, (and/or intake ports for portable protective equipment).

Flagging the possibility to governments so they can begin planning track and trace of machines.

To contact firmware teams at CPAP manufacturers to verify some of the propositions.

To prototype software that can do real-time monitoring of machine logs via radio, instead of the bulk post-hoc extraction via SD card current software is capable of.

Assistance with the above would be welcome; get in touch: mike@plan99.net