# adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation architecture

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

- Interactive diagram: https://gitdiagram.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation
- Repository: https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation

## Overview

##### Project type and purpose
- This is a research‐oriented, semi-supervised medical image segmentation codebase.
- It implements a two-stage pipeline:
a) Train a denoising autoencoder (DAE) to learn anatomical representations.
b) Train a mean-teacher segmentation model that leverages the DAE embeddings to estimate uncertainty and improve performance in a low-label regime.

##### File structure
- Top-level:
- LICENSE, README.md, requirement.txt
- code_DAE/ – DAE training and tests
- code_DAE_MT/ – Mean-teacher segmentation with DAE embeddings
- Inside each of code_DAE & code_DAE_MT:
- dataloaders/ – data loading logic (medical_dataloader.py + helper utils.py)
- networks/ – model definitions (vnet.py for 3D V-Net architecture)
- utils/ – losses.py, ramps.py, util.py
- train_*.py – training scripts
- test_*.py – evaluation scripts
- Requirements imply PyTorch, tensorboardX, numpy, skimage, etc.

##### README for additional insights
- Two phases of training are clearly described, with example CLI commands.
- References to datasets (LA 2018, FLARE 2021).

##### Additional notes
- External data sources as “outside” elements feeding into the Data Loader.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Data Sources
    subgraph "Data Sources" 
        direction TB
        LA["LA 2018 Dataset"]:::dataIO
        FLARE["FLARE 2021 Dataset"]:::dataIO
    end

    %% Phase 1: DAE Pretraining
    subgraph "Phase 1: DAE Pretraining"
        direction TB
        DL1["Data Loader Module"]:::dataIO
        DAE["DAE Encoder/Decoder (V-Net)"]:::model
        DAE_Loss["DAE Loss Functions"]:::loss
        DAE_Train["Pretraining Controller\n(train_DAE.py)"]:::script
        DAE_Checkpoint["DAE Model Checkpoint"]:::storage
        DAE_Test["DAE Evaluation Script\n(test_DAE.py)"]:::script
    end

    %% Phase 2: Segmentation Training
    subgraph "Phase 2: Mean-Teacher Segmentation"
        direction TB
        DL2["Data Loader Module"]:::dataIO
        Student["Student V-Net"]:::model
        Teacher["Teacher V-Net (EMA)"]:::model
        Embeddings["DAE Embeddings"]:::model
        Uncertainty["Uncertainty Estimator"]:::loss
        MT_Loss["Consistency & Supervised Loss"]:::loss
        Ramps2["Ramp-Up Schedules"]:::util
        MT_Train["MT Training Controller\n(train_Abdomen_meanteacher_DAE_certainty.py)"]:::script
        MT_Checkpoint["Segmentation Model Checkpoint"]:::storage
        MT_Test["Segmentation Evaluation Script\n(test_Abdomen.py)"]:::script
    end

    %% Utilities Shared
    subgraph Utilities
        direction TB
        Utils1["DAE Utils"]:::util
        Utils2["MT Utils"]:::util
        Ramps1["Ramp-Up Schedules"]:::util
    end

    %% Connections Phase 1
    LA --> DL1
    FLARE --> DL1
    DL1 --> DAE
    DAE --> DAE_Loss
    DAE_Loss --> DAE_Train
    DAE_Train --> DAE_Checkpoint
    DAE_Checkpoint --> DAE_Test

    %% Connections Phase 2
    LA --> DL2
    FLARE --> DL2
    DL2 --> Student
    DL2 --> Teacher
    DAE_Checkpoint --> Embeddings
    Embeddings --> Uncertainty
    Student --> MT_Loss
    Teacher --> MT_Loss
    Uncertainty --> MT_Loss
    MT_Loss --> MT_Train
    Ramps2 --> MT_Train
    MT_Train --> MT_Checkpoint
    MT_Checkpoint --> MT_Test

    %% Utility Flows
    Utils1 --> DL1
    Utils1 --> DAE_Loss
    Ramps1 --> DAE_Train
    Utils2 --> DL2
    Utils2 --> Uncertainty
    Utils2 --> MT_Loss

    %% Click Events
    click DL1 "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE/dataloaders/medical_dataloader.py"
    click DL1 "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE/dataloaders/utils.py"
    click DL2 "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE_MT/dataloaders/medical_dataloader.py"
    click DL2 "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE_MT/dataloaders/utils.py"
    click DAE "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE/networks/vnet.py"
    click Student "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE_MT/networks/vnet.py"
    click Teacher "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE_MT/networks/vnet.py"
    click Uncertainty "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE_MT/utils/losses.py"
    click DAE_Loss "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE/utils/losses.py"
    click Ramps1 "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE/utils/ramps.py"
    click Ramps2 "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE_MT/utils/ramps.py"
    click Utils1 "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE/utils/util.py"
    click Utils2 "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE_MT/utils/util.py"
    click DAE_Train "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE/train_DAE.py"
    click MT_Train "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE_MT/train_Abdomen_meanteacher_DAE_certainty.py"
    click DAE_Test "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE/test_DAE.py"
    click MT_Test "https://github.com/adigasu/anatomically-aware_uncertainty_for_semi-supervised_segmentation/blob/main/code_DAE_MT/test_Abdomen.py"

    %% Styles
    classDef dataIO fill:#D0E8FF,stroke:#0077B6,color:#023E8A,stroke-width:1px
    classDef model fill:#D0FFD6,stroke:#2D6A4F,color:#1B4332,stroke-width:1px
    classDef loss fill:#FFE8D6,stroke:#F08A5D,color:#C34000,stroke-width:1px
    classDef util fill:#F0F0F0,stroke:#555555,color:#222222,stroke-width:1px
    classDef script fill:#FDE2E4,stroke:#E63946,color:#9D0208,stroke-width:1px
    classDef storage fill:#E8EAFF,stroke:#4C6EF5,color:#253494,stroke-width:1px

    class LA,FLARE external
    class external fill:#FFFFFF,stroke:#000000,color:#000000
    class DL1,DL2 dataIO
    class DAE,Student,Teacher,Embeddings model
    class DAE_Loss,Uncertainty,MT_Loss loss
    class Utils1,Utils2,Ramps1,Ramps2 util
    class DAE_Train,MT_Train,DAE_Test,MT_Test script
    class DAE_Checkpoint,MT_Checkpoint storage
```
