# nhahub/nha-5-187 architecture

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

- Interactive diagram: https://gitdiagram.com/nhahub/nha-5-187
- Repository: https://github.com/nhahub/nha-5-187

## Overview

BMTS is a research prototype for 3D brain-MRI tumor segmentation and patient-level assessment. Its central workflow takes T1, T1ce, T2 and FLAIR scans through optional standardization and segmentation, then reports tumor-region volumes, longitudinal change, radiomics and confidence maps. Training, exploratory data analysis, fast model deployment and MRI mask viewing are additional product capabilities. Edges are limited to relationships stated in the README or visible in the supplied excerpts and source index; unsampled app and pipeline internals are not inferred.

Main entry points: [`src/bmts/pipeline/analyze.py`](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/pipeline/analyze.py) (Analysis pipeline), [`src/bmts/deploy/segmenter.py`](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/deploy/segmenter.py) (Fast segmenter), [`src/bmts/data/datasets/brats.py`](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/data/datasets/brats.py) (BraTS loader), [`src/bmts/segmentation/training/trainer.py`](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/segmentation/training/trainer.py) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["MRI Data"]
  node_cleaning["Scan cleaning<br/>[standardize.py]"]
  node_splits["Patient splits<br/>[splits.py]"]
  node_loader["BraTS loader<br/>[brats.py]"]
  node_augmentation["Augmentation<br/>[transforms.py]"]
end

subgraph group_model["Segmentation Model"]
  node_trainer["Model training<br/>[trainer.py]"]
  node_unet["3D U-Net<br/>[unet3d.py]"]
  node_export["Model export<br/>[export.py]"]
  node_segmenter["Fast segmenter<br/>[segmenter.py]"]
end

subgraph group_analysis["Patient Analysis"]
  node_pipeline["Analysis pipeline<br/>[analyze.py]"]
  node_volumes["Tumor volumes<br/>[volumes.py]"]
  node_longitudinal["Longitudinal change<br/>[longitudinal.py]"]
  node_radiomics["Radiomics features<br/>[features.py]"]
  node_tta["TTA prediction<br/>[nnunet_tta.py]"]
  node_confidence["Confidence maps<br/>[maps.py]"]
  node_report["Analysis results"]
end

subgraph group_apps["User Interfaces"]
  node_viewer["MRI mask viewer<br/>[m2_t05_viewer.py]"]
  node_webapp["Web interface"]
end

subgraph group_explore["EDA"]
  node_eda["EDA statistics<br/>[stats.py]"]
  node_figures["EDA figures<br/>[figures.py]"]
end

node_user(("Research user"))
node_scans["MRI scans"]

node_user -->|"provides"| node_scans
node_scans -->|"analyzes"| node_pipeline
node_pipeline -->|"optionally cleans"| node_cleaning
node_pipeline -->|"predicts mask"| node_tta
node_tta -->|"accumulates passes"| node_confidence
node_pipeline -->|"computes volumes"| node_volumes
node_pipeline -->|"computes change"| node_longitudinal
node_pipeline -->|"extracts features"| node_radiomics
node_pipeline -->|"summarizes maps"| node_confidence
node_pipeline -->|"produces"| node_report
node_user -->|"views scans"| node_viewer
node_viewer -->|"reads cleaned scans"| node_scans
node_user -.->|"uses"| node_webapp
node_loader -->|"checks eligibility"| node_splits
node_loader -->|"uses transforms"| node_augmentation
node_trainer -->|"builds loaders"| node_loader
node_trainer -->|"trains model"| node_unet
node_export -->|"packages model for"| node_segmenter
node_user -->|"requests prediction"| node_segmenter
node_scans -->|"provides modalities"| node_segmenter
node_segmenter -->|"returns mask"| node_report
node_user -->|"explores cohorts"| node_eda
node_eda -.->|"creates figures"| node_figures

click node_cleaning "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/data/cleaning/standardize.py"
click node_splits "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/data/splits.py"
click node_loader "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/data/datasets/brats.py"
click node_augmentation "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/data/augmentation/transforms.py"
click node_trainer "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/segmentation/training/trainer.py"
click node_unet "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/segmentation/models/unet3d.py"
click node_export "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/deploy/export.py"
click node_segmenter "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/deploy/segmenter.py"
click node_pipeline "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/pipeline/analyze.py"
click node_volumes "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/quantitative/volumes.py"
click node_longitudinal "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/quantitative/longitudinal.py"
click node_radiomics "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/radiomics/features.py"
click node_tta "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/uncertainty/nnunet_tta.py"
click node_confidence "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/uncertainty/maps.py"
click node_viewer "https://github.com/nhahub/nha-5-187/blob/main/apps/m2_t05_viewer.py"
click node_webapp "https://github.com/nhahub/nha-5-187/blob/main/apps/web_interface_m4_t03.py"
click node_eda "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/eda/stats.py"
click node_figures "https://github.com/nhahub/nha-5-187/blob/main/src/bmts/eda/figures.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_cleaning,node_splits,node_loader,node_augmentation,node_user toneBlue
class node_trainer,node_unet,node_export,node_segmenter toneAmber
class node_pipeline,node_volumes,node_longitudinal,node_radiomics,node_tta,node_confidence,node_report toneMint
class node_viewer,node_webapp toneRose
class node_eda,node_figures,node_scans toneIndigo
```

## Components

### MRI Data

- [Scan cleaning](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/data/cleaning/standardize.py): `src/bmts/data/cleaning/standardize.py`
- [Patient splits](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/data/splits.py): `src/bmts/data/splits.py`
- [BraTS loader](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/data/datasets/brats.py): `src/bmts/data/datasets/brats.py`
- [Augmentation](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/data/augmentation/transforms.py): `src/bmts/data/augmentation/transforms.py`

### Segmentation Model

- [Model training](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/segmentation/training/trainer.py): `src/bmts/segmentation/training/trainer.py`
- [3D U-Net](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/segmentation/models/unet3d.py): `src/bmts/segmentation/models/unet3d.py`
- [Model export](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/deploy/export.py): `src/bmts/deploy/export.py`
- [Fast segmenter](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/deploy/segmenter.py): `src/bmts/deploy/segmenter.py`

### Patient Analysis

- [Analysis pipeline](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/pipeline/analyze.py): `src/bmts/pipeline/analyze.py`
- [Tumor volumes](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/quantitative/volumes.py): `src/bmts/quantitative/volumes.py`
- [Longitudinal change](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/quantitative/longitudinal.py): `src/bmts/quantitative/longitudinal.py`
- [Radiomics features](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/radiomics/features.py): `src/bmts/radiomics/features.py`
- [TTA prediction](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/uncertainty/nnunet_tta.py): `src/bmts/uncertainty/nnunet_tta.py`
- [Confidence maps](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/uncertainty/maps.py): `src/bmts/uncertainty/maps.py`
- **Analysis results**

### User Interfaces

- [MRI mask viewer](https://github.com/nhahub/nha-5-187/blob/main/apps/m2_t05_viewer.py): `apps/m2_t05_viewer.py`
- [Web interface](https://github.com/nhahub/nha-5-187/blob/main/apps/web_interface_m4_t03.py): `apps/web_interface_m4_t03.py`

### EDA

- [EDA statistics](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/eda/stats.py): `src/bmts/eda/stats.py`
- [EDA figures](https://github.com/nhahub/nha-5-187/blob/main/src/bmts/eda/figures.py): `src/bmts/eda/figures.py`

### Other components

- **Research user**
- **MRI scans**

## Connections

- Research user → MRI scans: provides (evidence: `README.md`)
- MRI scans → Analysis pipeline: analyzes (evidence: `README.md`)
- Analysis pipeline → Scan cleaning: optionally cleans (evidence: `src/bmts/pipeline/analyze.py`)
- Analysis pipeline → TTA prediction: predicts mask (evidence: `src/bmts/pipeline/analyze.py`)
- TTA prediction → Confidence maps: accumulates passes (evidence: `src/bmts/uncertainty/nnunet_tta.py`)
- Analysis pipeline → Tumor volumes: computes volumes (evidence: `src/bmts/pipeline/analyze.py`)
- Analysis pipeline → Longitudinal change: computes change (evidence: `src/bmts/pipeline/analyze.py`)
- Analysis pipeline → Radiomics features: extracts features (evidence: `src/bmts/pipeline/analyze.py`)
- Analysis pipeline → Confidence maps: summarizes maps (evidence: `src/bmts/pipeline/analyze.py`)
- Analysis pipeline → Analysis results: produces (evidence: `README.md`)
- Research user → MRI mask viewer: views scans (evidence: `README.md`)
- MRI mask viewer → MRI scans: reads cleaned scans (evidence: `apps/m2_t05_viewer.py`)
- Research user → Web interface: uses (evidence: `README.md`)
- BraTS loader → Patient splits: checks eligibility (evidence: `src/bmts/data/datasets/brats.py`)
- BraTS loader → Augmentation: uses transforms (evidence: `src/bmts/data/datasets/brats.py`)
- Model training → BraTS loader: builds loaders (evidence: `src/bmts/segmentation/training/trainer.py`)
- Model training → 3D U-Net: trains model (evidence: `src/bmts/segmentation/training/trainer.py`)
- Model export → Fast segmenter: packages model for (evidence: `src/bmts/deploy/segmenter.py`)
- Research user → Fast segmenter: requests prediction (evidence: `README.md`)
- MRI scans → Fast segmenter: provides modalities (evidence: `README.md`)
- Fast segmenter → Analysis results: returns mask (evidence: `README.md`)
- Research user → EDA statistics: explores cohorts (evidence: `README.md`)
- EDA statistics → EDA figures: creates figures (evidence: `src/bmts/eda/figures.py`)
