Hybrid Context Forests and Bilateral Viterbi Matching for 3D Rib Centerline Tracing in CT
Abstract
Automatic extraction and anatomical numbering (R01-R12, L01-L12) of all 24 rib centerlines in thoracic CT is essential for unfolded rib visualization, fracture detection, and surgical navigation, but remains challenging due to adjacent-bone confluence, calcified costal cartilage bridges, kyphotic pose variation, and partial visibility of terminal ribs. We present ribline, an open-source three-stage framework combining: (1) an automatically detected lung-apex and vertebral-midline coordinate frame with a kyphosis-aware azimuthal angle for point ordering along each rib; (2) a hybrid voxel detector fusing an anatomically anchored Semantic Context Forest (SCF) with a lightweight 3D U-Net; and (3) a global stage that decomposes the probability skeleton into candidate curves, assigns rib indices via a bilateral Viterbi dynamic program coupled across both hemithoraces, and refines curves via template recovery and normal-plane centering (RibSnake). On the Siemens Corporate Research 2 mm thoracic CT benchmark (47 training and 12 evaluation scans), our pipeline achieves a labeled Chamfer distance of 2.05 mm, labeled clDice of 0.886 (3 mm) and 0.945 (4 mm), 97.2% labeling accuracy (278/286 ribs), and zero false-positive curves on the evaluation split, and 3.64 mm (median 2.39 mm) with 91.8% labeling accuracy across all 59 annotated scans (1,402 ribs) in 5-fold cross-validation. Code: https://github.com/wq2012/ribline Pretrained Models: https://huggingface.co/collections/wq2012/ribline
Figures & tables
| Method | LCD (mm) | 95 % CI | UCD | lab. clDice | Labeling accuracy (%) | Recall | Prec. (FP) | NLD | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| mean SD | (mm) | 3 mm | 4 mm | (%) | (%) | |||||||
| RF Pass-1 + Z-sort | (13) | |||||||||||
| SCF Pass-2 + Z-sort | (0) | |||||||||||
| SCF Pass-2 + Stage 3 | (1) | |||||||||||
| Anatomical SCF + Stage 3 | (1) | |||||||||||
| 3D U-Net + Z-sort | (0) | |||||||||||
| Method | LCD (mm) | 95 % CI | UCD (mm) | lab. clDice | Recall | Prec. (FP) | NLD | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Anatomical SCF + Stage 3 | (29) | |||||||||||
| 3D U-Net + Stage 3 | (25) | |||||||||||
| Hybrid + Viterbi (w/o RibSnake) | (17) | |||||||||||
| Hybrid + full Stage 3 (ours) | (20) | |||||||||||
| Method | LCD (mm) | 95 % CI | UCD (mm) | lab. clDice | Recall | Prec. (FP) | NLD | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Anatomical SCF + Stage 3 | (67) | |||||||||||
| 3D U-Net + Stage 3 | (26) | |||||||||||
| Hybrid + Viterbi (w/o RibSnake) | (29) | |||||||||||
| Hybrid + full Stage 3 (ours) | (33) | |||||||||||
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| Module / Script | Section | Implemented Functionality |
|---|---|---|
| ribline.data.image_reader | Sec. 2 | Analyze 7.5 ( .hdr/.img ), NIfTI ( .nii/.nii.gz ), and MetaImage ( .mha/.mhd ) 3D I/O with spacing and origin preservation. |
| ribline.data.centerline_parser | Sec. 5 | Parsing of ground-truth ( _interp.xls ) and predicted 3D centerline coordinate files. |
| ribline.model.anatomy | Sec. 2 | Hounsfield standardization ( standardize_hu ), lung apex and spine midline detection, kyphosis-aware azimuthal angle, and 24-rib statistical atlas ( RibCageStatisticalAtlas ). |
| ribline.model.features | Sec. 3 | Multi-scale 3D Gaussian derivatives, diagonal-curvature tubularity proxy, canonical coordinates, and Random Shift Intensity/Probability Differences (RSID). |
| ribline.model.forest | Sec. 3 | Balanced random forest wrappers ( RibForest ) for Pass-1, Pass-2 auto-context, and anatomically anchored SCF detectors. |
| ribline.model.unet.model | Sec. 3 | Plain 3-level 3D U-Net ( RibUNet3D , parameters) with GroupNorm and sliding-window inference. |
| Hugging Face Repository ID | Model Variant & Included Checkpoints | Size | 12-Scan LCD | 12-Scan Acc | 5-Fold CV LCD / Acc |
|---|---|---|---|---|---|
| wq2012/ribline-3d-ct-centerline | Full Hybrid Suite (SCF + 3D U-Net + Pass 1/2 + Atlas) | MB | mm | mm / | |
| wq2012/ribline-anatomical-scf | Standalone Anatomically Anchored SCF + Atlas (CPU) | MB | mm | mm / | |
| wq2012/ribline-3d-unet | Standalone Lightweight 3D U-Net ( k params) + Atlas | MB | mm | mm / | |
| wq2012/ribline-scf-pass2-autocontext | Two-Pass Auto-Context SCF Baseline + Atlas | MB | mm | — |
3D Medical Image Segmentation
3D Medical Image Segmentation identifies organs, lesions, and fine structures in volumetric scans for measurement and clinical planning.
See all 212 papers