How bidur-khanal/spinecurvest works
Project Type and Purpose
• This repository implements an end-to-end research pipeline (not a web app) for automated spine curvature estimation and Cobb angle calculation. It combines a two-stage deep-learning approach (object detection + landmark estimation) with post-processing and MATLAB scripts to produce the final angles from spinal X-ray images.
File Structure Analysis
• Top-level modules:
• Object_Detection – Faster-RCNN via the Luminoth framework, configured by config.yml, with TestAllImage.py.
• Landmark_Detection – Keras/DenseNet code (model.py, train.py, test.py) plus utility routines in all_utils.py.
• CobbAngle_Calculation – MATLAB scripts (angleCal_demo.m, polyfit_lmarks.m, isS.m) and a results folder for sample outputs.
• Jupyter_Notebooks – exploratory and utility notebooks for testing and ground-truth generation.
• utils – Python helpers (compare_angles.py, smape.py) used during evaluation.
• TestAll.py – top-level Python driver that glues all stages together.
• Config/dependency files: .gitmodules (submodule for Luminoth), config.yml, LICENSE.
README Insights
• The pipeline has two separately trained networks:
a. Object Detector to locate each vertebra.
b. Landmark Estimator to predict four corner landmarks per vertebra.
• Post-processing includes outlier rejection and curve smoothing.
• Final step computes three Cobb angles (MT, PT, TL/L).
1. Input: Raw spinal X-ray images.
2. Object Detector Module:
• Technology: Python, Luminoth (Faster-RCNN), config.yml.
3. Landmark Detector Module:
• Technology: Python, Keras, DenseNet (Landmark_Detection).
• Input: Cropped vertebra images.
• Output: (x,y) coordinates for 4 corners per vertebra.
4. Post-processing Module:
• Outlier Rejection & Curve Smoothing.
• Technology: Python utils and/or MATLAB pre-processing.
5. Cobb Angle Calculation Module:
• Technology: MATLAB (CobbAngle_Calculation/*.m).
• Uses polyfit and slope computations.
• Output: MT, PT, TL/L angle values.
6. Evaluation & Utilities:
• Python scripts: utils/compare_angles.py, utils/smape.py.
• Jupyter Notebooks for ground truth and analysis.
7. Orchestration:
• TestAll.py drives the end-to-end flow.
• Raw Images → Object Detector → Vertebra BBoxes
• BBoxes → Landmark Detector → Landmark Coordinates
• Coordinates → Post-processing → Smoothed Landmark Curve
• Smoothed Curve → MATLAB Angle Calculator → Cobb Angles
• Cobb Angles → utils → SMAPE/Evaluation Metrics
• Jupyter Notebooks tap into intermediate outputs for visualization.
c. Architectural Patterns & Principles:
• Pipeline / Dataflow architecture: each stage transforms data.
• Modular separation: object detection, landmark estimation, post-processing, and evaluation are distinct modules.
• Reuse of specialized tools: Luminoth, Keras, MATLAB – each used for best-fit tasks.
d. Key Technologies & Frameworks:
• Python 3, Luminoth (Faster-RCNN), Keras (DenseNet), MATLAB.
• Configuration via YAML.
• Jupyter for prototyping.
• Utility scripts for metric calculation.