# danielzamorap/el4203-proyecto-progra-avanzada-eeg architecture

> Architecture diagram of the GitHub repository danielzamorap/el4203-proyecto-progra-avanzada-eeg, 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/danielzamorap/el4203-proyecto-progra-avanzada-eeg
- Repository: https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg

## Overview

This repository is a research-oriented EEG seizure-window classifier. Its workflow is to prepare patient-specific windows from CHB-MIT EDF records using seizure annotations, save channel-power features and labels as NPZ files, then load five patients for training and hold out one patient for evaluation. The two models produce seizure scores that metrics summarize and the MLP uses to prioritize review windows; the script also saves an ROC plot. The graph reflects the shown entry points and module calls; it does not assume unsampled notebook or raw-data details.

Main entry points: [`src/main.py`](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/main.py) (Train-test runner), [`src/metricas.py`](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/metricas.py) (Model metrics), [`src/preparar_datos.py`](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/preparar_datos.py) (Patient preparation), [`src/datos.py`](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/datos.py) (Patient datasets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_preparation["Data preparation"]
  node_annotations["Seizure annotations<br/>[anotaciones.py]"]
  node_preparer["Patient preparation<br/>[preparar_datos.py]"]
end

subgraph group_dataset["Dataset handling"]
  node_windowing["EEG window features<br/>[datos.py]"]
  node_dataset["Patient datasets<br/>[datos.py]"]
  node_npz[("Processed NPZ files")]
end

subgraph group_inference["Modeling and evaluation"]
  node_runner["Train-test runner<br/>[main.py]"]
  node_threshold["Threshold model<br/>[modelos.py]"]
  node_mlp["Neural network<br/>[modelos.py]"]
  node_sorting["Score sorting<br/>[ordenamiento.py]"]
  node_metrics["Model metrics<br/>[metricas.py]"]
end

subgraph group_results["Review outputs"]
  node_review["Prioritized windows<br/>[main.py]"]
  node_roc["ROC plot"]
end

node_operator(("Analyst"))
node_edf["CHB-MIT EDF"]

node_operator -->|"runs"| node_runner
node_operator -->|"prepares data"| node_preparer
node_edf -->|"supplies records"| node_preparer
node_preparer -->|"reads annotations"| node_annotations
node_preparer -->|"adds records"| node_windowing
node_windowing -->|"saves features"| node_npz
node_dataset -->|"loads patients"| node_npz
node_runner -->|"loads patients"| node_dataset
node_runner -->|"trains and scores"| node_threshold
node_runner -->|"trains and scores"| node_mlp
node_runner -->|"evaluates models"| node_metrics
node_metrics -->|"reads labels and features"| node_dataset
node_metrics -->|"requests predictions"| node_threshold
node_metrics -->|"requests scores"| node_mlp
node_mlp -->|"orders scores"| node_sorting
node_runner -->|"gets window origins"| node_dataset
node_runner -->|"prioritizes windows"| node_mlp
node_runner -->|"prints top windows"| node_review
node_runner -->|"saves ROC plot"| node_roc

click node_annotations "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/anotaciones.py"
click node_preparer "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/preparar_datos.py"
click node_windowing "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/datos.py"
click node_dataset "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/datos.py"
click node_npz "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/tree/main/data/processed"
click node_runner "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/main.py"
click node_threshold "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/modelos.py"
click node_mlp "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/modelos.py"
click node_sorting "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/ordenamiento.py"
click node_metrics "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/metricas.py"
click node_review "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/main.py"
click node_roc "https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/tree/main/resultados"

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_annotations,node_preparer toneBlue
class node_windowing,node_dataset,node_npz toneAmber
class node_runner,node_threshold,node_mlp,node_sorting,node_metrics toneMint
class node_review,node_roc toneRose
class node_operator,node_edf toneIndigo
```

## Components

### Data preparation

- [Seizure annotations](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/anotaciones.py): `src/anotaciones.py`
- [Patient preparation](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/preparar_datos.py): `src/preparar_datos.py`

### Dataset handling

- [EEG window features](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/datos.py): `src/datos.py`
- [Patient datasets](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/datos.py): `src/datos.py`
- [Processed NPZ files](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/tree/main/data/processed): `data/processed`

### Modeling and evaluation

- [Train-test runner](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/main.py): `src/main.py`
- [Threshold model](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/modelos.py): `src/modelos.py`
- [Neural network](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/modelos.py): `src/modelos.py`
- [Score sorting](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/ordenamiento.py): `src/ordenamiento.py`
- [Model metrics](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/metricas.py): `src/metricas.py`

### Review outputs

- [Prioritized windows](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/blob/main/src/main.py): `src/main.py`
- [ROC plot](https://github.com/danielzamorap/el4203-proyecto-progra-avanzada-eeg/tree/main/resultados): `resultados`

### Other components

- **Analyst**
- **CHB-MIT EDF**

## Connections

- Analyst → Train-test runner: runs (evidence: `README.md`)
- Analyst → Patient preparation: prepares data (evidence: `src/preparar_datos.py`)
- CHB-MIT EDF → Patient preparation: supplies records (evidence: `README.md`)
- Patient preparation → Seizure annotations: reads annotations (evidence: `src/preparar_datos.py`)
- Patient preparation → EEG window features: adds records (evidence: `src/preparar_datos.py`)
- EEG window features → Processed NPZ files: saves features (evidence: `src/datos.py`)
- Patient datasets → Processed NPZ files: loads patients (evidence: `src/datos.py`)
- Train-test runner → Patient datasets: loads patients (evidence: `src/main.py`)
- Train-test runner → Threshold model: trains and scores (evidence: `src/main.py`)
- Train-test runner → Neural network: trains and scores (evidence: `src/main.py`)
- Train-test runner → Model metrics: evaluates models (evidence: `src/main.py`)
- Model metrics → Patient datasets: reads labels and features (evidence: `src/metricas.py`)
- Model metrics → Threshold model: requests predictions (evidence: `src/metricas.py`)
- Model metrics → Neural network: requests scores (evidence: `src/metricas.py`)
- Neural network → Score sorting: orders scores (evidence: `src/modelos.py`)
- Train-test runner → Patient datasets: gets window origins (evidence: `src/main.py`)
- Train-test runner → Neural network: prioritizes windows (evidence: `src/main.py`)
- Train-test runner → Prioritized windows: prints top windows (evidence: `src/main.py`)
- Train-test runner → ROC plot: saves ROC plot (evidence: `src/main.py`)
