# marcuschong2003/chbmit architecture

> Architecture diagram of the GitHub repository marcuschong2003/chbmit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marcuschong2003/chbmit
- Repository: https://github.com/marcuschong2003/chbmit

## Overview

This is a collection of research scripts for EEG seizure detection using CHB-MIT data, plus a separate Bonn-dataset SVM experiment. The main workflow parses seizure timings, filters and segments EEG into ictal/non-ictal CSV data, then trains and evaluates CNN classifiers. The repository also contains patient-wise CNN experiments and a Bonn feature-based SVM workflow. README documentation is minimal; the map reflects the sampled scripts and the file tree, not an integrated application.

Main entry points: [`attention_independent.py`](https://github.com/marcuschong2003/chbmit/blob/main/attention_independent.py) (Patient-wise attention CNN), [`generate_csv.py`](https://github.com/marcuschong2003/chbmit/blob/main/generate_csv.py) (CSV generator), [`data_model.py`](https://github.com/marcuschong2003/chbmit/blob/main/data_model.py) (Pooled CNN), [`attention_model.py`](https://github.com/marcuschong2003/chbmit/blob/main/attention_model.py) (Pooled attention CNN)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_preprocessing["EEG preprocessing"]
  node_csv_generator["CSV generator<br/>[generate_csv.py]"]
  node_labeled_csv["Ictal / non-ictal CSVs"]
end

subgraph group_chbmit_models["CHB-MIT models"]
  node_pooled_cnn["Pooled CNN<br/>[data_model.py]"]
  node_pooled_attention["Pooled attention CNN<br/>[attention_model.py]"]
  node_patient_cnn["Patient-wise CNN"]
  node_patient_attention["Patient-wise attention CNN"]
  node_model_results["Model evaluation"]
  node_saved_model["Saved attention model"]
end

subgraph group_bonn_experiment["Bonn experiment"]
  node_bonn_svm["Bonn SVM experiment<br/>[10-fold CV SVM.py]"]
  node_bonn_metrics["SVM metrics"]
end

node_researcher(("Researcher"))
node_chbmit_data["CHB-MIT EEG"]
node_patient_csvs["Patient CSVs"]
node_bonn_data["Bonn formatted CSV"]

node_researcher -->|"runs preprocessing"| node_csv_generator
node_chbmit_data -->|"reads EEG and summaries"| node_csv_generator
node_csv_generator -->|"writes segments"| node_labeled_csv
node_researcher -->|"runs training"| node_pooled_cnn
node_labeled_csv -->|"reads samples"| node_pooled_cnn
node_pooled_cnn -->|"reports evaluation"| node_model_results
node_researcher -->|"runs training"| node_pooled_attention
node_labeled_csv -->|"reads samples"| node_pooled_attention
node_pooled_attention -->|"reports evaluation"| node_model_results
node_researcher -->|"runs training"| node_patient_cnn
node_patient_csvs -->|"reads patient data"| node_patient_cnn
node_patient_cnn -->|"reports evaluation"| node_model_results
node_researcher -->|"runs training"| node_patient_attention
node_patient_csvs -->|"reads patient data"| node_patient_attention
node_patient_attention -->|"reports evaluation"| node_model_results
node_patient_attention -->|"saves model"| node_saved_model
node_researcher -->|"runs experiment"| node_bonn_svm
node_bonn_data -->|"reads samples"| node_bonn_svm
node_bonn_svm -->|"reports metrics"| node_bonn_metrics

click node_csv_generator "https://github.com/marcuschong2003/chbmit/blob/main/generate_csv.py"
click node_pooled_cnn "https://github.com/marcuschong2003/chbmit/blob/main/data_model.py"
click node_pooled_attention "https://github.com/marcuschong2003/chbmit/blob/main/attention_model.py"
click node_patient_cnn "https://github.com/marcuschong2003/chbmit/blob/main/patient_independent_model.py"
click node_patient_attention "https://github.com/marcuschong2003/chbmit/blob/main/attention_independent.py"
click node_bonn_svm "https://github.com/marcuschong2003/chbmit/blob/main/Conference/Bonn/10-fold%20CV%20SVM.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_csv_generator,node_labeled_csv toneBlue
class node_pooled_cnn,node_pooled_attention,node_patient_cnn,node_patient_attention,node_model_results,node_saved_model toneAmber
class node_bonn_svm,node_bonn_metrics toneMint
class node_researcher,node_chbmit_data,node_patient_csvs,node_bonn_data toneIndigo
```

## Components

### EEG preprocessing

- [CSV generator](https://github.com/marcuschong2003/chbmit/blob/main/generate_csv.py): `generate_csv.py`
- **Ictal / non-ictal CSVs**

### CHB-MIT models

- [Pooled CNN](https://github.com/marcuschong2003/chbmit/blob/main/data_model.py): `data_model.py`
- [Pooled attention CNN](https://github.com/marcuschong2003/chbmit/blob/main/attention_model.py): `attention_model.py`
- [Patient-wise CNN](https://github.com/marcuschong2003/chbmit/blob/main/patient_independent_model.py): `patient_independent_model.py`
- [Patient-wise attention CNN](https://github.com/marcuschong2003/chbmit/blob/main/attention_independent.py): `attention_independent.py`
- **Model evaluation**
- **Saved attention model**

### Bonn experiment

- [Bonn SVM experiment](https://github.com/marcuschong2003/chbmit/blob/main/Conference/Bonn/10-fold%20CV%20SVM.py): `Conference/Bonn/10-fold CV SVM.py`
- **SVM metrics**

### Other components

- **Researcher**
- **CHB-MIT EEG**
- **Patient CSVs**
- **Bonn formatted CSV**

## Connections

- Researcher → CSV generator: runs preprocessing
- CHB-MIT EEG → CSV generator: reads EEG and summaries
- CSV generator → Ictal / non-ictal CSVs: writes segments
- Researcher → Pooled CNN: runs training
- Ictal / non-ictal CSVs → Pooled CNN: reads samples
- Pooled CNN → Model evaluation: reports evaluation
- Researcher → Pooled attention CNN: runs training
- Ictal / non-ictal CSVs → Pooled attention CNN: reads samples
- Pooled attention CNN → Model evaluation: reports evaluation
- Researcher → Patient-wise CNN: runs training
- Patient CSVs → Patient-wise CNN: reads patient data
- Patient-wise CNN → Model evaluation: reports evaluation
- Researcher → Patient-wise attention CNN: runs training
- Patient CSVs → Patient-wise attention CNN: reads patient data
- Patient-wise attention CNN → Model evaluation: reports evaluation
- Patient-wise attention CNN → Saved attention model: saves model
- Researcher → Bonn SVM experiment: runs experiment
- Bonn formatted CSV → Bonn SVM experiment: reads samples
- Bonn SVM experiment → SVM metrics: reports metrics
