Skip to content

sthaarwin/pulseAI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cuffless Blood Pressure Estimation

A machine learning project for estimating blood pressure from PPG (Photoplethysmography) and ECG (Electrocardiography) signals using deep learning techniques. This project implements CNN-LSTM architecture with attention mechanisms for non-invasive blood pressure prediction.

✨ Key Features

  • Real-time BP monitoring with web interface
  • Dual signal quality validation (PPG + ECG)
  • Intelligent prediction gating (requires ≥60% signal quality)
  • Independent signal normalization for accurate predictions
  • WebSocket-based streaming for real-time data
  • Raw signal filtering in Python for flexibility

🎯 Quick Start - Real-time BP Monitoring

Hardware Setup

Required:

  • ESP32 development board
  • MAX30102 PPG sensor (pulse oximeter)
  • AD8232 ECG sensor module
  • 3x disposable ECG electrodes

See HARDWARE_SETUP.md for complete wiring guide with diagrams.

Software Setup

Option 1: Automated Script (Recommended)

# Start everything with one command
./bash/start-realtime-bp.sh

# Or with custom serial port
./bash/start-realtime-bp.sh /dev/ttyACM0

Then open http://localhost:3000 in your browser.

Option 2: Manual Setup

Hardware Setup:

  1. ESP32 + MAX30102 - See esp32/README.md
  2. Upload the filtered PPG sketch to ESP32
  3. Connect MAX30102 sensor and place finger on it

Software:

# 1. Start the bridge server (connects ESP32 → Model → Frontend)
python bridge_server.py --serial-port /dev/ttyUSB0

# 2. In another terminal, start frontend
cd frontend
pnpm dev

# 3. Open browser
open http://localhost:3000

See REALTIME_SETUP.md for complete setup guide.


🚀 Development Setup

Backend (WebSocket Server)

For development and testing, you can use the mock ESP32 server:

# Install Python dependencies
pip install -r requirements.txt

# Start the mock ESP32 WebSocket server
python mock_esp32_server.py

The server will start on http://localhost:8080 and provide:

  • WebSocket endpoint at ws://localhost:8080/signals
  • Web interface at http://localhost:8080
  • Real-time PPG and ECG signal simulation

Frontend (Next.js)

cd frontend
npm install
# or
pnpm install

# Start the development server
npm run dev
# or
pnpm dev

The frontend will be available at http://localhost:3000.

📡 WebSocket Communication

The system uses WebSocket connections to stream real-time physiological signals:

Signal Data Format

{
  "type": "signal_data",
  "payload": {
    "timestamp": 1640995200000,
    "ppg_value": 0.5,
    "ecg_value": 0.2,
    "sample_rate": 250,
    "quality": 0.85,
    "heart_rate": 72
  }
}

Note: quality ranges from 0.0 to 1.0 and represents combined PPG+ECG signal quality. Predictions require quality ≥ 0.6.

BP Prediction Format

{
  "type": "bp_prediction",
  "payload": {
    "sbp": 118.3,
    "dbp": 78.2,
    "timestamp": 1640995200000,
    "confidence": 0.87,
    "prediction_count": 42,
    "error": "Low signal quality - check sensor connections" // Optional, if quality too low
  }
}

Control Commands

{
  "type": "control",
  "command": "start_acquisition" | "stop_acquisition" | "calibrate"
}

🔧 Troubleshooting

If you see WebSocket errors in the console:

  1. Check if the backend server is running: Make sure python mock_esp32_server.py is running
  2. Verify the connection URL: The frontend should connect to ws://localhost:8080/signals
  3. Check network connectivity: Ensure no firewall is blocking the connection
  4. Review browser console: Look for detailed error messages with troubleshooting tips

📁 Data Directories

The project uses the following data structure:

  • data/raw/ - Raw dataset files downloaded from PulseDB
  • data/processed/ - Preprocessed .mat files ready for training
  • checkpoints/ - Model checkpoints and saved weights

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 43.9%
  • TypeScript 39.9%
  • Jupyter Notebook 13.7%
  • Shell 1.2%
  • CSS 1.0%
  • C++ 0.3%