FleXray: Flexible Full-Body
X-ray Segmentation
Massachusetts Institute of Technology · Massachusetts General Hospital · Harvard Medical School
python -m pip install flexray
Abstract
We present FleXray, the first foundation model for segmenting anatomy from standard X-rays that enables quantitative radiographic analysis. Segmenting X-rays is challenging: X-rays are 2D projections of 3D anatomy, so overlapping structures—common in regions like the abdomen, pelvis, and neck—appear visually ambiguous, and differences in acquisition angle, exposure, and equipment make X-rays of the same region look markedly different. These obstacles have limited the collection of expert-labeled X-ray segmentation data, and consequently the development of general-purpose X-ray segmentation tools. FleXray is designed to segment X-rays from diverse anatomical regions, clinical environments, and acquisition settings. We train it on a label-standardized aggregation of CT and X-ray segmentation datasets, covering 62 foreground anatomical labels. From the CT data, we synthesize radiographic views spanning realistic acquisition conditions with physics-based projections. Across a wide range of held-out datasets, FleXray produces accurate segmentations and substantially outperforms existing baselines, and it supports clinical workflows such as scoliosis monitoring. We release FleXray as a one-step tool, together with its data engine and training code.
Motivation
More than 2.3 billion conventional X-ray examinations are acquired each year, yet public pixel-level annotations cover only a narrow set of views and structures. Every radiograph collapses 3D anatomy into a 2D projection: overlapping organs, variable angles, scanner settings, field of view, and patient morphology can make even the same body region look radically different.
Labeled CT volumes offer a way out. Segmented CT scans turn scarce 3D annotations into many anatomically correct 2D training views.
Method: online CT-to-DRR rendering
FleXray ray-casts labeled CT volumes into digitally reconstructed radiographs (DRRs). Geometry, framing, and per-structure attenuation vary online, so a single subject becomes a stream of distinct paired images and masks—a new view at every training step. Randomly sampled cameras expose the model to anatomy from standard and non-standard acquisition angles.
- Load the CT volume, dense native labels, and physical-space affine.
- Sample detector geometry, view angle, field of view, and anatomy-centered crops.
- Ray-cast image intensities and masks into the common model label space.
Results
Across nine real-radiograph datasets held out from training, FleXray achieves the highest macro Dice among generalist methods in every comparison (9 of 9)—covering lungs, ribs, peripheral bones, spine, and pelvis. Qualitative predictions remain coherent across variation in anatomy, field of view, image polarity, projection, and acquisition modality.
Application: scoliosis measurement
Anatomical masks can support quantitative workflows beyond segmentation itself. On the AASCE scoliosis challenge, FleXray derives vertebral endplate orientation from predicted masks and yields a measurable angle for 261 of 262 images, reaching a mean absolute error of 7.1° for the major Cobb angle. Under the same protocol, PAXray reaches 22.8° MAE and TotalSeg2D 16.4°.
Resources
The release includes inference, the training data engine, online DRR rendering, label protocols, experiment configuration, and launch tools.
Limitations
FleXray currently targets conventional, non-dental and non-mammographic radiographs. Its public output space covers anatomy rather than pathology; laterality, uncertainty estimation, and broader clinical validation remain future work. The release is intended for research use.
Acknowledgements
This work was supported by the National Science Foundation Graduate Research Fellowship Program, Quanta Computer Inc., and the NIH, with grants R01 EB033773 and S10 OD038222. Compute provided by the Massachusetts Life Sciences Center (MLSC).
Citation
If you use FleXray or build on its methods in your work, please cite the associated paper:
@software{butoi2026flexray,
title = {FleXray: Flexible Full-Body X-ray Segmentation},
author = {Butoi, Victor Ion and Gopalakrishnan, Vivek and
Guttag, John V. and Dalca, Adrian V. and Dey, Neel},
year = {2026},
license = {MIT},
url = {https://github.com/VictorButoi/FleXray}
}