# phantomcoder9632/apneoa-event-prediction-using-ppg-signal architecture

> Architecture diagram of the GitHub repository phantomcoder9632/apneoa-event-prediction-using-ppg-signal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal
- Repository: https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal

## Overview

This repository contains scripts and saved models for PPG-based sleep-apnea forecasting and analysis. The intended task is to use a 30-second PPG window to predict apnea 5 seconds ahead; the available training and evaluation scripts also describe patient-level splits and five-fold validation. The tree does not contain the dataset or several scripts named in the README, so those broader pipeline stages cannot be mapped. The excerpts show data and model loading, but do not establish all artifact handoffs.

Main entry points: [`testing_final.py`](https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/testing_final.py) (Interactive Evaluation), [`prediction_window_plot.py`](https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/prediction_window_plot.py) (Prediction Examples), [`training.py`](https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/training.py) (Train Predictor), [`preapnea_vs_baseline.py`](https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/preapnea_vs_baseline.py) (Pre-Apnea Analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_forecast["Forecast Model"]
  node_trainer["Train Predictor<br/>[training.py]"]
  node_weights_pth["PyTorch Weights"]
end

subgraph group_evaluation["Evaluation"]
  node_tester["Interactive Evaluation<br/>[testing_final.py]"]
  node_keras_weights["Keras Weights"]
  node_window_plot["Prediction Examples"]
end

subgraph group_analysis["Signal Analysis"]
  node_comparison["Pre-Apnea Analysis"]
end

subgraph group_visuals["Result Visualization"]
  node_results_plots["Metric Plots"]
end

node_data["PPG Dataset"]

node_trainer -->|"loads"| node_data
node_tester -->|"loads"| node_data
node_tester -->|"loads"| node_weights_pth
node_window_plot -->|"loads"| node_data
node_window_plot -->|"loads"| node_keras_weights
node_comparison -->|"loads"| node_data

click node_trainer "https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/training.py"
click node_weights_pth "https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/my_final_apnea_predictor.pth"
click node_tester "https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/testing_final.py"
click node_keras_weights "https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/my_final_apnea_predictor.keras"
click node_window_plot "https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/prediction_window_plot.py"
click node_comparison "https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/preapnea_vs_baseline.py"
click node_results_plots "https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/visualization_plots.py"

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_trainer,node_weights_pth toneBlue
class node_tester,node_keras_weights,node_window_plot toneAmber
class node_comparison toneMint
class node_results_plots toneRose
class node_data toneIndigo
```

## Components

### Forecast Model

- [Train Predictor](https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/training.py): `training.py`
- [PyTorch Weights](https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/my_final_apnea_predictor.pth): `my_final_apnea_predictor.pth`

### Evaluation

- [Interactive Evaluation](https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/testing_final.py): `testing_final.py`
- [Keras Weights](https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/my_final_apnea_predictor.keras): `my_final_apnea_predictor.keras`
- [Prediction Examples](https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/prediction_window_plot.py): `prediction_window_plot.py`

### Signal Analysis

- [Pre-Apnea Analysis](https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/preapnea_vs_baseline.py): `preapnea_vs_baseline.py`

### Result Visualization

- [Metric Plots](https://github.com/phantomcoder9632/apneoa-event-prediction-using-ppg-signal/blob/main/visualization_plots.py): `visualization_plots.py`

### Other components

- **PPG Dataset**

## Connections

- Train Predictor → PPG Dataset: loads (evidence: `training.py`)
- Interactive Evaluation → PPG Dataset: loads (evidence: `testing_final.py`)
- Interactive Evaluation → PyTorch Weights: loads (evidence: `testing_final.py`)
- Prediction Examples → PPG Dataset: loads (evidence: `prediction_window_plot.py`)
- Prediction Examples → Keras Weights: loads (evidence: `prediction_window_plot.py`)
- Pre-Apnea Analysis → PPG Dataset: loads (evidence: `preapnea_vs_baseline.py`)
