# mohammedsunoqrot/pyautoref architecture

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

- Interactive diagram: https://gitdiagram.com/mohammedsunoqrot/pyautoref
- Repository: https://github.com/mohammedsunoqrot/pyautoref

## Overview

pyAutoRef is a research-use Python package for dual-reference fat-and-muscle normalization of prostate T2-weighted MRI. A caller supplies a SimpleITK image or supported image path; the exported `autoref` function preprocesses the image, detects and refines reference-tissue regions (with a fallback when detection fails), normalizes intensities, and optionally saves the result. The graph follows the sampled orchestrator and modules; utility functions are grouped by responsibility because `utils.py` is only partially excerpted.

Main entry points: [`src/pyAutoRef/autoref.py`](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/autoref.py) (AutoRef pipeline), [`src/pyAutoRef/__init__.py`](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/__init__.py) (Public API), [`src/pyAutoRef/pre_processing.py`](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/pre_processing.py) (Image preprocessing), [`src/pyAutoRef/object_detection.py`](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/object_detection.py) (YOLO detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Package entry"]
  node_api["Public API<br/>[__init__.py]"]
  node_pipeline["AutoRef pipeline<br/>[autoref.py]"]
end

subgraph group_prep["Image preparation"]
  node_prepare["Image preprocessing<br/>[pre_processing.py]"]
  node_image_io["Image and DICOM I/O<br/>[utils.py]"]
end

subgraph group_detect["Detection and refinement"]
  node_detector["YOLO detection"]
  node_model["YOLO ONNX model<br/>[model.onnx]"]
  node_detection_helpers["Inference helpers<br/>[utils.py]"]
  node_postprocess["Detection refinement<br/>[post_processing.py]"]
  node_postprocess_helpers["Mask and intensity helpers<br/>[utils.py]"]
  node_fallback["No-detection fallback<br/>[utils.py]"]
end

subgraph group_normalize["Normalization and output"]
  node_normalize["Intensity normalization<br/>[normalization.py]"]
  node_output_io["Output image writer<br/>[utils.py]"]
end

node_caller(("Image caller"))

node_caller -->|"calls"| node_api
node_api -->|"exports"| node_pipeline
node_pipeline -->|"preprocesses"| node_prepare
node_prepare -->|"reads and prepares"| node_image_io
node_pipeline -->|"detects objects"| node_detector
node_pipeline -->|"locates model"| node_model
node_detector -->|"runs inference"| node_detection_helpers
node_pipeline -->|"refines predictions"| node_postprocess
node_postprocess -->|"extracts masks"| node_postprocess_helpers
node_pipeline -->|"gets fallback intensities"| node_fallback
node_pipeline -->|"normalizes image"| node_normalize
node_pipeline -->|"optionally saves"| node_output_io
node_pipeline -->|"returns image"| node_caller

click node_api "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/__init__.py"
click node_pipeline "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/autoref.py"
click node_prepare "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/pre_processing.py"
click node_image_io "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/utils.py"
click node_detector "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/object_detection.py"
click node_model "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/model.onnx"
click node_detection_helpers "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/utils.py"
click node_postprocess "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/post_processing.py"
click node_postprocess_helpers "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/utils.py"
click node_fallback "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/utils.py"
click node_normalize "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/normalization.py"
click node_output_io "https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/utils.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_pipeline toneBlue
class node_prepare,node_image_io toneAmber
class node_detector,node_model,node_detection_helpers,node_postprocess,node_postprocess_helpers,node_fallback toneMint
class node_normalize,node_output_io toneRose
class node_caller toneIndigo
```

## Components

### Package entry

- [Public API](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/__init__.py): `src/pyAutoRef/__init__.py`
- [AutoRef pipeline](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/autoref.py): `src/pyAutoRef/autoref.py`

### Image preparation

- [Image preprocessing](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/pre_processing.py): `src/pyAutoRef/pre_processing.py`
- [Image and DICOM I/O](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/utils.py): `src/pyAutoRef/utils.py`

### Detection and refinement

- [YOLO detection](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/object_detection.py): `src/pyAutoRef/object_detection.py`
- [YOLO ONNX model](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/model.onnx): `src/pyAutoRef/model.onnx`
- [Inference helpers](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/utils.py): `src/pyAutoRef/utils.py`
- [Detection refinement](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/post_processing.py): `src/pyAutoRef/post_processing.py`
- [Mask and intensity helpers](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/utils.py): `src/pyAutoRef/utils.py`
- [No-detection fallback](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/utils.py): `src/pyAutoRef/utils.py`

### Normalization and output

- [Intensity normalization](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/normalization.py): `src/pyAutoRef/normalization.py`
- [Output image writer](https://github.com/mohammedsunoqrot/pyautoref/blob/master/src/pyAutoRef/utils.py): `src/pyAutoRef/utils.py`

### Other components

- **Image caller**

## Connections

- Image caller → Public API: calls (evidence: `README.md`)
- Public API → AutoRef pipeline: exports (evidence: `src/pyAutoRef/__init__.py`)
- AutoRef pipeline → Image preprocessing: preprocesses (evidence: `src/pyAutoRef/autoref.py`)
- Image preprocessing → Image and DICOM I/O: reads and prepares (evidence: `src/pyAutoRef/pre_processing.py`)
- AutoRef pipeline → YOLO detection: detects objects (evidence: `src/pyAutoRef/autoref.py`)
- AutoRef pipeline → YOLO ONNX model: locates model (evidence: `src/pyAutoRef/autoref.py`)
- YOLO detection → Inference helpers: runs inference (evidence: `src/pyAutoRef/object_detection.py`)
- AutoRef pipeline → Detection refinement: refines predictions (evidence: `src/pyAutoRef/autoref.py`)
- Detection refinement → Mask and intensity helpers: extracts masks (evidence: `src/pyAutoRef/post_processing.py`)
- AutoRef pipeline → No-detection fallback: gets fallback intensities (evidence: `src/pyAutoRef/autoref.py`)
- AutoRef pipeline → Intensity normalization: normalizes image (evidence: `src/pyAutoRef/autoref.py`)
- AutoRef pipeline → Output image writer: optionally saves (evidence: `src/pyAutoRef/autoref.py`)
- AutoRef pipeline → Image caller: returns image (evidence: `README.md`)
