# benkeel/lymph_node_classification_miua architecture

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

- Interactive diagram: https://gitdiagram.com/benkeel/lymph_node_classification_miua
- Repository: https://github.com/benkeel/lymph_node_classification_miua

## Overview

##### Project type and purpose
- This is a research-style machine-learning pipeline for “interpretable prediction of lymph node metastasis in rectal cancer MRI” using a variational autoencoder (VAE) plus a multilayer perceptron (MLP) classifier.
- The codebase includes data preprocessing notebooks, model definitions, training/evaluation utilities, hyperparameter-sweep scripts, and a results directory.

##### File structure
- Top-level folders:
- Data_Preprocessing – Jupyter notebooks for exploratory data inspection, image extraction from raw MRI, and dataset preprocessing.
- VAE-MLP – the core modeling package, split into:
– models: VAE_2D_model.py and MLP_model.py
– utils: dataset loaders, loss functions, training/test routines, helper code
– scripts: a set of .ipynb notebooks for cross-validation, hyperparameter sweeps, Grad-CAM, latent-space analyses, ablation studies, etc.
- Results – holds configuration files, training logs, model outputs, plots, and error analyses for each experimental setup (CNN, VAE, VAE-MLP, cross-validation).
- requirements.txt – defines dependencies (PyTorch, scikit-learn, matplotlib, etc.).

##### README for additional insights
- The README confirms the pipeline stages (preprocessing → model training → evaluation) and lists the experiments and outputs under Results.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Stores
    RawData["Raw MRI DICOMs"]:::storage
    PreprocessedDS["Preprocessed Dataset"]:::storage

    %% Data Preprocessing Notebooks
    Inspect["/ Data Inspect Notebook /"]:::notebook
    click Inspect "https://github.com/benkeel/lymph_node_classification_miua/blob/main/Data_Preprocessing/Data_Inspect.ipynb"
    Extraction["/ Image Extraction Notebook /"]:::notebook
    click Extraction "https://github.com/benkeel/lymph_node_classification_miua/blob/main/Data_Preprocessing/Image_Data_Extraction.ipynb"
    PreprocessNB["/ Preprocess Dataset Notebook /"]:::notebook
    click PreprocessNB "https://github.com/benkeel/lymph_node_classification_miua/blob/main/Data_Preprocessing/Preprocess_Dataset.ipynb"
    DataPreMod["Data Preprocessing Module"]:::code
    click DataPreMod "https://github.com/benkeel/lymph_node_classification_miua/tree/main/Data_Preprocessing/"

    %% Modeling Package
    subgraph "Modeling Package (VAE-MLP)"
        direction TB
        DatasetLoader["Dataset Loader"]:::code
        click DatasetLoader "https://github.com/benkeel/lymph_node_classification_miua/blob/main/VAE-MLP/utils/datasets.py"
        VAEModel["VAE Encoder/Decoder"]:::code
        click VAEModel "https://github.com/benkeel/lymph_node_classification_miua/blob/main/VAE-MLP/models/VAE_2D_model.py"
        MLPModel["MLP Classifier"]:::code
        click MLPModel "https://github.com/benkeel/lymph_node_classification_miua/blob/main/VAE-MLP/models/MLP_model.py"
        LossFuncs["Loss Functions"]:::code
        click LossFuncs "https://github.com/benkeel/lymph_node_classification_miua/blob/main/VAE-MLP/utils/loss_functions.py"
        TrainEval["Training & Eval Routines"]:::code
        click TrainEval "https://github.com/benkeel/lymph_node_classification_miua/blob/main/VAE-MLP/utils/train_and_test_functions.py"
        Utils["Utility Helpers"]:::code
        click Utils "https://github.com/benkeel/lymph_node_classification_miua/blob/main/VAE-MLP/utils/utility_code.py"
    end

    %% Experiment Orchestration
    Scripts["Experiment Scripts"]:::code
    click Scripts "https://github.com/benkeel/lymph_node_classification_miua/tree/main/VAE-MLP/scripts/"

    %% Results Repository
    Results["Results Repository"]:::storage
    click Results "https://github.com/benkeel/lymph_node_classification_miua/tree/main/Results/"
    CNNcfg["CNN config.txt"]:::code
    click CNNcfg "https://github.com/benkeel/lymph_node_classification_miua/blob/main/Results/CNN/config.txt"
    VAEcfg["VAE config.txt"]:::code
    click VAEcfg "https://github.com/benkeel/lymph_node_classification_miua/blob/main/Results/VAE/config.txt"
    VAEMLPcfg["VAE-MLP config.txt"]:::code
    click VAEMLPcfg "https://github.com/benkeel/lymph_node_classification_miua/blob/main/Results/VAE-MLP/config.txt"
    CVcfg["VAE-MLP Cross-Val results.txt"]:::code
    click CVcfg "https://github.com/benkeel/lymph_node_classification_miua/blob/main/Results/VAE-MLP-Cross-Val/results.txt"

    %% Environment
    Requirements["requirements.txt"]:::code
    click Requirements "https://github.com/benkeel/lymph_node_classification_miua/blob/main/requirements.txt"
    Readme["README.md"]:::code
    click Readme "https://github.com/benkeel/lymph_node_classification_miua/blob/main/README.md"

    %% Connections: Preprocessing
    RawData --> Inspect --> Extraction --> PreprocessNB --> DataPreMod --> PreprocessedDS

    %% Connections: Modeling
    PreprocessedDS --> DatasetLoader --> VAEModel --> MLPModel --> TrainEval --> Results

    LossFuncs --> TrainEval
    Utils --> TrainEval

    %% Connections: Orchestration
    Scripts --> DatasetLoader
    Scripts --> VAEModel
    Scripts --> MLPModel
    Scripts --> TrainEval
    Scripts --> Results

    %% Results details
    Results --> CNNcfg
    Results --> VAEcfg
    Results --> VAEMLPcfg
    Results --> CVcfg

    %% Docs and Env
    Requirements -->|Defines environment| Scripts
    Requirements -->|Defines environment| DataPreMod
    Requirements -->|Defines environment| TrainEval
    Readme -->|Project overview| Scripts
    Readme -->|Project overview| DataPreMod

    classDef code fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef storage fill:#90EE90,stroke:#000,stroke-width:1px
    classDef notebook fill:#FFA500,stroke:#000,stroke-width:1px
```
