# omkarpshetty/abdomen-project architecture

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

- Interactive diagram: https://gitdiagram.com/omkarpshetty/abdomen-project
- Repository: https://github.com/omkarpshetty/abdomen-project

## Overview

This is a Python tool for coloring abdominal CT DICOM slices with organ-specific legend colors. The primary workflow exports or supplies a DICOM series, loads it as a CT volume and NIfTI file, runs TotalSegmentator, maps and derives organ masks, then renders annotated PNG slices with an optional legend. A batch entry point repeats much of that workflow across patient folders. The README also describes manual tracing for organs without pretrained classes. Relationships are based on the shown entry points, source references, and README; unsampled behavior is not inferred.

Main entry points: [`main.py`](https://github.com/omkarpshetty/abdomen-project/blob/main/main.py) (Pipeline entry), [`batch_main.py`](https://github.com/omkarpshetty/abdomen-project/blob/main/batch_main.py) (Batch entry), [`src/annotate.py`](https://github.com/omkarpshetty/abdomen-project/blob/main/src/annotate.py) (Slice renderer), [`src/dicom_io.py`](https://github.com/omkarpshetty/abdomen-project/blob/main/src/dicom_io.py) (DICOM loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["DICOM input"]
  node_osirix[("OsiriX storage")]
  node_export["Series exporter<br/>[osirix_export.py]"]
  node_dicom["DICOM loader<br/>[dicom_io.py]"]
end

subgraph group_pipeline["Segmentation pipeline"]
  node_main["Pipeline entry<br/>[main.py]"]
  node_segment["Segmentation and masks<br/>[segment.py]"]
  node_totalsegmentator["TotalSegmentator"]
  node_mapping["Organ class mapping<br/>[label_mapping.py]"]
end

subgraph group_annotation["Annotation output"]
  node_colors["Organ color palette<br/>[color_map.py]"]
  node_annotate["Slice renderer<br/>[annotate.py]"]
  node_png["Annotated PNGs"]
  node_manual["Manual tracing"]
end

subgraph group_batch["Batch processing"]
  node_batch["Batch entry<br/>[batch_main.py]"]
end

node_user(("User"))

node_user -->|"selects series"| node_export
node_osirix -->|"scans files"| node_export
node_export -->|"exports DICOM"| node_dicom
node_user -->|"runs pipeline"| node_main
node_main -->|"loads and converts"| node_dicom
node_dicom -->|"returns volume"| node_main
node_main -->|"reads class map"| node_mapping
node_main -->|"runs and loads masks"| node_segment
node_segment -->|"invokes CLI"| node_totalsegmentator
node_main -->|"derives and merges masks"| node_segment
node_main -->|"renders series"| node_annotate
node_annotate -->|"uses palette"| node_colors
node_annotate -->|"writes slices"| node_png
node_user -->|"runs batch"| node_batch
node_batch -->|"loads and converts"| node_dicom
node_batch -->|"runs and loads masks"| node_segment
node_batch -->|"reads class map"| node_mapping
node_batch -->|"renders series"| node_annotate
node_user -->|"traces organs"| node_manual

click node_export "https://github.com/omkarpshetty/abdomen-project/blob/main/src/osirix_export.py"
click node_dicom "https://github.com/omkarpshetty/abdomen-project/blob/main/src/dicom_io.py"
click node_main "https://github.com/omkarpshetty/abdomen-project/blob/main/main.py"
click node_segment "https://github.com/omkarpshetty/abdomen-project/blob/main/src/segment.py"
click node_mapping "https://github.com/omkarpshetty/abdomen-project/blob/main/src/label_mapping.py"
click node_colors "https://github.com/omkarpshetty/abdomen-project/blob/main/color_map.py"
click node_annotate "https://github.com/omkarpshetty/abdomen-project/blob/main/src/annotate.py"
click node_batch "https://github.com/omkarpshetty/abdomen-project/blob/main/batch_main.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_osirix,node_export,node_dicom,node_user toneBlue
class node_main,node_segment,node_totalsegmentator,node_mapping toneAmber
class node_colors,node_annotate,node_png,node_manual toneMint
class node_batch toneRose
```

## Components

### DICOM input

- **OsiriX storage**
- [Series exporter](https://github.com/omkarpshetty/abdomen-project/blob/main/src/osirix_export.py): `src/osirix_export.py`
- [DICOM loader](https://github.com/omkarpshetty/abdomen-project/blob/main/src/dicom_io.py): `src/dicom_io.py`

### Segmentation pipeline

- [Pipeline entry](https://github.com/omkarpshetty/abdomen-project/blob/main/main.py): `main.py`
- [Segmentation and masks](https://github.com/omkarpshetty/abdomen-project/blob/main/src/segment.py): `src/segment.py`
- **TotalSegmentator**
- [Organ class mapping](https://github.com/omkarpshetty/abdomen-project/blob/main/src/label_mapping.py): `src/label_mapping.py`

### Annotation output

- [Organ color palette](https://github.com/omkarpshetty/abdomen-project/blob/main/color_map.py): `color_map.py`
- [Slice renderer](https://github.com/omkarpshetty/abdomen-project/blob/main/src/annotate.py): `src/annotate.py`
- **Annotated PNGs**
- **Manual tracing**

### Batch processing

- [Batch entry](https://github.com/omkarpshetty/abdomen-project/blob/main/batch_main.py): `batch_main.py`

### Other components

- **User**

## Connections

- User → Series exporter: selects series (evidence: `README.md`)
- OsiriX storage → Series exporter: scans files (evidence: `src/osirix_export.py`)
- Series exporter → DICOM loader: exports DICOM (evidence: `README.md`)
- User → Pipeline entry: runs pipeline (evidence: `README.md`)
- Pipeline entry → DICOM loader: loads and converts (evidence: `main.py`)
- DICOM loader → Pipeline entry: returns volume (evidence: `main.py`)
- Pipeline entry → Organ class mapping: reads class map (evidence: `main.py`)
- Pipeline entry → Segmentation and masks: runs and loads masks (evidence: `main.py`)
- Segmentation and masks → TotalSegmentator: invokes CLI (evidence: `src/segment.py`)
- Pipeline entry → Segmentation and masks: derives and merges masks (evidence: `main.py`)
- Pipeline entry → Slice renderer: renders series (evidence: `main.py`)
- Slice renderer → Organ color palette: uses palette (evidence: `src/annotate.py`)
- Slice renderer → Annotated PNGs: writes slices (evidence: `src/annotate.py`)
- User → Batch entry: runs batch (evidence: `README.md`)
- Batch entry → DICOM loader: loads and converts (evidence: `batch_main.py`)
- Batch entry → Segmentation and masks: runs and loads masks (evidence: `batch_main.py`)
- Batch entry → Organ class mapping: reads class map (evidence: `batch_main.py`)
- Batch entry → Slice renderer: renders series (evidence: `batch_main.py`)
- User → Manual tracing: traces organs (evidence: `README.md`)
