ECG_classification

Autoencoder for ECG Classification :heartbeat: :brain: This repository contains code for an autoencoder implemented in Python using TensorFlow for ECG (Electrocardiogram) classification.

What is an Autoencoder? :thinking: An autoencoder is a type of neural network that can be used for unsupervised learning tasks, such as dimensionality reduction or data compression. It consists of two main parts: an encoder and a decoder. The encoder takes an input signal and compresses it into a lower-dimensional representation, called the latent space. The decoder then takes this compressed representation and attempts to reconstruct the original input signal.

Autoencoder Structure :building_construction: The autoencoder implemented in this code consists of the following parts:

Encoder: several convolutional layers followed by a fully connected layer that outputs the compressed representation.

Decoder: several deconvolutional layers followed by a final fully connected layer that produces the reconstructed signal.

Advantages of Using an Autoencoder for ECG Classification :muscle: The advantages of using an autoencoder for ECG classification are as follows:

Unsupervised Learning: An autoencoder can learn to extract useful features from the ECG signal without requiring labeled data.

Data Compression and Denoising: Autoencoders can be used for data compression and denoising, which can improve the performance of downstream tasks such as ECG classification. By compressing the ECG signal into a lower-dimensional representation, the autoencoder can reduce the amount of noise in the signal and remove redundant information, making it easier for a classifier to distinguish between different types of ECG signals.

Results

Loss Accuracy Table

Epoch Loss Accuracy
1 0.6620 0.5900
2 0.5923 0.6836
3 0.5199 0.8952
4 0.4482 0.9382
5 0.3860 0.9492
6 0.3326 0.9502
7 0.2880 0.9532
8 0.2515 0.9542
9 0.2209 0.9555
10 0.1964 0.9572
11 0.1764 0.9590
12 0.1587 0.9600
13 0.1441 0.9630
14 0.1308 0.9645
15 0.1199 0.9680
16 0.1116 0.9695
17 0.1035 0.9702
18 0.0970 0.9722
19 0.0907 0.9735
20 0.0865 0.9742
21 0.0826 0.9762
22 0.0790 0.9747
23 0.0760 0.9752
24 0.0740 0.9787
25 0.0715 0.9782
26 0.0678 0.9787
27 0.0679 0.9792
28 0.0667 0.9800
29 0.0654 0.9805
30 0.0640 0.9817

Confusion Matrix

The confusion matrix for the model on the test set is:

Predicted Negative Predicted Positive
Actual Negative 427 13
Actual Positive 6 554

Performance Metrics

The following performance metrics were computed for the model:

  • Accuracy: 0.9810
  • Precision: 0.9771
  • Recall: 0.9893
  • F1 Score: 0.9831
  • Area Under Curve (AUC): 0.9799

The ROC curve for the model is shown below:

ROC Curve

ONNX Runtime Docker Image for ARM 64

This Docker image installs ONNX and ONNX Runtime for ARM 64. It is based on the Ubuntu 20.04 operating system and includes the Intel oneAPI Base Toolkit for optimized performance on Intel architectures.

Usage

  1. Install Docker: https://www.docker.com/get-started
  2. Build the Docker image: docker build -t onnxruntime-arm64 .
  3. Run the Docker container: docker run -it onnxruntime-arm64

Hardware:

To detect and correctly amplify heart signal to feed into the AI-based network, a analog sensor is designed based on the classical 3-opamp instramentation.
The overall schematic of the ECG amplifier:

image

The team also come up with an approximated model for human body, encorporating left and right atrium and a drivien right leg circuit

image

Dockerfile

The Dockerfile for this image can be found in the official ONNX Runtime GitHub repository. It installs the required dependencies, builds ONNX Runtime from source, and installs it system-wide.

Resources

For more information on using ONNX Runtime, see the official documentation:

Conclusion :memo:

The implementation of an autoencoder for ECG classification is a promising technique that can be used to extract useful features from ECG signals. By compressing the ECG signal into a lower-dimensional representation, the autoencoder can reduce the amount of noise in the signal and remove redundant information, making it easier for a classifier to distinguish between different types of ECG signals. This technique can be particularly useful when labeled data is scarce or expensive to obtain.

Challenges we ran into

ONNX datatype conversion from float64 to tensor(float) Serial Communications

Accomplishments that we're proud of

Successful building the circuit

What's next for Fear No Age

Update GUI and Android APP

Built With

Share this project:

Updates

posted an update

ECG_classification

Autoencoder for ECG Classification :heartbeat: :brain: This repository contains code for an autoencoder implemented in Python using TensorFlow for ECG (Electrocardiogram) classification.

What is an Autoencoder? :thinking: An autoencoder is a type of neural network that can be used for unsupervised learning tasks, such as dimensionality reduction or data compression. It consists of two main parts: an encoder and a decoder. The encoder takes an input signal and compresses it into a lower-dimensional representation, called the latent space. The decoder then takes this compressed representation and attempts to reconstruct the original input signal.

Autoencoder Structure :building_construction: The autoencoder implemented in this code consists of the following parts:

Encoder: several convolutional layers followed by a fully connected layer that outputs the compressed representation.

Decoder: several deconvolutional layers followed by a final fully connected layer that produces the reconstructed signal.

Advantages of Using an Autoencoder for ECG Classification :muscle: The advantages of using an autoencoder for ECG classification are as follows:

Unsupervised Learning: An autoencoder can learn to extract useful features from the ECG signal without requiring labeled data.

Data Compression and Denoising: Autoencoders can be used for data compression and denoising, which can improve the performance of downstream tasks such as ECG classification. By compressing the ECG signal into a lower-dimensional representation, the autoencoder can reduce the amount of noise in the signal and remove redundant information, making it easier for a classifier to distinguish between different types of ECG signals.

Results

Loss Accuracy Table

Epoch Loss Accuracy
1 0.6620 0.5900
2 0.5923 0.6836
3 0.5199 0.8952
4 0.4482 0.9382
5 0.3860 0.9492
6 0.3326 0.9502
7 0.2880 0.9532
8 0.2515 0.9542
9 0.2209 0.9555
10 0.1964 0.9572
11 0.1764 0.9590
12 0.1587 0.9600
13 0.1441 0.9630
14 0.1308 0.9645
15 0.1199 0.9680
16 0.1116 0.9695
17 0.1035 0.9702
18 0.0970 0.9722
19 0.0907 0.9735
20 0.0865 0.9742
21 0.0826 0.9762
22 0.0790 0.9747
23 0.0760 0.9752
24 0.0740 0.9787
25 0.0715 0.9782
26 0.0678 0.9787
27 0.0679 0.9792
28 0.0667 0.9800
29 0.0654 0.9805
30 0.0640 0.9817

Confusion Matrix

The confusion matrix for the model on the test set is:

Predicted Negative Predicted Positive
Actual Negative 427 13
Actual Positive 6 554

Performance Metrics

The following performance metrics were computed for the model:

  • Accuracy: 0.9810
  • Precision: 0.9771
  • Recall: 0.9893
  • F1 Score: 0.9831
  • Area Under Curve (AUC): 0.9799

The ROC curve for the model is shown below:

ROC Curve

ONNX Runtime Docker Image for ARM 64

This Docker image installs ONNX and ONNX Runtime for ARM 64. It is based on the Ubuntu 20.04 operating system and includes the Intel oneAPI Base Toolkit for optimized performance on Intel architectures.

Usage

  1. Install Docker: https://www.docker.com/get-started
  2. Build the Docker image: docker build -t onnxruntime-arm64 .
  3. Run the Docker container: docker run -it onnxruntime-arm64

Hardware:

To detect and correctly amplify heart signal to feed into the AI-based network, a analog sensor is designed based on the classical 3-opamp instramentation.
The overall schematic of the ECG amplifier:

image

The team also come up with an approximated model for human body, encorporating left and right atrium and a drivien right leg circuit

image

Dockerfile

The Dockerfile for this image can be found in the official ONNX Runtime GitHub repository. It installs the required dependencies, builds ONNX Runtime from source, and installs it system-wide.

Resources

For more information on using ONNX Runtime, see the official documentation:

Conclusion :memo:

The implementation of an autoencoder for ECG classification is a promising technique that can be used to extract useful features from ECG signals. By compressing the ECG signal into a lower-dimensional representation, the autoencoder can reduce the amount of noise in the signal and remove redundant information, making it easier for a classifier to distinguish between different types of ECG signals. This technique can be particularly useful when labeled data is scarce or expensive to obtain.

Log in or sign up for Devpost to join the conversation.