7.7.14. ECG Classification

Edge AI solution for real-time ECG signal classification on the MSPM0G5187 with NPU. Classifies ECG signals into cardiac conditions for portable, low-power heart monitoring.

7.7.14.1. Overview

Cardiovascular diseases (CVDs) are the leading cause of death globally, responsible for approximately 17.9 million deaths per year. Early detection through continuous ECG monitoring significantly improves patient outcomes. However, traditional ECG analysis requires expensive medical equipment and trained professionals, limiting access to timely diagnosis.

This example demonstrates how Edge AI enables real-time cardiac classification on portable, low-power devices – without the need for cloud connectivity. By deploying a CNN-based model directly on the MSPM0G5187 microcontroller with NPU acceleration, ECG signals can be classified into multiple cardiac conditions at the point of care.

  • Application: Wearable health monitors, portable cardiac monitoring devices

  • Task Type: Time Series Classification

  • Primary Device: MSPM0G5187 (with NPU)

  • Also Supported: AM13E2, F28P55

Note

Device-specific configuration files are provided as config_<device>.yaml. See the Available Configurations section below for details.

7.7.14.2. Key Performance Targets

  • Real-time ECG classification on-device

  • Low power consumption suitable for wearables

  • Greater than 95% classification accuracy

  • LED feedback for classification results

7.7.14.3. System Components

Hardware

Software

  • Code Composer Studio (CCS) 12.x or later

  • MSPM0 SDK 2.08.00 or later

  • TI Edge AI Studio

7.7.14.4. Dataset Details

Dataset: ecg_classification_4class

The dataset contains ECG recordings labeled into the following classes:

Class

Description

Normal

Healthy sinus rhythm

Mild

Minor cardiac abnormalities

Other

Other cardiac conditions

7.7.14.5. Feature Extraction

The feature extraction pipeline for MSPM0 (preset ECG2500Input_Roundoff_1Frame) processes the raw ECG signal as follows:

  1. Sampling: 2500 samples per frame from the ECG input

  2. Normalization: Signal normalization by rounding off

  3. Framing: Single frame input to the model

data_processing_feature_extraction:
  feature_extraction_name: ECG2500Input_Roundoff_1Frame

7.7.14.6. Model

ECG_55k_NPU (Default)

A CNN architecture optimized for the MSPM0G5187 NPU, with approximately 55K parameters. This model is designed for NPU-compatible inference, enabling efficient real-time classification on the target device.

Model

Parameters

Description

ECG_55k_NPU

~55,000

CNN optimized for NPU, default for MSPM0

Expected Accuracy: ~97%

7.7.14.7. Training Configuration

The default training hyperparameters for the MSPM0 configuration:

Parameter

Value

Batch size

12

Learning rate

0.001

Optimizer

Adam

Weight decay

4e-5

Epochs

25

Quantization: INT8 quantization is enabled by default for deployment.

Compilation: Uses the TI Neural Network Compiler (NNC), optimized for the MSPM0G5187 NPU.

7.7.14.8. Configuration (MSPM0)

common:
  target_module: 'timeseries'
  task_type: 'ecg_classification'
  target_device: 'MSPM0G5187'

dataset:
  dataset_name: ecg_classification_4class

data_processing_feature_extraction:
  feature_extraction_name: ECG2500Input_Roundoff_1Frame

training:
  model_name: ECG_55k_NPU
  batch_size: 12
  learning_rate: 0.001
  weight_decay: 4e-5
  optimizer: 'adam'
  training_epochs: 25
  num_gpus: 0

testing:
  enable: True

compilation:
  enable: True

7.7.14.9. Running the Example

# MSPM0G5187 (primary target)
cd tinyml-modelzoo
./run_tinyml_modelzoo.sh examples/ecg_classification/config_MSPM0.yaml

# AM13E2
./run_tinyml_modelzoo.sh examples/ecg_classification/config.yaml

# Anomaly detection mode
./run_tinyml_modelzoo.sh examples/ecg_classification/config_anomaly_detection.yaml

7.7.14.10. Available Configurations

Config File

Target Device

Mode

config_MSPM0.yaml

MSPM0G5187

Classification (4-class)

config.yaml

AM13E2

Classification

config_anomaly_detection.yaml

F28P55

Anomaly Detection

7.7.14.11. Anomaly Detection Mode

A separate anomaly detection configuration is available for ECG monitoring using the config_anomaly_detection.yaml file. This mode trains on normal ECG recordings only and detects anomalies based on reconstruction error, which can be useful when labeled fault data is not available.

common:
  task_type: 'generic_timeseries_anomalydetection'
  target_device: 'F28P55'

dataset:
  dataset_name: 'ecg_ad'

training:
  model_name: 'AD_Linear'
  training_epochs: 200

7.7.14.12. References

7.7.14.13. See Also