# yazdansalimi/organ-segmentation architecture

> Architecture diagram of the GitHub repository yazdansalimi/organ-segmentation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yazdansalimi/organ-segmentation
- Repository: https://github.com/yazdansalimi/organ-segmentation

## Overview

Organ-Segmentation is a Python tool for deep-learning multi-organ segmentation of NIfTI images, using nnU-Net models selected by imaging modality. The main workflow accepts images and options, optionally validates and splits large images, selects trained models, runs inference, and restores segmentations to the original image dimensions. The README also documents CT and PET model families and modality-specific input requirements. The graph follows the sampled inference code; model-family internals and some image-processing details are not shown.

Main entry points: [`organsegment/predict_multi.py`](https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/predict_multi.py) (Batch inference API), [`organsegment/ImageUtitlities.py`](https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/ImageUtitlities.py) (nnU-Net prediction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Inference workflow"]
  node_api["Batch inference API<br/>[predict_multi.py]"]
  node_validation["Input validation<br/>[predict_multi.py]"]
  node_model_select["Modality model selection<br/>[predict_multi.py]"]
end

subgraph group_runtime["Segmentation runtime"]
  node_nnunet["nnU-Net prediction<br/>[ImageUtitlities.py]"]
end

subgraph group_imaging["Image handling"]
  node_large_image["Large-image splitting<br/>[ImageUtitlities.py]"]
  node_staging["Inference staging<br/>[ImageUtitlities.py]"]
  node_segment_files["Segmentation files<br/>[ImageUtitlities.py]"]
  node_reassembly["Segmentation reassembly<br/>[ImageUtitlities.py]"]
end

node_user(("Operator"))
node_inputs["NIfTI images"]
node_model_store[("Trained nnU-Net models")]

node_user -->|"configures"| node_api
node_inputs -->|"submits"| node_api
node_api -->|"validates"| node_validation
node_api -->|"splits images"| node_large_image
node_api -->|"selects models"| node_model_select
node_model_select -->|"finds model folders"| node_model_store
node_api -->|"stages inference"| node_staging
node_staging -->|"calls predictor"| node_nnunet
node_nnunet -->|"writes segments"| node_segment_files
node_api -->|"reassembles"| node_reassembly
node_reassembly -->|"restores dimensions"| node_segment_files

click node_api "https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/predict_multi.py"
click node_validation "https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/predict_multi.py"
click node_model_select "https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/predict_multi.py"
click node_large_image "https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/ImageUtitlities.py"
click node_staging "https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/ImageUtitlities.py"
click node_nnunet "https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/ImageUtitlities.py"
click node_segment_files "https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/ImageUtitlities.py"
click node_reassembly "https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/ImageUtitlities.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_validation,node_model_select toneBlue
class node_nnunet,node_model_store toneAmber
class node_large_image,node_staging,node_segment_files,node_reassembly toneMint
class node_user,node_inputs toneIndigo
```

## Components

### Inference workflow

- [Batch inference API](https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/predict_multi.py): `organsegment/predict_multi.py`
- [Input validation](https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/predict_multi.py): `organsegment/predict_multi.py`
- [Modality model selection](https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/predict_multi.py): `organsegment/predict_multi.py`

### Segmentation runtime

- [nnU-Net prediction](https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/ImageUtitlities.py): `organsegment/ImageUtitlities.py`

### Image handling

- [Large-image splitting](https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/ImageUtitlities.py): `organsegment/ImageUtitlities.py`
- [Inference staging](https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/ImageUtitlities.py): `organsegment/ImageUtitlities.py`
- [Segmentation files](https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/ImageUtitlities.py): `organsegment/ImageUtitlities.py`
- [Segmentation reassembly](https://github.com/yazdansalimi/organ-segmentation/blob/main/organsegment/ImageUtitlities.py): `organsegment/ImageUtitlities.py`

### Other components

- **Operator**
- **NIfTI images**
- **Trained nnU-Net models**

## Connections

- Operator → Batch inference API: configures
- NIfTI images → Batch inference API: submits
- Batch inference API → Input validation: validates (evidence: `organsegment/predict_multi.py`)
- Batch inference API → Large-image splitting: splits images (evidence: `organsegment/predict_multi.py`)
- Batch inference API → Modality model selection: selects models (evidence: `organsegment/predict_multi.py`)
- Modality model selection → Trained nnU-Net models: finds model folders (evidence: `organsegment/predict_multi.py`)
- Batch inference API → Inference staging: stages inference (evidence: `organsegment/predict_multi.py`)
- Inference staging → nnU-Net prediction: calls predictor (evidence: `organsegment/ImageUtitlities.py`)
- nnU-Net prediction → Segmentation files: writes segments (evidence: `organsegment/ImageUtitlities.py`)
- Batch inference API → Segmentation reassembly: reassembles (evidence: `organsegment/predict_multi.py`)
- Segmentation reassembly → Segmentation files: restores dimensions (evidence: `organsegment/ImageUtitlities.py`)
