Anatomy-constrained chest X-ray pipeline: lung segmentation + two-stage heatmap regression for hemidiaphragm landmark localisation.
An open baseline for hemidiaphragm landmark localisation on chest X-rays using an anatomy-constrained pipeline (lung segmentation → two-stage heatmap regression → evaluation). This repository accompanies the manuscript "Accessible Hemidiaphragm Landmark Localisation on Chest X-Ray Images Using Deep Learning and Anatomical Constraints."
This repository implements an anatomy-constrained chest X-ray pipeline for hemidiaphragm landmark localisation. The method first segments the lung fields and then applies a two-stage heatmap regression model to localise left and right hemidiaphragm landmarks.
Figure 1. Automated pipeline for hemidiaphragm landmark localisation: U-Net-based lung segmentation followed by two-stage heatmap regression and landmark extraction.
- Anatomy-aware approach combining lung segmentation with heatmap-based landmark localisation
- Reproducible pipeline with preprocessing, training, testing, and evaluation stages
- Modular structure to plug in different backbones or training regimes
Train a segmentation model to obtain lung masks used as anatomical priors.
Prepare final CSV/metadata from masks and reference points for the heatmap stage.
Train a two-stage heatmap model to localise hemidiaphragm landmarks.
Report segmentation Dice/IoU and landmark error metrics (mean/median pixel error, PCK at fixed thresholds) with qualitative overlays.
- Training: Scripts to train a lung segmentation model
- Testing: Utilities to evaluate segmentation checkpoints and summarise metrics
- Data Preprocessing: Tools to reshape/merge CSVs and generate the final metadata for landmark training
- Training: Training entry points for the two-stage heatmap regression
- Testing: Inference/evaluation utilities for predicted landmarks and heatmaps
- Sanity checks, quick visualisations, and qualitative examples
- Please obtain data from the original sources and follow their licenses
- Prepare dataset directories and split files as required by your environment
- Example folder conventions and expected CSV fields are described in the preprocessing scripts
Post-processing was applied to improve anatomical consistency of the predicted lung masks before landmark localisation. Convex hull completion and morphological closing helped reduce segmentation artefacts and improved the reliability of the heatmap-based landmark predictions.
Figure 2. Example of post-processing effectiveness. Predicted masks and heatmaps are shown before and after post-processing, demonstrating improved anatomical consistency and reduced hemidiaphragm error.
Grad-CAM visualisations were used to inspect whether classification models relied on clinically meaningful lung regions. Although the classifier achieved high accuracy, several heatmaps showed attention outside the lung boundaries, highlighting the importance of anatomical constraints and interpretability checks.
Figure 3. Grad-CAM overlays showing model attention on segmented chest X-rays. Some predictions rely on non-anatomical or clinically irrelevant regions outside the lung boundaries.
- Dice coefficient and IoU on lung masks
- Mean and median pixel error
- PCK (Percentage of Correct Keypoints) at chosen thresholds
- Qualitative overlays and visualisations
If you use this code in your research, please cite:
@article{sert2025accessible,
title={Accessible Hemidiaphragm Landmark Localisation on Chest X-Ray Images Using Deep Learning and Anatomical Constraints},
author={Sert, E. and Azimbagirad, M. and Onah, D. and Alexander, D. C. and Jacob, J. and Aslani, S.},
journal={Submitted to IEEE ISBI 2026},
year={2025}
}📄 A machine-readable citation file is provided as CITATION.cff. Update it (and this section) with arXiv/DOI details when available.
- Code: Released under Apache-2.0
- Datasets: Not distributed; please respect original data licenses
We thank our collaborators and institutions listed in the manuscript. Ethics/compliance and funding acknowledgements are detailed in the paper.
⭐ Star this repository if you find it useful for your research!


