Topology-aware bronchial tree segmentation from CT. Airway masks are extracted using TotalSegmentator, then skeletonized with Kimimaro. Branch points are detected and parsed using rule-based anatomical constraints to produce consistent airway labeling and multi-segment outputs for 3D Slicer.
Automatically parse an unsegmented bronchial tree into anatomically meaningful airway branches using skeleton-based topology analysis.
This project provides a lightweight, non-deep-learning pipeline to convert a binary bronchial tree into structured anatomical segments (e.g., Trachea, RMB, RUL, B1–B10).
Unlike neural network approaches, this method is:
It is particularly useful for:
CT scan (.nii.gz) ↓ TotalSegmentator ↓ Extract bronchial tree (binary mask / Segment_1) ↓ Skeletonization (kimimaro) ↓ Graph-based branch tracing ↓ Anatomical classification (B1–B10) ↓ Export:
.seg.nrrd (3D Slicer compatible) .txt (segment names)
Below shows how the algorithm converts an unsegmented bronchial tree into labeled anatomical branches:

The colorized airway branches significantly improve interpretability when reviewing CT in different views:
This allows faster identification of bronchial segments (e.g., B1–B10) during image navigation.

🎥 Video demonstration:
https://youtu.be/xXrjiTo91TU
pip install numpy scipy scikit-learn nibabel pynrrd kimimaro
python bronchial_branch_labeler.py ^
--input "D:/LyNoS_dataset/Benchmark/Pat2/lung_vessels_segmentation/lung_vessels_segmentation_bronchial_ori.seg.nrrd" ^
--ct "D:/LyNoS_dataset/Benchmark/Pat2/pat2_data.nii.gz" ^
--output "D:/LyNoS_dataset/Benchmark/Pat2/lung_vessels_segmentation/bronchial_BRANCHES.seg.nrrd"
Argument Description –input Binary bronchial tree segmentation (.seg.nrrd) –ct Original CT volume (.nii.gz) for spatial reference –output Output segmented airway file (.seg.nrrd) –ap-sign (optional) Set to -1 if anterior–posterior direction is flipped
Skeletonization via kimimaro Graph traversal (BFS, shortest path) PCA-based orientation estimation Branch classification using geometric heuristics Cranial direction → B1 Anterior/Posterior → B2 / B3 Spatial clustering for distal branches Topology-preserving labeling
No deep learning model is used.
Input bronchial tree should be reasonably clean (e.g., from TotalSegmentator) Extremely noisy segmentations may affect branch detection Left B7 is not defined (consistent with anatomical convention)
MIT License
TotalSegmentator for whole-body CT segmentation kimimaro for skeletonization
Support for airway variants Integration with radiology AI pipelines Quantitative airway analysis (diameter, angle, topology metrics)