Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ECG-Free Cardiac Timing Detection

Robust Multi-Proxy EchoWave (RMEW) — An ECG-free method for detecting End-Diastolic (ED) and End-Systolic (ES) frames in echocardiography videos.


Author

Nikhileswara Rao Sulake
RGUKT Nuzvid, India


Overview

This repository implements an automated method for cardiac timing detection in echocardiography without requiring ECG synchronization. The approach uses multiple image-based proxies (intensity, area, optical flow) combined with adaptive filtering to robustly identify ED and ES frames.

Key Features

  • ECG-free: No external synchronization required
  • Multi-proxy fusion: Combines intensity, area, flow, and edge signals
  • Adaptive processing: Automatically selects optimal strategy based on video characteristics
  • Robust: Handles varying image quality and frame rates

Results

Dataset N ED Mean ED Median ES Mean ES Median ED (ms) ES (ms)
EchoNet-Dynamic
CAMUS

Results will be populated after running the evaluation pipeline on your local setup.


Installation

git clone https://github.com/yourusername/ecg-free-cardiac-timing.git
cd ecg-free-cardiac-timing
pip install -r requirements.txt

Requirements

  • Python 3.8+
  • NumPy, SciPy, OpenCV, Pandas, Matplotlib
  • nibabel (for CAMUS dataset)
  • tqdm (for progress bars)

Dataset Setup

EchoNet-Dynamic

  1. Request access and download from https://echonet.github.io/dynamic/
  2. Extract to get the following structure:
EchoNet-Dynamic/
├── FileList.csv          # Video metadata (10,030 entries)
├── VolumeTracings.csv    # Ground truth tracings
└── Videos/
    ├── 0X100009310A3BD7FC.avi
    ├── 0X1002E8FBACD08477.avi
    └── ... (10,030 .avi files, 112x112 resolution)
  1. Move the folder to data/:
ecg-free-cardiac-timing/
└── data/
    └── EchoNet-Dynamic/

CAMUS

  1. Request access and download from https://www.creatis.insa-lyon.fr/Challenge/camus/
  2. Extract database_nifti.zip to get:
CAMUS/
└── database_nifti/
    ├── patient0001/
    │   ├── Info_2CH.cfg               # Ground truth (ED, ES frames)
    │   ├── Info_4CH.cfg
    │   ├── patient0001_2CH_half_sequence.nii.gz
    │   ├── patient0001_4CH_half_sequence.nii.gz
    │   └── ...
    ├── patient0002/
    └── ... (500 patients, 2 views each)
  1. Move the folder to data/:
ecg-free-cardiac-timing/
└── data/
    └── CAMUS/

Usage

Full Evaluation Pipeline

# Run evaluation on all available datasets
python main.py

# Run on specific dataset
python main.py --dataset echonet
python main.py --dataset camus

# Limit number of samples (for quick testing)
python main.py --max-videos 100

# Custom data directory
python main.py --data-dir /path/to/data

Single Video Inference

python inference.py path/to/video.avi

Python API

import numpy as np
from rmew import CardiacTimingDetector

# Load your video as (T, H, W) grayscale array
frames = np.random.rand(100, 112, 112) * 255  # Example

# Detect ED/ES frames
detector = CardiacTimingDetector(fps=50.0)
ed_frame, es_frame, info = detector.detect(frames)

print(f"ED: frame {ed_frame}")
print(f"ES: frame {es_frame}")
print(f"Method used: {info['method']}")

Output

Results are saved to results/run_YYYYMMDD_HHMMSS/:

results/run_20250115_143022/
├── summary_table.csv              # Combined metrics
├── echonet/
│   ├── echonet_results.csv        # Per-video predictions
│   ├── echonet_summary.txt        # Text summary
│   ├── scatter_comparison.png     # Pred vs GT plots
│   ├── error_histograms.png       # Error distributions
│   └── bland_altman.png           # Agreement analysis
└── camus/
    └── ... (same structure)

Project Structure

ecg-free-cardiac-timing/
├── README.md
├── requirements.txt
├── .gitignore
├── main.py                    # Full evaluation pipeline
├── inference.py               # Single video inference
├── rmew/
│   ├── __init__.py
│   ├── detector.py            # Core detection algorithm
│   ├── proxies.py             # Image-based signal extraction
│   └── filters.py             # Signal processing utilities
├── datasets/
│   ├── __init__.py
│   ├── echonet.py             # EchoNet-Dynamic loader
│   └── camus.py               # CAMUS loader
├── evaluation/
│   ├── __init__.py
│   ├── metrics.py             # Error metrics computation
│   └── visualize.py           # Plot generation
├── data/                      # Place datasets here
│   └── README.md
└── results/                   # Output directory
    └── README.md

Method Overview

The RMEW algorithm:

  1. ROI Extraction: Defines a circular region-of-interest centered on the image
  2. Proxy Signals: Extracts multiple time-series from the video:
    • Mean intensity (inverted for dark-blood imaging)
    • Segmented area via Otsu thresholding
    • Optical flow magnitude
    • Edge energy
  3. Signal Fusion: Selects best proxy based on SNR or fuses if quality is similar
  4. Adaptive Smoothing: Median + Savitzky-Golay filtering
  5. Peak Detection:
    • Short sequences: Global max (ED) / min after max (ES)
    • Longer sequences: Scipy peak detection with prominence constraints
  6. Validation: Ensures physiologically plausible systolic duration

Citation

If you use this code in your research, please cite:

@article{sulake2025ecgfree,
  title={ECG-Free Cardiac Timing Detection using Robust Multi-Proxy EchoWave},
  author={Sulake, Nikhileswara Rao},
  institution={RGUKT Nuzvid, India},
  year={2025}
}

License

MIT License

Copyright (c) 2025 Nikhileswara Rao Sulake

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages