I have developed a ECG analyzer using Edge Impulse software and it has following features:
•ECG Analyzer powered by Edge Impulse will analyze the ECG data without any dependency on the Internet.
•Latency is lowest compared to IoT devices
•A 15Kb Rom - ECG Analyzing TinyML model can run on any TinyML supported microcontrollers.
•The device will analyze ECG patterns and classify into Normal, Atrial Fibrillation and First-Degree heart block
The outcome of the previous work is a library file with all signal processing functionalities where it can be ported into any TinyML supported microcontrollers
The detailed documentation of my previous work is available in the below link.
https://www.hackster.io/manivannan/ecg-analyzer-powered-by-edge-impulse-24a6c2
Library Portability to nRF5340 DKThis project work explains the library portability of ECG Analyzer project into a nRF5340 DK.
Before the detailed technical works, lets go through the basic medical terminologies.
In this project, The model will analyze the PR interval and R to R wave interval.
In order to improve the model prediction accuracy, I created a separate waveforms from filtered ECG data.
New waveforms:
- R-R Interval
- PR Interval
ECG analyzer library is a C library with all predefined signal processing to split the filtered ECG wave into R-R wave and PR wave.
open nRF Connect and open Toolchain manager
Install and open nRF Connect SDK IDE v1.5.0
After opening IDE, We need to import the existing 'nRF connect SDK project'.
I have chosen "Hello world" project, since the nRF5340 DK will communicate to the "Edge Impulse" through Data Forwarder.
The Hello world project will print the statement/data through COM ports, which is sufficient to establish the communication between nRF5340 DK with Edge Impulse.
Select the project directory selection option and trace to the following path
Users\ncs\v1.5.0\zephyr\samples\hello_world
For Board Selection:
Trace to the following path;
C:\Users\ncs\v1.5.0\zephyr\boards\arm\nrf5340dk_nrf5340
The final import project configuration look like this.
Copy and replace the main.c in "hello world" project with ECGlib included in main.c file from below Github link.
https://github.com/Manivannan-maker/nRF5340-DK-ECG_Analyzer
ECG Simulation mode:The nRF5340 DK with ECG Analyzer library will work on simulation mode, Where the ECG data from any open source platform or through AD8232 sensor can be used. The data acquisition should be pasted in the "simulated_ecg_data" buffer in main.c file. The interference time is 5ms.
The Boolean should be set to 1.
The different ECG condition data's are available in the main.c file (line 110). Un comment the necessary condition data buffer and build the code.
From below line, we could see normal, Atrial fibrillation and AVblock 1 cases data buffers are available.
Since it is in simulation mode from nRF5340, the pin connection not required.
Refer for existing research work:
https://www.hackster.io/manivannan/ecg-analyzer-powered-by-edge-impulse-24a6c2
Once the nRF5340 DK board is connected, build and flash the code.
After Flashing, to visualize the data in serial terminal. I have used Arduino ide to see the real time data from COM port 7.
open command window
type " edge-impulse-data-forwarder" and make sure the nRF5340 DK is connected to the system. Then it will get connected to the Edge Impulse.
After getting connected, name the device, I have given nRF5340 and the three signal names as 'Filtered ECG', 'R-R interval' and 'PR interval'.
Then we can notice that board is connected to Edge impulse. It will shows the device name in data acquisition section.
Since the ECG Analyzer TinyML is already created, I am skipping to the testing part.
The achieved accuracy was 97%.
Result:The TinyML model created using Edge Impulse can be flashed easily into nRF5340 DK board and it analyze the heart conditions in simulation mode (=ON).
DemoRecognition of ECG Analyzer :
The project got selected for Tiny talks in recent EMEA TinyML event.
https://cms.tinyml.org/wp-content/uploads/emea2021/tinyMLEMEA2021d2_Manivannan.pdf
Future Works:Implementing the 'ECG Analyzer' TinyML model into the steering wheel with nRF5340 to predict the driver health conditions and to predict the driver attention level as a research continuation.
Comments