dart_ecg 0.1.0 copy "dart_ecg: ^0.1.0" to clipboard
dart_ecg: ^0.1.0 copied to clipboard

Pure Dart port of NeuroKit2 ECG processing module. Provides ECG signal cleaning, R-peak detection, delineation, quality assessment, simulation, and full processing pipeline.

dart_ecg #

A pure Dart port of the renowned NeuroKit2 ECG processing module. dart_ecg provides clinical-grade ECG signal processing, R-peak detection, quality assessment, and delineation functionalities directly in Dart, allowing Flutter and pure-Dart developers to run sophisticated biosignal algorithms natively without requiring Python backends or native FFI calls.

Features #

  • 100% Pure Dart: No native dependencies, FFI, or Flutter-specific code. Works across all Dart platforms (Web, iOS, Android, Windows, macOS, Linux).
  • Algorithmic Parity: Extensively tested against NeuroKit2 with >0.99 morphological correlation and ±1 sample precision for R-peak indexing.
  • ECG Processing Pipeline: Fully automated orchestration matching the ecg_process flow.
  • R-Peak Detection: Includes the top algorithms: neurokit, pantompkins1985, hamilton2002, elgendi2010, engzeemod2012.
  • Signal Cleaning: Advanced zero-phase (filtfilt) Butterworth filtering, powerline noise removal, and baseline wandering reduction.
  • Delineation: DWT-based and Peak-search based delineation for finding P, Q, S, and T waves.
  • Quality Assessment: Signal quality mapping (e.g. zhao2018, averageQRS).
  • Simulation: Simulate realistic clinical ECG signals using the McSharry dynamical model with 4th-order Runge-Kutta integration (ecgSimulate).

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  dart_ecg: ^0.1.0

Usage #

High-level Processing (The Pipeline) #

The easiest way to process an ECG signal is to use the ecgProcess orchestration function, which cleans the signal, finds R-peaks, calculates rate, and delineates the waves.

import 'package:dart_ecg/dart_ecg.dart';

void main() {
  // 1. Get some raw ECG data (List<double>)
  List<double> rawSignal = [/* ... */];
  
  // 2. Process the signal
  final result = ecgProcess(
    signal: rawSignal,
    samplingRate: 1000,
  );
  
  // 3. Use the results
  print('Detected ${result.info.rPeaks.length} R-Peaks.');
  print('Average Heart Rate: ${result.signals['ECG_Rate']}');
}

Low-level Modules #

You can also use the individual modules directly if you only need specific functionalities:

// 1. Clean the signal
final cleaned = ecgClean(
  signal: rawSignal,
  samplingRate: 1000,
  method: EcgCleanMethod.neurokit,
);

// 2. Find R-Peaks
final peaks = ecgFindpeaks(
  signal: cleaned,
  samplingRate: 1000,
  method: RPeakMethod.neurokit,
);

print(peaks.rPeaks);

Disclaimer #

MEDICAL DISCLAIMER: dart_ecg is a software library designed for research, education, and informational purposes only. It is NOT a medical device. The algorithms and results provided by this library are not intended for use in the diagnosis, cure, mitigation, treatment, or prevention of disease or any other medical condition. Always consult a qualified healthcare professional for medical advice and interpretation of physiological signals. The authors and maintainers of this library assume no responsibility or liability for any clinical decisions made based on the output of this software.

Architecture #

This library leverages advanced DSP techniques (IIR/FIR zero-phase filtering, DWT, etc.) using iirjdart and fftea. All algorithms are exact mathematical ports from Python's NeuroKit2, ensuring that research validated in Python transitions seamlessly into production Dart environments.

0
likes
140
points
33
downloads

Documentation

API reference

Publisher

verified publisherspinex.io

Weekly Downloads

Pure Dart port of NeuroKit2 ECG processing module. Provides ECG signal cleaning, R-peak detection, delineation, quality assessment, simulation, and full processing pipeline.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

collection, fftea, iirjdart

More

Packages that depend on dart_ecg