Hearing aid algorithm adapted for COVID-19 ventilators

This post describes our paper "Low-complexity system and algorithm for an emergency ventilator sensor and alarm" in the IEEE Transactions on Biomedical Circuits and Systems.

The Illinois RapidAlarm emergency ventilator sensor and alarm system

Audio signal processing would seem to have nothing to do with the COVID-19 pandemic. It turns out, however, that a low-complexity signal processing algorithm used in hearing aids can also be used to monitor breathing for patients on certain types of ventilator.

To address the shortage of emergency ventilators caused by the pandemic, this spring the Grainger College of Engineering launched the Illinois RapidVent project to design an emergency ventilator that could be rapidly and inexpensively produced. In little more than a week, the team built a functional pressure-cycled pneumatic ventilator, which is now being manufactured by Belkin.

The Illinois RapidVent is powered by pressurized gas and has no electronic components, making it easy to produce and to use. However, it lacks many of the monitoring features found in advanced commercial ventilators. Without an alarm to indicate malfunctions, clinicians must constantly watch patients to make sure that they are still breathing. More-advanced ventilators also display information about pressure, respiratory rate, and air volume that can inform care decisions.

To complement the ventilator, a team of electrical engineers worked with medical experts to design a sensor and alarm system known as the Illinois RapidAlarm. The device attaches to a pressure-cycled ventilator, such as the Illinois RapidVent, and monitors the breathing cycle. The device includes a pressure sensor, a microcontroller, a buzzer, three buttons, and a display. It shows clinically useful metrics and sounds an audible alarm when the ventilator stops working. The hardware design, firmware code, and documentation are available online with open-source licenses. A paper describing how the system works is available on arXiv [and now published in the IEEE Transactions on Biomedical Circuits and Systems].

Pressure-cycled ventilators Heading link

Pressure cycle of a ventilator during inhalation and exhalation

The Illinois RapidVent, like many of the emergency ventilator designs produced during the pandemic, is a pressure-cycled mechanical ventilator powered by pressurized gas. In inhalation mode, it delivers a high-pressure oxygen mixture to the patient airway. As the lungs inflate, the pressure in the airway increases. Once the pressure reaches a set level, called PIP (peak inspiratory pressure), the ventilator automatically switches to exhalation mode, allowing gases to exit the lungs. When the pressure drops below a different trigger point, known as PEEP (positive end-expiratory pressure), the ventilator switches back to inhalation mode. The PIP can be adjusted by the clinician using a dial, and in this type of ventilator the PEEP level is a fixed fraction of the PIP level.

Because they are controlled by pressure levels, pressure-cycled ventilators can be monitored by processing the pressure signal measured in the patient airway. The distinctive pressure signal, shown above, should have one major high and low peak during each breath cycle. Thus, a peak detection algorithm can be used to count the breath cycles and ensure that the ventilator is working correctly. To be useful for the COVID-19 emergency, the system should be able to run on small, low-power, inexpensive microcontrollers, which means the algorithm must have low computational complexity.

Dynamic range compression Heading link

Dynamic range compression algorithm

Ventilator monitoring is not the only application that calls for peak tracking with low computational complexity. Hearing aids have similar size and power constraints, and they also perform a form of peak tracking to help control the level of sound signals. Dynamic range compression, a form of automatic gain control, adjusts hearing aid gain in response to signal level. Quiet sounds are strongly amplified, but sounds that are already loud are amplified less. Compression reduces the wide dynamic range of everyday sounds to match the narrower dynamic range of hearing-impaired listeners. They also protect users from loud sounds that could be painful or dangerous if amplified strongly.

Compression systems use envelope detection to track the level of incoming sounds. The envelope is a moving average of the energy of the signal. However, it is not a simple linear average. Compressors are usually designed to respond quickly to increases in sound level, like a sudden loud noise, and slowly to decreasing sound levels, like a pause between words in speech. Thus, the moving average weights increases in signal level more strongly than decreases. Mathematically, the envelope ($v[t]$) is given by the recursive equation

$ v[t] = \begin{cases}
\alpha_A v[t-1] + (1-\alpha_A) p[t], & \text{if } p[t] \ge v[t-1] \\
\alpha_R v[t-1] + (1-\alpha_R) p[t], & \text{if } p[t] < v[t-1], \end{cases} $ where $p[t]$ is the instantaneous power of the signal and $\alpha_A$ and $\alpha_R$ are averaging coefficients between 0 and 1. The “attack” coefficient $\alpha_A$ is smaller than the “release” coefficient $\alpha_R$, meaning that the average changes more quickly in response to signal increases. Thus, this simple algorithm acts as a peak tracker. The recursive envelope detector is useful in a resource-limited system because it does not have to store past values of the signal in memory. In contrast, an algorithm that looked for the maximum value of the signal over the last few seconds would have to store hundreds of samples in memory and search over all of them. Our research group has studied dynamic range compression as part of our work on listening devices. Because of its peak-tracking behavior, robustness to small signal variations, and low computational complexity, recursive envelope detection was a natural choice for the ventilator monitoring system.

Envelope tracking algorithm for RapidAlarm Heading link

Pressure waveform and tracked envelopes

The Illinois RapidAlarm uses two recursive envelope detectors to track pressure signals from the ventilator. One is a normal envelope detector that tracks high-pressure peaks and follows the top of the signal, much like the one used in hearing aids. The second is a reversed envelope detector: it responds to decreases in signal level and so it follows the bottom of the signal. Therefore, two envelope signals follow the high pressure levels reached at the end of inhalation and the low pressure levels reached at the end of exhalation. If the ventilator is working properly, these two envelopes should be spread apart from each other. They should also reach their peak values once per breath cycle.

Breath tracking and clinical metrics Heading link

Pressure and respiratory rate waveforms

The Illinois RapidAlarm tracks breathing by monitoring changes in the two envelopes. While the pressure signal itself may have small fluctuations even during normal breathing, the envelope signals each increase and decrease only once per breath cycle. When the high-pressure envelope enters “attack mode”, increasing rapidly, the system knows that the patient is inhaling. When the low-pressure envelope enters attack mode, the patient is exhaling. The algorithm tracks the peak pressure values of each “attack” cycle as well as the time between them. It uses this data to display clinical metrics.

The Illinois RapidAlarm displays three metrics: PIP, PEEP, and respiratory rate. The PIP is calculated from the last “attack” sample of the high-pressure envelope in each breath cycle. The PEEP is calculated from the last “attack” sample of the low-pressure envelope in each breath cycle. The respiratory rate is calculated from the time between these peak events. All three metrics are smoothed over time so that they do not fluctuate too quickly. They are displayed on the screen of the device, rotating every few seconds.

Alarm conditions Heading link

The most important function of the Illinois RapidAlarm is to alert the clinician if there is a problem with the ventilator. The system has five alarm conditions, each with user-configurable settings.

  1. Low pressure: If the pressure drops to near zero (that is, atmospheric pressure), there may be a disconnection in the system. This alarm triggers immediately when the pressure drops too close to zero.
  2. High pressure: A pressure-cycled ventilator should never exceed the PIP value set by the clinician. The Illinois RapidVent has a pop-off safety valve that activates if the pressure grows too high, for example due to a blockage. If the pressure would for some reason exceed this safety level, the Illinois RapidAlarm will trigger an immediate alarm.
  3. Low respiratory rate: This alarm triggers if the average time between breaths grows too long. Slow breathing could mean that the ventilator is not configured correctly.
  4. High respiratory rate: This alarm triggers if the breathing rate is too fast, which could mean that the lungs have become stiff and not enough air is being delivered with each breath.
  5. Noncycling: This alarm goes off when the ventilator has stopped cycling. This could indicate a disconnection, obstruction, or other problem that must be addressed.
Pressure waveforms with alarm states

The first four alarm conditions are straightforward to implement: they compare the measured pressure signal or calculated respiratory rate to a threshold. The noncycling alarm is more complex because there are many ways for the ventilator to stop cycling. If there is a disconnection, the pressure could drop to zero immediately, which would trigger the low-pressure alarm. However, the pressure could also get stuck at PIP, PEEP, or some other level. It could even oscillate slightly, meaning that there would still be peaks that would trigger the breath tracker even though the patient is not breathing.

To detect noncycling conditions, the Illinois RapidAlarm compares the levels of the two envelopes. During normal operation, the ratio of PIP to PEEP in this type of ventilator should be a constant; for the Illinois RapidVent, it is around 2.4. The noncycling alarm triggers if the two envelopes get too close together. It also triggers if too much time has elapsed since the last attack event. The trigger levels and the envelope coefficients ($\alpha_A$ and $\alpha_R$) must be carefully chosen to ensure that the alarm goes off when it should but does not trigger a false alarm when the knobs are adjusted; see the paper for more information about the parameter calculations.

Illinois RapidAlarm prototype Heading link

The team tested the algorithm in simulations using pressure data collected by the Illinois RapidVent team. After tuning, it correctly identified all the anomalous events that occurred during the trials. The algorithm was then implemented in C code on an Arduino Uno microcontroller board, which uses the 8-bit ATmega328 chip running at 8 MHz. This is one of the lowest-cost, lowest-power microcontrollers on the market and is widely available, making it a good test platform for the Illinois RapidAlarm—if it can run on an Arduino, it can run on anything. To work properly, the algorithm would need to measure the pressure signal at least 10 times per second. Thanks to the low complexity of the recursive envelope-tracking algorithm, the microcontroller was able to process up to 1000 samples per second. Thus, the algorithm can easily run on virtually any low-cost microcontroller.

The Illinois RapidAlarm prototype was constructed on a printed circuit board using the ATmega328 microcontroller. A pressure sensor connects to the ventilator using a tube that attaches on the patient side. It converts the pressure measurement into an electrical signal, which is then converted to a digital value by the microcontroller. The chip reads the signal 100 times per second, which is more than fast enough to track the signal and well within the capabilities of the processor. The microcontroller also connects to three buttons, used to adjust the alarm parameters, a buzzer that sounds when the alarm is activated, and a display that shows the PIP, PEEP, and respiratory rate measurements. The device is powered by a standard 5 V supply, and it could also run on batteries for portable use. A 3D-printed enclosure protects the electronics. The parts are all widely available and can be soldered to the board by hand, so the device can be assembled by anyone with basic electronics skills.

The prototype was tested using the Illinois RapidVent and an artificial lung. The team deliberately disconnected and blocked the tubing and applied pressure to the lung to cause the ventilator to fail. The RapidAlarm successfully detected all the alarm conditions. You can see the device in action in the video below. Thanks to a classic audio processing algorithm, this simple, low-cost device can help to protect patients during this health emergency.