# phyrise/nnunet_translation architecture

> Architecture diagram of the GitHub repository phyrise/nnunet_translation, 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/phyrise/nnunet_translation
- Repository: https://github.com/phyrise/nnunet_translation

## Overview

Overview:

Main Components:
##### Data Preparation & Conversion
- Dataset conversion scripts (located under nnunetv2/dataset_conversion): These modules are responsible for converting raw medical imaging datasets into the format required by the nnU-Net pipelines.
- Integration test dataset converters indicate a rigorous approach to dataset integrity and testing.

##### Experiment Planning & Preprocessing
- Experiment planning (nnunetv2/experiment_planning): This includes fingerprint extraction, planners (default, network_topology, resencUNet_planner), and pretraining plans.
- Preprocessing modules (nnunetv2/preprocessing): Normalize imaging data, crop images, and resample for the network training. The normalization and cropping submodules are critical to preparing the image data.

##### Training Modules
- The training codebase (nnunetv2/training): Contains data augmentation, data loading, logging, and various customized trainer variants (e.g., different loss functions, schedulers, network architectures). This section further includes numerous variants within nnUNetTrainer suggesting multiple training strategies.
- Incorporate custom augmentation and loss functions, directional data flow from preprocessed data into the training routines.

##### Inference & Evaluation
- Inference pipeline (nnunetv2/inference): Handles prediction workflows, including sliding window prediction, inference export, and handling raw data.
- Evaluation (nnunetv2/evaluation): Modules for accumulating results, evaluating predictions, and finding the best configuration establish evaluation loops within the pipeline.

##### Model Sharing & Ensembling
- Model sharing (nnunetv2/model_sharing): Provides mechanisms for model import/export and downloading pretrained weights.
- Ensembling (nnunetv2/ensembling): Combines multiple predictions to potentially improve inference outcomes.

##### Utilities & Configuration
- A centralized utilities folder (nnunetv2/utilities) supports various tasks such as logging, file path utilities, network initialization, and plan handling.
- Configuration files (nnunetv2/configuration.py, setup.py, pyproject.toml) help manage environment settings and dependencies.

##### Batch Operations & Automated Workflows
- The batch_running directory shows scripts designed for generating commands, benchmarking, and handling large-scale experiments.
- GitHub workflows (in .github/workflows) and various documentation files indicate continuous integration practices and detailed usage instructions.

Architectural Relationships:
- Data flows from raw datasets → dataset_conversion → preprocessing → experiment planning.
- Preprocessed data then flows into distinct training pipelines, which are highly modular (supported by different nnUNetTrainer variants).
- Once models are trained, the pipeline divides into inference and evaluation routes.
- Model sharing and ensembling are components that interact with both training (for export/import) and inference (to create ensemble predictions).
- Auxiliary utilities and logging are interconnected with all core components providing configuration and diagnostic support.

– The sequential flow from dataset conversion → preprocessing → training → validation/inference.
– Feedback loops such as evaluation results influencing retraining or tuning.
- External dependencies such as modified versions of the batchgenerators and dynamic-network-architectures with external link markers.

Tailoring to This Project:
Since nnUNet_translation is a full-stack deep learning pipeline specifically for medical imaging:
- Separation between data preparation (conversion, normalization, resampling) and experimentation (planning, training, variant modules).
- Iterative and modular nature of training pipelines, noting the multiple trainer variants and custom augmentation modules.

Summary for the Principal Software Engineer:
- Raw Data → Data Conversion → Preprocessing/Experiment Planning → Training (with multiple trainer variants) → Inference → Evaluation.
3. External libraries (modified batchgenerators and dynamic-network-architectures), configuration management, and integration testing.
5. Review the detailed directory structure to ensure that every significant piece (such as utilities, logging, and experiment planning) is included to capture the comprehensive architecture of nnUNet_translation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Input Layer
    subgraph "Data Input Layer"
        RD("Raw Medical Data"):::datainput
        DC("Dataset Conversion"):::datainput
        PP("Preprocessing"):::datainput
        EP("Experiment Planning"):::datainput
    end

    %% Model Training & Processing Layer
    subgraph "Model Training & Processing"
        TM("Training Modules<br/>(Data Augmentation, Data Loading,<br/>Trainer Variants)"):::training
    end

    %% Deployment & Output Layer
    subgraph "Deployment & Output Layer"
        IF("Inference"):::output
        EV("Evaluation"):::output
        MS("Model Sharing"):::output
        EN("Ensembling"):::output
    end

    %% Auxiliary Components
    UTIL("Utilities & Configuration"):::utility
    BATCH("Batch Operations & Workflows"):::utility
    NOTE("Notebooks (Entry Points/Tutorials)"):::utility

    %% Main Flow
    RD -->|"ingests"| DC
    DC -->|"converts"| PP
    PP -->|"preps"| EP
    EP -->|"guides"| TM
    TM -->|"trains into"| IF
    TM -->|"exports models to"| MS
    TM -->|"logs & metrics to"| EV
    IF -->|"outputs to"| EV
    MS -->|"feeds into"| EN

    %% Feedback loop
    EV -- "feedback" --> EP

    %% Connections to auxiliary components (dotted lines)
    UTIL -.-> DC
    UTIL -.-> PP
    UTIL -.-> EP
    UTIL -.-> TM
    UTIL -.-> IF
    UTIL -.-> EV
    UTIL -.-> MS
    UTIL -.-> EN

    BATCH -.-> TM
    BATCH -.-> IF
    BATCH -.-> EV

    NOTE -.-> EP

    %% Click Events
    click DC "https://github.com/phyrise/nnunet_translation/tree/master/nnunetv2/dataset_conversion"
    click PP "https://github.com/phyrise/nnunet_translation/tree/master/nnunetv2/preprocessing"
    click EP "https://github.com/phyrise/nnunet_translation/tree/master/nnunetv2/experiment_planning"
    click TM "https://github.com/phyrise/nnunet_translation/tree/master/nnunetv2/training"
    click IF "https://github.com/phyrise/nnunet_translation/tree/master/nnunetv2/inference"
    click EV "https://github.com/phyrise/nnunet_translation/tree/master/nnunetv2/evaluation"
    click MS "https://github.com/phyrise/nnunet_translation/tree/master/nnunetv2/model_sharing"
    click EN "https://github.com/phyrise/nnunet_translation/tree/master/nnunetv2/ensembling"
    click UTIL "https://github.com/phyrise/nnunet_translation/tree/master/nnunetv2/utilities"
    click BATCH "https://github.com/phyrise/nnunet_translation/tree/master/nnunetv2/batch_running"
    click NOTE "https://github.com/phyrise/nnunet_translation/tree/master/notebooks"

    %% Styles
    classDef datainput fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef training fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef output fill:#ABEBC6,stroke:#1D8348,stroke-width:2px;
    classDef utility fill:#D5DBDB,stroke:#566573,stroke-width:2px;
```
