# vthuong99/eeg_ad_detection architecture

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

- Interactive diagram: https://gitdiagram.com/vthuong99/eeg_ad_detection
- Repository: https://github.com/vthuong99/eeg_ad_detection

## Overview

##### Major components
- Data Input & Preprocessing Layer – Represented by the files in src/data_processing. This includes modules for loading the EEG datasets (load_data.py) and processing the raw data (bandpower.py, feature_extraction.py).
- Model Development Layer – Located in src/model. This layer contains several machine learning/deep learning models including CNN_TransSeizNet.py, DICE_Net.py, cnnNet.py, dl_model.py, and additional helper components like layer.py and transformer_model.py.
- Model Evaluation & Validation Layer – Found in src/validation. This includes the cross_validation.py script which implements the LOSO strategy and metrics.py for performance evaluation.
- Experimentation & Analysis – Notebooks in src/notebooks (e.g., experiment.ipynb) for exploratory work, prototyping, or visual analysis of model performance.
- Results Output – The results folder, which stores evaluation outputs (e.g., dl_model_eval.txt and ml_model_eval.txt) that document model performance.
- Project Configuration – Files like config.py and requirements.txt provide configuration settings and dependency management.

##### Relationships and interactions
- Data flows from the Data Input (EEG dataset) to the Preprocessing modules, which then produce features via feature extraction methods.
- These features feed into the Model Development Layer – where different architectures are defined to train on the preprocessed data.
- After training, the evaluation process is handled by the Validation layer (LOSO cross-validation using cross_validation.py and metrics.py) and the results are recorded in the Results folder.
- The Notebooks act as an orchestration/testing environment that ties these components together for experimentation.
- Configuration files (config.py) guide settings for the pipeline and make it reproducible.

##### Architectural patterns and design principles
- Modular Pipeline: Each stage (data processing, model building, validation) is clearly separated, making it easy to plug in different modules or update specific stages.
- Reproducibility: The use of configuration files (config.py) and well-documented requirements encourages consistency across experiments.
- Experimentation/Exploratory Analysis: The inclusion of notebooks highlights the iterative nature typical in ML projects.
- Evaluation via LOSO Cross-Validation: A systematic cross-validation strategy is integral for assessing model robustness.

##### Associate technologies and frameworks
- Python is the primary language, with libraries probably used for numerical computing and ML (e.g., NumPy, SciPy, perhaps PyTorch or TensorFlow, though not explicitly mentioned).
- Data processing techniques specific to EEG signal analysis (band power computation) are essential.
- A clear ML evaluation pipeline using LOSO cross-validation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Input & Preprocessing Layer
    subgraph "Data Input & Preprocessing"
        A1["load_data.py"]:::data
        A2["bandpower.py"]:::data
        A3["feature_extraction.py"]:::data
    end

    %% Dummy node for aggregated output from preprocessing
    FE["Extracted Features"]:::feature

    %% Model Development Layer
    subgraph "Model Development"
        B1["CNN_TransSeizNet.py"]:::model
        B2["DICE_Net.py"]:::model
        B3["cnnNet.py"]:::model
        B4["dl_model.py"]:::model
        B5["layer.py"]:::model
        B6["transformer_model.py"]:::model
    end

    %% Model Evaluation & Validation Layer
    subgraph "Model Evaluation & Validation"
        C1["cross_validation.py(LOSO)"]:::validation
        C2["metrics.py"]:::validation
    end

    %% Results Output
    subgraph "Results Output"
        E1["dl_model_eval.txt"]:::results
        E2["ml_model_eval.txt"]:::results
    end

    %% Project Configuration
    subgraph "Project Configuration"
        F1["config.py"]:::config
        F2["requirements.txt"]:::config
    end

    %% Experimentation & Analysis
    subgraph "Experimentation & Analysis"
        D1["experiment.ipynb"]:::notebook
    end

    %% Data Flow Arrows
    A3 -->|"extracts_features"| FE
    FE -->|"to_model"| B1
    B4 -->|"model_predictions"| C1
    C1 -->|"evaluates"| E1

    %% Configuration influence
    F1 ---|"configures"| A1
    F1 ---|"configures"| B1
    F1 ---|"configures"| C1

    %% Experimentation Orchestration Connections (dotted lines)
    D1 ---|"orchestrates"| A1
    D1 ---|"orchestrates"| B1
    D1 ---|"orchestrates"| C1
    D1 ---|"orchestrates"| E1
    D1 ---|"orchestrates"| F1

    %% Click Events for Data Input & Preprocessing Layer
    click A1 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/data_processing/load_data.py"
    click A2 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/data_processing/bandpower.py"
    click A3 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/data_processing/feature_extraction.py"

    %% Click Events for Model Development Layer
    click B1 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/model/CNN_TransSeizNet.py"
    click B2 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/model/DICE_Net.py"
    click B3 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/model/cnnNet.py"
    click B4 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/model/dl_model.py"
    click B5 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/model/layer.py"
    click B6 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/model/transformer_model.py"

    %% Click Events for Model Evaluation & Validation Layer
    click C1 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/validation/cross_validation.py"
    click C2 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/validation/metrics.py"

    %% Click Event for Experimentation & Analysis
    click D1 "https://github.com/vthuong99/eeg_ad_detection/blob/main/src/notebooks/experiment.ipynb"

    %% Click Events for Results Output
    click E1 "https://github.com/vthuong99/eeg_ad_detection/blob/main/results/dl_model_eval.txt"
    click E2 "https://github.com/vthuong99/eeg_ad_detection/blob/main/results/ml_model_eval.txt"

    %% Click Events for Project Configuration
    click F1 "https://github.com/vthuong99/eeg_ad_detection/blob/main/config.py"
    click F2 "https://github.com/vthuong99/eeg_ad_detection/blob/main/requirements.txt"

    %% Styles
    classDef data fill:#FFDDC1,stroke:#333,stroke-width:2px;
    classDef feature fill:#FFF2CC,stroke:#333,stroke-width:2px;
    classDef model fill:#C6E2FF,stroke:#333,stroke-width:2px;
    classDef validation fill:#CCE5CC,stroke:#333,stroke-width:2px;
    classDef results fill:#E0BBE4,stroke:#333,stroke-width:2px;
    classDef config fill:#F0E68C,stroke:#333,stroke-width:2px;
    classDef notebook fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
