# rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection architecture

> Architecture diagram of the GitHub repository rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection
- Repository: https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection

## Overview

Heart Disease Prediction is a Streamlit application that accepts an ECG image and displays a predicted class. Its main flow reads the upload, divides it into leads, extracts and combines scaled signals, then analyzes PQRST waves, applies PCA, and predicts a diagnosis. The UI also displays intermediate images and results. The edges follow calls visible in the app and ECG excerpts; the README documents the Streamlit launch command but no additional capabilities.

Main entry points: [`final_app.py`](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/final_app.py) (Streamlit workflow), [`Ecg.py`](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py) (Signal extraction), [`Scaled_1DLead_1.csv`](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Scaled_1DLead_1.csv) (Lead CSV files), [`pca-final.pkl`](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/pca-final.pkl) (PCA model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["Streamlit workflow<br/>[final_app.py]"]
end

subgraph group_signal["Signal processing"]
  node_image["Image reader<br/>[Ecg.py]"]
  node_leads["Lead segmentation<br/>[Ecg.py]"]
  node_preprocess["Lead preprocessing<br/>[Ecg.py]"]
  node_extract["Signal extraction<br/>[Ecg.py]"]
  node_csv[("Lead CSV files")]
  node_combine["Signal combination<br/>[Ecg.py]"]
end

subgraph group_diagnosis["Analysis and prediction"]
  node_wave["PQRST analysis<br/>[Ecg.py]"]
  node_pca["PCA reduction<br/>[Ecg.py]"]
  node_pca_model[("PCA model<br/>[pca-final.pkl]")]
  node_classifier["ECG classifier<br/>[Ecg.py]"]
  node_classifier_model[("Classifier model<br/>[best.pkl]")]
end

node_user(("ECG uploader"))

node_user -->|"uploads image"| node_app
node_app -->|"reads upload"| node_image
node_app -->|"segments image"| node_leads
node_app -->|"preprocesses leads"| node_preprocess
node_app -->|"extracts signals"| node_extract
node_extract -->|"writes signals"| node_csv
node_app -->|"combines signals"| node_combine
node_combine -->|"reads signals"| node_csv
node_app -->|"analyzes waves"| node_wave
node_app -->|"reduces signals"| node_pca
node_pca -->|"loads model"| node_pca_model
node_app -->|"predicts class"| node_classifier
node_classifier -->|"loads model"| node_classifier_model

click node_app "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/final_app.py"
click node_image "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py"
click node_leads "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py"
click node_preprocess "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py"
click node_extract "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py"
click node_csv "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Scaled_1DLead_1.csv"
click node_combine "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py"
click node_wave "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py"
click node_pca "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py"
click node_pca_model "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/pca-final.pkl"
click node_classifier "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py"
click node_classifier_model "https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/best.pkl"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app toneBlue
class node_image,node_leads,node_preprocess,node_extract,node_csv,node_combine toneAmber
class node_wave,node_pca,node_pca_model,node_classifier,node_classifier_model toneMint
class node_user toneIndigo
```

## Components

### User interface

- [Streamlit workflow](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/final_app.py): `final_app.py`

### Signal processing

- [Image reader](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py): `Ecg.py`
- [Lead segmentation](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py): `Ecg.py`
- [Lead preprocessing](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py): `Ecg.py`
- [Signal extraction](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py): `Ecg.py`
- [Lead CSV files](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Scaled_1DLead_1.csv): `Scaled_1DLead_1.csv`
- [Signal combination](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py): `Ecg.py`

### Analysis and prediction

- [PQRST analysis](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py): `Ecg.py`
- [PCA reduction](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py): `Ecg.py`
- [PCA model](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/pca-final.pkl): `pca-final.pkl`
- [ECG classifier](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/Ecg.py): `Ecg.py`
- [Classifier model](https://github.com/rbnarule3007/combining-heart-imaging-with-advanced-ai-for-better-heart-disease-detection/blob/master/best.pkl): `best.pkl`

### Other components

- **ECG uploader**

## Connections

- ECG uploader → Streamlit workflow: uploads image (evidence: `final_app.py`)
- Streamlit workflow → Image reader: reads upload (evidence: `final_app.py`)
- Streamlit workflow → Lead segmentation: segments image (evidence: `final_app.py`)
- Streamlit workflow → Lead preprocessing: preprocesses leads (evidence: `final_app.py`)
- Streamlit workflow → Signal extraction: extracts signals (evidence: `final_app.py`)
- Signal extraction → Lead CSV files: writes signals (evidence: `Ecg.py`)
- Streamlit workflow → Signal combination: combines signals (evidence: `final_app.py`)
- Signal combination → Lead CSV files: reads signals (evidence: `Ecg.py`)
- Streamlit workflow → PQRST analysis: analyzes waves (evidence: `final_app.py`)
- Streamlit workflow → PCA reduction: reduces signals (evidence: `final_app.py`)
- PCA reduction → PCA model: loads model (evidence: `Ecg.py`)
- Streamlit workflow → ECG classifier: predicts class (evidence: `final_app.py`)
- ECG classifier → Classifier model: loads model (evidence: `Ecg.py`)
