# arberetum/synthetic_eeg architecture

> Architecture diagram of the GitHub repository arberetum/synthetic_eeg, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arberetum/synthetic_eeg
- Repository: https://github.com/arberetum/synthetic_eeg

## Overview

##### Main Components of the System
- Data Input & Preprocessing Module:
- Raw EEG data source (from the Kaggle Seizure Prediction Challenge dataset) as the starting point.
- "preprocessing.ipynb" notebook that handles initial data cleaning and preparation.
- Feature Extraction and Selection:
- A component for "feature_extraction.py" and "feature_selection.py". These scripts are responsible for extracting relevant signal features from the preprocessed data.
- Generative Model Training:
- WGAN: Represented by the "WGAN.ipynb" notebook. Emphasize that this module uses an adversarial framework with a critic network and employs the earth-mover distance to ensure training stability.
- DDPM: Represent the DDPM-based components which are spread across "DDPM-Interictal.ipynb", "DDPM-Preictal.ipynb", and "DDPM-smaller_data.ipynb". These notebooks indicate iterative denoising refinement of synthetic signals.
- DCGAN if it is used as an auxiliary experiment.
- Evaluation & Analysis Module:
- "figures.ipynb", where loss curves and other performance metrics (plus qualitative visualizations like spectrogram comparisons) are generated.
- Reporting & Documentation:
- Incorporate the CS_534_Final_Report_Shoibolina_Aiden.pdf and README as final artifacts that summarize the methods, experiments, and outcomes.

##### Relationships and Interactions
- From raw EEG data to the Preprocessing Module.
- From preprocessing to Feature Extraction/Selection.
- From there, split the flow to the generative model training pipelines (WGAN and DDPM).
- After model training, the generated synthetic data flows to the Evaluation Module where classification models compare performance with real data.
- Demonstrate feedback loops if applicable (e.g., evaluation results influencing further model tuning).

##### Highlighting Architectural Patterns
- Data Pipeline: Emphasize the sequential processing of data from raw input to preprocessed signals, then through feature extraction and model training.
- Experimental Separation: Clearly distinguish between the different generative modeling approaches (WGAN vs. DDPM), showing that they operate in parallel to generate synthetic data.
- Modular Design: Indicate that each notebook/script serves as an independent module that can be modified or replaced without affecting the overall pipeline.

##### Essential Elements
- Clear labels for each module:
- “Raw EEG Data Input” → “Preprocessing (preprocessing.ipynb)” → “Feature Extraction/Selection (feature_extraction.py & feature_selection.py)” → Branches into “WGAN (WGAN.ipynb)” and “DDPM Models (DDPM-*.ipynb)” → “Evaluation (evaluation_models.py, figures.ipynb)” → “Reporting (PDF report & README)”
- Data/Artifact components (raw data, synthetic data, output figures)
- Processing modules (preprocessing, feature extraction, model training, evaluation)
- Documentation elements (final report, README)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Processing Block
    subgraph "Data Processing"
        A1["Raw EEG Data Input"]:::data
        A2["Preprocessing (preprocessing.ipynb)"]:::module
        A3["Feature Extraction (feature_extraction.py)"]:::module
        A4["Feature Selection (feature_selection.py)"]:::module
    end

    %% Generative Model Training Block
    subgraph "Generative Model Training"
        B1["WGAN (WGAN.ipynb)"]:::module
        subgraph "DDPM Models"
            B2["DDPM-Interictal (DDPM-Interictal.ipynb)"]:::module
            B3["DDPM-Preictal (DDPM-Preictal.ipynb)"]:::module
            B4["DDPM-smaller_data (DDPM-smaller_data.ipynb)"]:::module
        end
        B5["DCGAN (DCGAN.ipynb)"]:::module
    end

    %% Evaluation & Reporting Block
    subgraph "Evaluation & Reporting"
        E1["Evaluation (evaluation_models.py)"]:::module
        E2["Figures (figures.ipynb)"]:::module
        R1["Final Report (CS_534_Final_Report_Shoibolina_Aiden.pdf)"]:::doc
        R2["README (README.md)"]:::doc
    end

    %% Data Flow Connections
    A1 --> A2
    A2 --> A3
    A3 --> A4
    A4 --> B1
    A4 --> B2
    A4 --> B3
    A4 --> B4
    A4 --> B5
    B1 --> E1
    B2 --> E1
    B3 --> E1
    B4 --> E1
    B5 --> E1
    E1 --> E2
    E2 --> R1
    R1 --> R2

    %% Click Events
    click A2 "https://github.com/arberetum/synthetic_eeg/blob/main/preprocessing.ipynb"
    click A3 "https://github.com/arberetum/synthetic_eeg/blob/main/feature_extraction.py"
    click A4 "https://github.com/arberetum/synthetic_eeg/blob/main/feature_selection.py"
    click B1 "https://github.com/arberetum/synthetic_eeg/blob/main/WGAN.ipynb"
    click B2 "https://github.com/arberetum/synthetic_eeg/blob/main/DDPM-Interictal.ipynb"
    click B3 "https://github.com/arberetum/synthetic_eeg/blob/main/DDPM-Preictal.ipynb"
    click B4 "https://github.com/arberetum/synthetic_eeg/blob/main/DDPM-smaller_data.ipynb"
    click B5 "https://github.com/arberetum/synthetic_eeg/blob/main/DCGAN.ipynb"
    click E1 "https://github.com/arberetum/synthetic_eeg/blob/main/evaluation_models.py"
    click E2 "https://github.com/arberetum/synthetic_eeg/blob/main/figures.ipynb"
    click R1 "https://github.com/arberetum/synthetic_eeg/blob/main/CS_534_Final_Report_Shoibolina_Aiden.pdf"
    click R2 "https://github.com/arberetum/synthetic_eeg/blob/main/README.md"

    %% Styling Classes
    classDef data fill:#b3cde0,stroke:#03396c,stroke-width:2px;
    classDef module fill:#ccebc5,stroke:#006400,stroke-width:2px;
    classDef doc fill:#ffcc5c,stroke:#ee4035,stroke-width:2px;
```
