Keep Your Fluids Up with Arduino and Edge Impulse

When a patient is admitted to a hospital, one of the first things to happen is the insertion of an intravenous (IV) drip line. This is to ensure that the patient stays hydrated and to prevent electrolyte imbalances that could further complicate any other health issues that are present. The drip also provides a quick way to administer any needed IV medications. Despite the ubiquity of this first step in a treatment plan, IV drips carry significant risks with them. Chief among those risks is the total emptying of the IV bag. If a bag empties while still attached to a patient, it can introduce air bubbles into the bloodstream that may travel to the brain, heart, or lungs and cause a heart attack, stroke, or respiratory failure.

There are ways to track the fluid level of an IV bag, but they can be cumbersome and expensive. And if this tracking is left up to hospital staff, it can lead to life threatening situations due to human error, especially when the hospital starts to get busy. Manivannan Sivan decided to put his machine learning expertise to work in solving this problem and developed an interesting solution that has the potential to save time, money, and maybe even lives. His proof of concept device uses computer vision to continually monitor an IV bag so that it can trigger an alarm before it has a chance to completely empty.

Sivan chose an Arduino Portenta H7 development board to power his prototype. The Portenta H7 was designed for high-performance applications, with an STM32H747XI dual Cortex-M7+M4 CPU and 8 MB of SDRAM. It was paired with an Arduino Portenta Vision Shield to add a 320 x 320 pixel image sensor. To develop a machine learning pipeline that can perform optimally on a resource-constrained device such as this, Sivan used Edge Impulse Studio.

Sample training data

Since an image classifier should be able to determine the fluid level of an IV bag, Sivan decided to create an image classification model.  But before doing so, a set of example images was collected and uploaded to Edge Impulse to serve as the training data for that model. In total, 117 images were captured to represent the classes to be recognized, namely “adequate," “less than 50%," and “low."

While designing the impulse, preprocessing steps were added to resize the images and extract the most important features — both very important steps in preparing a model to run on a microcontroller with limited compute resources. The processed data then serves as the input for a convolutional neural network. These types of networks can use a great deal of memory, so Sivan tweaked the model’s design such that it would fit nicely within the Portenta’s available memory.

Building a model optimized for tinyML

The neural network was then trained on the example images within Edge Impulse Studio.  A testing dataset, that was not a part of the training process, was used to evaluate the model after training. A very high classification accuracy of 95.8% was observed. Sivan noted that the images that were incorrectly classified resulted from different levels of light exposure as compared to the training data. This is not a surprising finding considering the very small size of the training dataset. Collecting a bit more data to further train the model on would be expected to resolve this minor deficiency.

Validation of the model’s performance

To decouple the device from the cloud, the model was deployed directly to the Arduino board.  Edge Impulse fully supports both the Portenta H7 and the Vision Shield, so it only took a few clicks to build custom firmware and flash it to the hardware. At that point the device was ready to monitor an IV bag’s fluid level. Sivan notes that it would not take much additional work to have a network of these IV fluid level detectors that all report their results to a central monitoring system. As he points out, similar systems could also be implemented to monitor fluid levels in various machinery in industry and laboratories.

If you might be able to use a fluid level monitor of your own, you are in luck because Sivan has made his Edge Impulse project public. Be sure to check out the documentation page as well for all the details about the build.


Want to see Edge Impulse in action? Schedule a demo today.

Comments

Subscribe

Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

Subscribe to our newsletter