Skip to content

upsidedownlabs/Rpeak

Repository files navigation

Rpeak - Real-Time Heart Monitoring Application

A comprehensive web application for real-time ECG monitoring, heart rate variability analysis, and AI-powered heartbeat classification. Built with Next.js, TensorFlow.js, and modern web technologies for in-browser ECG signal processing.


Note:
This application is currently in the development and testing phase. Features, performance, and results may change as improvements are made. Please use for research, learning, and prototyping only not for clinical or diagnostic purposes.


✨ Key Features

  • Real-time ECG monitoring with live waveform at 360Hz sampling rate.
  • Advanced heart rate analysis using multiple peak detection algorithms and physiological validation.
  • Detection of PQRST wave components.
  • AI-powered heartbeat classification based on the AAMI EC57 standard.
  • Session recording for long-term monitoring and detailed analysis reports.

πŸš€ Quick Start

Prerequisites

  • Modern web browser with Bluetooth support (Chrome, Edge)
  • Compatible Npg Lite device with Bluetooth connectivity
  • Node.js 18+ (for development)

Installation

  1. Clone and setup:

    git clone https://github.com/yourusername/Rpeak.git
    cd your_foldername
    npm install
  2. Start development server:

    npm run dev

    Open http://localhost:3000


πŸ”§ How to Use

1. Connect Your Npg Lite device

  • Click the πŸ”΅ Connect button in the sidebar
  • Select your Npg Lite device from the browser's device list
  • Wait for "Connected" status
  • ECG waveform will automatically start displaying

2. Monitor Your Heart

  • Real-time waveform display of your ECG signal
  • Automatic heart rate calculation from detected beats

3. Enable Analysis Features

Click sidebar buttons to activate different analysis tools:

Button Feature Description
πŸ«€ PQRST Wave Analysis Identifies P, Q, R, S, T wave components
⏱️ Intervals Clinical Measurements PR, QRS, QT intervals with normal ranges
πŸ’“ HRV Heart Rate Variability RMSSD, SDNN, stress level analysis
πŸ€– AI Analysis Beat Classification Neural network heartbeat classification
πŸ“Š Session Recording & Reports Long-term monitoring with detailed analysis

4. Record Sessions (Optional)

  • Click πŸ“Š Session to start recording
  • Monitor for desired duration (5-10 minutes recommended)
  • Stop recording to generate comprehensive analysis report

πŸ“ˆ Understanding Your Results

Heart Rate

  • Normal: 60-100 BPM (resting)
  • Bradycardia: < 60 BPM (may be normal for athletes)
  • Tachycardia: > 100 BPM (exercise, stress, or medical condition)

HRV Metrics

  • RMSSD: Higher values (>30ms) indicate better cardiovascular fitness
  • Stress Level: Derived from multiple HRV parameters
  • LF/HF Ratio: Balance between sympathetic/parasympathetic nervous systems

ECG Intervals

  • PR Interval: 120-200ms (normal conduction)
  • QRS Duration: 80-120ms (ventricular conduction)
  • QT Interval: Rate-corrected using Bazett's formula

AI Classification (if enabled)

  • Normal (N): Healthy heartbeats
  • Supraventricular (S): Beats from above ventricles
  • Ventricular (V): Beats from ventricles (may need attention)
  • Fusion (F): Mixed morphology beats
  • Other (Q): Unclassifiable or paced beats

⚠️ Important: This is not a diagnostic tool. AI classification features are currently experimental and under development. Results should not be used for medical diagnosis or treatment decisions. Always consult qualified healthcare professionals for medical interpretation.


πŸ› οΈ Technical Specifications

Signal Processing

  • Sampling Rate: 360 Hz
  • Buffer Size: 1000 samples (~2.78 seconds)
  • Peak Detection: Pan-Tompkins algorithm with fallback methods
  • Filtering: Real-time bandpass and noise reduction
  • Validation: Physiological heart rate limits (40-180 BPM)

AI Model

  • Architecture: 1D Convolutional Neural Network (CNN)
  • Input: 135-sample ECG windows (375ms), centered on detected R-peaks
  • Classes: 5 heartbeat categories (AAMI EC57 standard)
  • Training: In-browser training using the MIT-BIH Arrhythmia Database or your own datasets

πŸ§‘β€πŸ”¬ Custom AI Model Training with MIT-BIH Dataset

The default AI model is trained on the MIT-BIH Arrhythmia Database (Modern, 2023).

To retrain the model with your own data or variations:

  1. Download the dataset
    Get the MIT-BIH Arrhythmia Database (Modern, 2023) from Kaggle.

  2. Add the dataset to your project
    Place the downloaded files (e.g., .csv) into the public/data folder of your project.

  3. Retrain the model

    • Open the /train page in the app.
    • Start the training process and follow the on-screen instructions.
  4. Use your updated model

    • After training, the new model will be used for real-time AI beat classification.

Tip:
You can modify the model architecture or preprocessing steps in src/lib/modelTrainer.ts before retraining to experiment with different approaches.


Browser Compatibility

  • Recommended: Chrome, Edge
  • Required: Web Bluetooth API support

πŸ—οΈ Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ page.tsx              # Main application interface
β”‚   β”œβ”€β”€ train/page.tsx        # AI model training
β”‚   β”œβ”€β”€ docs/page.tsx         # User documentation
β”‚   └── layout.tsx            # App layout and navigation
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ EcgPanel.tsx          # Main ECG visualization & controls
β”‚   β”œβ”€β”€ SessionRecording.tsx  # Recording interface
β”‚   β”œβ”€β”€ SessionReport.tsx     # Analysis reports
β”‚   └── ModelInspector.tsx    # AI model inspection
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ panTompkinsDetector.ts # R-peak detection algorithm
β”‚   β”œβ”€β”€ bpmCalculator.ts      # Heart rate calculation
β”‚   β”œβ”€β”€ pqrstDetector.ts      # Wave component detection
β”‚   β”œβ”€β”€ hrvAnalysis.ts        # HRV calculations
β”‚   β”œβ”€β”€ ecgIntervals.ts       # Clinical interval measurement
β”‚   └── Modeltrainer.ts            # Neural network training
└── public/
    └── data                # ECG datasets for AI training

πŸš€ Deployment

Development

npm run dev

Production Build

npm run build
npm start

Hosting Platforms

  • GitHub Pages: Free hosting for public repos

🎯 Use Cases

For Healthcare Professionals

  • Research: Rapid prototyping of ECG analysis algorithms
  • Education: Teaching ECG interpretation and signal processing
  • Screening: Non-diagnostic monitoring and assessment tools

For Students & Researchers

  • Learning: Hands-on ECG signal processing experience
  • Development: Building custom analysis algorithms
  • Visualization: Understanding cardiac electrophysiology

For Developers

  • Customization: Extending features for specific use cases
  • API Development: Building ECG analysis services

⚠️ Important Disclaimers

Medical Disclaimer

This application is designed for educational, research, and development purposes only. It is not a medical device and should not be used for:

  • Medical diagnosis or treatment decisions
  • Emergency medical situations
  • Replacing professional medical advice
  • Clinical decision-making without physician oversight

Accuracy Notice

  • Results may vary depending on signal quality and device characteristics
  • Always consult qualified healthcare professionals for medical interpretation

πŸ™ Acknowledgements

Special thanks to Deepak Khatri and Krishnanshu Mittal for their continuous support, guidance, and valuable feedback throughout the development of this project. Your encouragement and insights have been instrumental in making this application possible.


🀝 Contributing

We welcome contributions to help improve this application and ensure it works accurately.


πŸ“„ License

This project is licensed under the MIT License - see LICENSE file for details.


πŸ”— Resources


πŸ› οΈ Credits & Tools Used

This project leverages the following open-source tools and libraries:

Special thanks to the authors and maintainers of these projects for enabling rapid development and beautiful UI/UX.


πŸ’‘ Support

For technical support, feature requests, or questions:

  • Open an issue on GitHub
  • Check the documentation at /docs
  • Contact the development team

Project developed by Ritika Mishra
LinkedIn | GitHub

About

ECG based heart analysis tool for everyone!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages