Code Monkey home page Code Monkey logo

tinyml-ecg-'s Introduction

TinyRhythmAnalyzer

TinyML-powered ECG arrhythmia detection on Arduino Nano 33 BLE Sense

demo_gif


Requirements

Hardware

Software


Disclaimer

This project is a conceptual tool intended for educational and research purposes only. It is not a medical device and should not be used for diagnosing or treating health conditions. The outputs of this project should not be considered accurate or reliable for clinical or diagnostic use. The creators of this project are not liable for any misuse or for any direct or indirect damage that may result from the use of the information provided. Always seek the advice of a qualified healthcare provider with any questions you may have regarding a medical condition or health concerns.


Tutorial

I have recorded a video tutorial for this project: link

TinyRhythmAnalyzer Tutorial

And here are the rough steps:

1. Download the MIT-BIH Arrhythmia Database

Download the MIT-BIH Arrhythmia Database and extract the mit-bih-arrhythmia-database-1.0.0.zip file.

2. Train a TensorFlow Model on Colab

Start a new notebook on Google Colab and upload the MIT-BIH Arrhythmia Database to your Google Drive. Clean the dataset to retain only signals with 'N' and 'V' annotations. Address any class imbalances with SMOTE. Develop a model that processes an array of 10 R-R intervals, predicting if the signal is normal or arrhythmic. Save the trained model as a .tflite file, then hexdump it to a .cpp file.

The model can be either a fully-connected neural network or a 1D convolutional neural network. I used the former for simplicity, but the latter makes more sense for time series data like ECG signals. LSTM networks are also a good option.

3. Write the Arduino Code

Write Arduino Code to extract R-R intervals from the incoming ECG signal.

4. (Optional) Test the Code on Local Machine

Test the code for R-R interval extraction on your local machine using CppUnitLite. Testing the TensorFlow Lite model is a bit more complicated. I recommend cloning the TensorFlow Lite for Microcontrollers and overwriting the tensorflow/lite/micro/examples/hello_world example with your own test code. Then, you can run the test using make -f tensorflow/lite/micro/tools/make/Makefile test_hello_world_test.

5. Test the Code on Arduino

Put together the Arduino sketch and test it on the Arduino Nano 33 BLE Sense. I first use a potentiometer to simulate the ECG signal, just to make sure the code is working. Then, I connect the SparkFun Single Lead Heart Rate Monitor to the Arduino and test the code with real ECG signals.

tinyml-ecg-'s People

Contributors

tonyfu97 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.