IDNEO Develops Embedded Computer Vision and Machine Learning Algorithms for Interpreting Blood Type Results
Automate the visual interpretation of cards used by hospital staff to determine patient blood antigenic typing
Use MATLAB to develop, test, and generate embedded code for image analysis and machine learning algorithms
- Accuracy requirements exceeded
- Project completion time halved
- Optimized system delivered
Knowing the blood antigen typing of a patient involved in a medical trauma is often essential for the physician to deliver effective treatment. The Grifols MDmulticard can determine blood antigen typing from a single drop of blood in just five minutes. The card uses lateral flow technology based on immunochromatographic strips to display distinct red bands that indicate the presence or absence of key antigens.
To help clinicians interpret MDmulticard results, Grifols engaged IDNEO to develop an automated card reader. The software for the card reader, developed in MATLAB® and implemented on Android target hardware, includes image processing, computer vision, and machine learning algorithms that translate the patterns and shapes of the bands on the card into blood antigen typing results.
“MATLAB enabled us to rapidly analyze images and improve our algorithms over several iterations,” says Marc Blanch, R&D hardware supervisor at IDNEO. “After we had developed the algorithms, MATLAB made it easy to deploy them to an embedded system. It would have been much more difficult to do this in C or another language, particularly on a short timeline.”
The red bands on the MDmulticard are sometimes misshapen or faded due to humidity, temperature, the patient’s transfusion history, the manual process used to dilute the blood sample, or other factors. As a result, the IDNEO team needed to develop algorithms capable of handling significant variations in band patterns and shapes. The team only had access to a limited number of cards at the start of the project. They needed a workflow that supported rapid iterations so that they could easily refine their algorithms as they received more cards with different band patterns and shapes.
Grifols and IDNEO wanted to deliver a prototype as quickly as possible to enable clinical staff to provide feedback on the software before the algorithms were deployed to production hardware. Because the team was working on a short timeline, they wanted to employ an agile development approach that would enable them to incorporate customer input and react quickly to shifting requirements.
IDNEO engineers developed image processing, computer vision, and machine learning algorithms in MATLAB and then generated code for the production Android implementation of the MDmulticard reader with Embedded Coder®.
The core image analysis algorithm, developed with MATLAB and Image Processing Toolbox™, performs color equalization and white balancing, converts the image to the CIELUV color space, computes color differences, and then locates fiducial markers on the card indicating band patterns in the image. The IDNEO team added band analysis to the core algorithm, creating a binary version of the image and then applying morphological operations to obtain skeleton images for each band on the card.
Next, they implemented a linear regression classifier trained with features extracted from the skeleton images. The classifier detects solid bands (classified as positive), the absence of bands (classified as negative), and mixed-field bands (classified as doubtful), which can occur when a patient has had a previous blood transfusion.
After testing the algorithms on the images provided by Grifols, the engineers designed a user interface with MATLAB App Designer. They used MATLAB Compiler™ to produce a standalone MATLAB app that Grifols engineers and selected hospital staff could use without installing MATLAB.
The IDNEO team generated production C code from the core image analysis algorithms with Embedded Coder. They tested the C code by comparing the results it produced with the results produced by the original MATLAB algorithms, using MATLAB Profiler to measure code coverage.
The team integrated the generated code into an Android app that provides a touch-screen interface to the Grifols MDmulticard reader.
To comply with the customer’s tight schedule, the IDNEO team used the Scrum process framework and continuous integration throughout development. MATLAB supported this workflow, with Jenkins jobs testing the code generated with Embedded Coder against a database of card images.
A fully validated, preproduction prototype of the card reader is undergoing usability testing at various hospitals in Spain. Meanwhile, IDNEO engineers continue to improve the accuracy of their algorithms, using the Classification Learner app in Statistics and Machine Learning Toolbox™ to evaluate support vector machines and other machine learning models.
- Accuracy requirements exceeded. “Our customer set a requirement of greater than 90% accuracy in identifying positive and negative bands,” says Blanch. “The algorithm we developed in MATLAB produced zero false positives or false negatives in the sample data set, so we exceeded that requirement.”
- Project completion time halved. “MATLAB and Embedded Coder enabled us to reduce the time we needed to complete the project from 24 months to 12 months—without adding more engineers to the team,” Blanch says. “This approach enabled team members to focus on their specific roles, making us more efficient as well as reducing the number of software bugs.”
- Optimized system delivered. “Using Embedded Coder to generate C code for the device enabled us to concentrate fully on developing and optimizing our algorithms,” says Blanch. “As a result, we were able to deliver a higher quality system in the time that we had.”