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.
- 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.
- Modern web browser with Bluetooth support (Chrome, Edge)
- Compatible Npg Lite device with Bluetooth connectivity
- Node.js 18+ (for development)
-
Clone and setup:
git clone https://github.com/yourusername/Rpeak.git cd your_foldername npm install
-
Start development server:
npm run dev
- 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
- Real-time waveform display of your ECG signal
- Automatic heart rate calculation from detected beats
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 |
- Click π Session to start recording
- Monitor for desired duration (5-10 minutes recommended)
- Stop recording to generate comprehensive analysis report
- Normal: 60-100 BPM (resting)
- Bradycardia: < 60 BPM (may be normal for athletes)
- Tachycardia: > 100 BPM (exercise, stress, or medical condition)
- RMSSD: Higher values (>30ms) indicate better cardiovascular fitness
- Stress Level: Derived from multiple HRV parameters
- LF/HF Ratio: Balance between sympathetic/parasympathetic nervous systems
- PR Interval: 120-200ms (normal conduction)
- QRS Duration: 80-120ms (ventricular conduction)
- QT Interval: Rate-corrected using Bazett's formula
- 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
- 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)
- 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
The default AI model is trained on the MIT-BIH Arrhythmia Database (Modern, 2023).
To retrain the model with your own data or variations:
-
Download the dataset
Get the MIT-BIH Arrhythmia Database (Modern, 2023) from Kaggle. -
Add the dataset to your project
Place the downloaded files (e.g.,.csv
) into thepublic/data
folder of your project. -
Retrain the model
- Open the
/train
page in the app. - Start the training process and follow the on-screen instructions.
- Open the
-
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.
- Recommended: Chrome, Edge
- Required: Web Bluetooth API support
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
npm run dev
npm run build
npm start
- GitHub Pages: Free hosting for public repos
- Research: Rapid prototyping of ECG analysis algorithms
- Education: Teaching ECG interpretation and signal processing
- Screening: Non-diagnostic monitoring and assessment tools
- Learning: Hands-on ECG signal processing experience
- Development: Building custom analysis algorithms
- Visualization: Understanding cardiac electrophysiology
- Customization: Extending features for specific use cases
- API Development: Building ECG analysis services
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
- Results may vary depending on signal quality and device characteristics
- Always consult qualified healthcare professionals for medical interpretation
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.
We welcome contributions to help improve this application and ensure it works accurately.
This project is licensed under the MIT License - see LICENSE file for details.
- Documentation: Application User Guide
- ECG Fundamentals: Understanding ECG
- TensorFlow.js: Machine Learning in Browsers
- Web Bluetooth: Connecting Devices
This project leverages the following open-source tools and libraries:
- Next.js β React framework for web apps
- TensorFlow.js β Machine learning in the browser
- Lucide Icons β Beautiful open-source icon library
- WebglPlot β High-performance waveform visualization
- Tailwind CSS β Utility-first CSS framework
- LucideCards β Card-style UI components (if used)
- React β UI library
- TypeScript β Typed JavaScript
Special thanks to the authors and maintainers of these projects for enabling rapid development and beautiful UI/UX.
For technical support, feature requests, or questions:
- Open an issue on GitHub
- Check the documentation at
/docs
- Contact the development team