Abstract
Lung segmentation in x-rays is a critical step for automated clinical diagnosis and severity grading of various pulmonary diseases. Lung segmentation from premature chest x-rays is particularly challenging due to tiny size of lungs, variability of anatomical presentations, and presence of radiological artifacts. We propose a two-step deep learning based method for lung delineation: we first perform lung detection, which is followed by segmentation of the retro-cardiac lung region. We finetune a segmentation model (UNETR) using pediatric (407 images) and premature (193 images) cohorts with a weighted loss. The model is first pretrained on a large chest x-ray data (∼31,000 scans). Our proposed strategy accurately segments lungs in both pediatric and premature x-rays with a mean Dice score of 0.960 and 0.946, and a mean Hausdorff distance of 6.576 and 8.124 pixels respectively.
Index Terms: Lung segmentation, chest x-rays, premature infants, bronchopulmonary dysplasia (BPD), deep learning
I. Introduction
Treatment for premature infants is critical and delicate due to their vulnerable, highly variable, and underdeveloped systems, particularly the respiratory system. Premature infants often experience respiratory distress syndrome (RDS), bronchopulmonary dysplasia (BPD), and apnea of prematurity (AOP) [1]. Among these, BPD is a chronic lung condition that affects more than 45% of premature births. It can be caused by neonatal RDS as well as delayed lung development [2], leading to significant long-term pulmonary, cardiovascular, and neurological conditions. BPD is further associated with longer hospitalization and rehospitalization, somatic underdevelopment, and socio-economic burdens [3].
An important topic of research in pediatric healthcare is risk stratification and prediction of disease severity, which can inform clinical decision making. In the case of BPD, a timely and accurate diagnosis assists the clinicians in the management of early and evolving BPD by using a fitting combination of preventative and therapeutic techniques such as the use of supplemental oxygen, early respiratory support with surfactant administration, caffeine, nutritional support, and postnatal steroids [4]. Lung segmentation from chest x-rays can greatly benefit disease diagnosis and grading for conditions such as BPD.
Neonatal chest x-rays are unique and highly dissimilar from adults or even pediatric chest x-rays (see figure 1) as the lungs occupy only a tiny portion of the premature chest radiograph. Unlike adults, pediatric chest x-rays have higher variability—lungs are often smaller and triangular with elevated diaphragms and larger cardiac contours [5]. Even within the pediatric population, anatomy differs greatly depending on the developmental stage of the child. For example, lung imaging differs among premature babies, healthy newborns, infants, and children aged 3 or more.
Fig. 1.
Examples of chest x-ray images for premature (left), pediatric (middle), and adult (right) population.
Candemir et al. [6] discussed the differences among the presentation of lungs in radiographs at different ages and highlighted the need for age-sensitive lung segmentation algorithms. Moreover, pediatric chest x-rays are often noisier than adult ones due to the potential for irregular body pose as well as a child being held by a caregiver at the time of imaging [7]. These variations and size restrictions in premature chest x-rays make lung segmentation a prerequisite task to clinical diagnosis.
There are many existing deep learning methods in literature that accurately detect and segment lungs from a chest x-ray and fail to accurately segment pediatric data [7]–[9]. Mansoor et al. [10] combined statistical shape modeling with deep learning to perform lung field segmentation in a pediatric dataset with 92% accuracy. Reamaroon et al. [11] developed a total variation-based active contour lung segmentation algorithm and compared it to a U-Net-based methods. In the case of pediatric imaging, an average Dice coefficient of 0.85 and 0.87 was reported for their method and U-Net respectively. Recently, a transfer learning-based study [12] achieved a Dice score of 0.91 for lung segmentation, leading to a 0.95 precision in pneumonia diagnosis in children.
Despite recent advances, there is a need for specialized diagnostic and lung segmentation tools which are specifically designed for the premature population. Accurate delineation of lungs from chest x-rays will facilitate early intervention and provide support for clinical decision-making. Towards this, we propose to perform premature lung delineation in two steps: 1) lung region of interest (ROI) detection, since a direct segmentation of lungs does not work well for premature infant x-rays, and 2) lung segmentation within the ROI from step 1. Our proposed method provides a complete end-to-end solution for pediatric and premature lung segmentation. The method is unique and allows accurate lung segmentation for premature infants, a domain where automated methods are scarce. This method generalizes lung segmentation across different age groups. We further segment the anatomically correct regions of the lung including the retro-cardiac portion, which is overlooked in methods presented in literature.
Our contributions are:
1) we leverage state of the art object detector for detecting a region of interest for lung segmentation in premature babies, 2) we adopt a large-scale deep learning model utilizing self-supervised learning to achieve state of the art performance in lung segmentation for premature babies.
II. Methods
In contrast to adult or some pediatric chest x-rays, premature x-rays exhibit variations in lung orientation, shape, size, and often include abdominal regions, wires, tubes, and parts of medical equipment. As such, direct application of methods developed for standardized adult scans are not applicable. We design a method employing a two-stage strategy to mitigate these differences. The first stage is to detect a bounding box ROI, around the lung region from an x-ray, and the second stage is to segment the lungs within that region. Prior to segmentation via UNETR [13], we also employed self-supervised pretraining on a large-scale adult chest x-ray data to enhance our segmentation output. Figure 2 depicts a brief overview of our proposed method for pediatric and premature lung segmentation.
Fig. 2.
Workflow diagram – Pediatric and premature chest x-ray datasets are employed to train deep learning algorithms for lung detection and segmentation.
A. Data
In this study we utilize two distinct chest x-ray datasets, both acquired in-house at Children’s National Hospital, Washington, DC. Dataset A consists of 407 pediatric chest x-ray scans along with the ground truths for lung masks. Dataset B consists of 193 premature chest x-ray scans and their ground truths for lung segmentation. The ground truth was established by manually segmenting the lung region including the cardiac portion. These annotations were performed by expert clinicians at the hospital. Each dataset was split as follows: 80% of images for training, 10% for the validation, and the remaining 10% for the testing/inference stage.
B. Lung ROI Detection
The lung ROI detection step is performed to acquire cropped lung regions that can serve as an input to our segmentation training and to provide standardized inputs to our segmentation network, i.e., images of the lung area, as it is typical with other pediatric (not neonatal) and adult data. We developed a YOLOv8-based lung detection algorithm using the Ultralytics package [14]. First, we generate the ground truth bounding boxes for our premature dataset by approximating a region-of-interest from the segmentation labels. We then train and finetune the YOLO model with our data. This detection algorithm accurately calculates bounding boxes around the lungs (as shown in figure 3), as well as outputs the cropped x-ray images of the pediatric/premature lung region, which are subsequently utilized for training the UNETR-based segmentation algorithm.
Fig. 3.
Examples of lung detection from premature chest x-ray images.
C. Pretraining
Given the limited availability of infant lung data, we employ a self-supervised strategy to pretrain a Vision Transformer (ViT) on a generous collection of 31,493 publicly available adult chest x-ray images [15]. Each image is subjected to random masking with white noise and zeros. The ViT encodes these masked images into a latent space, which is subsequently decoded into the image space using a lightweight linear decoder. We conduct this pretraining for 150 epochs, employing a learning rate of 1e−4 with the Adam optimizer. Then, the weights from the ViT are fed to the UNETR model, which has a transformer backbone, for initialization of the transformer weights.
D. Lung Segmentation
The implementation of our method is based on MONAI [16], a PyTorch-based open-source framework for conducting deep learning experiments in the domain of medical imaging.
We preprocess our images and apply conventional data augmentation techniques to encourage a variety of image qualities and increase the number of images available for training. We apply random operations such as rotation (up to 30◦) with bilinear interpolation and zoom (90–110%) function. We also apply color jitter, Gaussian blur, altered sharpness, and contrast adjustment to a fraction of training images. All images are subjected to intensity scaling between 0 and 1 and resized to 256 × 256 pixels.
Since we are dealing with two datasets, we designed a custom weighted loss function to prioritize premature cases (dataset B). This function scales the standard dice loss with user specified weightages. In this study, we chose a weight of 1 for dataset A, and a higher weight of 2 for the dataset B.
A UNETR model using a transformer encoder-decoder architecture [13] was finetuned in a supervised manner using both datasets. The model was initialized with the weights acquired from the pretrained self-supervised model as described in section 2.3. The training was conducted for 50 epochs with the validation being performed every five intervals. For each epoch, the model was first trained on a batch of images from training dataset A, followed by training dataset B with appropriate weighted loss function. After automated hyperparameter optimization, the training was performed using an NAdam optimizer with a learning rate of 2e−4 and a batch size of 32. During the validation phase, we use normalized and average Dice coefficient from datasets A and B as a validation metric.
E. Testing and Evaluation
The segmentation method was evaluated using the Dice coefficient. We also evaluated the contour delineation using the 95% Hausdorff distance (HD) metric and Average Surface Distance (ASD) metric (Euclidean distance). We report these metrics separately for pediatric (dataset A) and premature (dataset B) chest x-ray images. To demonstrate the generalizability of our method, we also perform lung segmentation on pediatric x-ray images provided by the PediCXR dataset [17].
III. Results
Our proposed method segmented the lungs from chest x-rays with a Dice score of 95.5 ± 0.7% and a 95% Hausdorff distance of 7 ± 0.9pixels averaged over both datasets. The distribution of evaluation metrics for pediatric (A) and premature (B) datasets can be seen in Figure 4, where the metrics’ averages are reported in Table I.
Fig. 4.
Data distribution of evaluation metrics: Dice score, 95% Hausdorff distance and Euclidean surface distance for both pediatric (A) and premature (B) training datasets. px: pixel.
TABLE I.
Average results of the evaluation metrics: Dice score, 95% Hausdorff distance and Euclidean surface distance, as evaluated on the pediatric (A) and premature (B) training datasets. px: pixel.
|
| |||
|---|---|---|---|
| Metric | Dice coefficient | Hausdorff distance (px) | Avg. surface distance (px) |
| Dataset A | 0.960 | 6.576 | 0.923 |
| Dataset B | 0.946 | 8.124 | 0.898 |
|
| |||
| Combined | 0.955 | 7.075 | 0.915 |
|
| |||
These results are statistically superior to those reported in literature [7], [11], [12] as evident by t-test analysis (Table II). Figure 5 shows a qualitative evaluation of the proposed method by comparing the segmented lung regions with the ground truth labels for both pediatric (dataset A) and premature (dataset B) chest x-rays. Moreover, the generazability of our method can be seen through the qualitative evaluation of lung segmentation performed on CXR images from the PediCXR dataset in figure 6.
TABLE II.
Comparison with state-of-the-art lung segmentation techniques designed for pediatric population.
Fig. 5.
Segmentation results from the training datasets of pediatric (A) and premature (B) chest x-ray images. Green regions represent the ground truths. Red regions represent the retro-cardiac lung as segmented by our proposed method.
Fig. 6.
Lung segmentation on PediCXR x-ray images. Red regions represent the retro-cardiac lung as segmented by our proposed method.
IV. Discussion
Lung segmentation from chest x-rays is a pre-requisite to the computer-aided detection and diagnosis of many diseases in children. Techniques developed for processing adult chest x-rays fail to translate [8]–[10] to a pediatric and premature population. This is caused by the fact that premature infants have a high degree of variability in their physical size, pathology, and radiological presentation. Thus, lung segmentation from premature chest x-rays remains a challenge–even a deep learning model with training and sufficient performance on pediatric dataset drastically fails to handle chest x-rays of premature infants (see Figure 7).
Fig. 7.
Top row: Incorrect lung segmentation output from a UNETR model trained only on pediatric cases (dataset A). Bottom row: Accurate lung segmentation from our method.
In the proposed solution, we used a ViT which typically requires extensive training resources, where pediatric chest x-ray datasets are uncommon. Therefore, we have included adult chest x-rays as well in our pretraining of the self-supervised model. The pretraining on adult chest x-rays has clear indications of improved performance in the case of pediatric and premature lung segmentation. We experimented with finetuning the UNETR with weights derived from (a) pretraining on adult chest x-ray dataset, (b) no pretraining dataset, and (c) pretraining on ImageNet dataset. Figure 8 shows a comparison between these methods as evaluated by the Dice score and Hausdorff distance observed for our testing dataset. Pretraining with adult chest x-rays not only enhances the Dice score but also reduces the Hausdorff distance error from 9.5 to 7 pixels on average.
Fig. 8.
Comparison between different pretraining strategies, evaluated using Dice score and Hausdorff distance.
V. Conclusion
Lung segmentation in chest x-rays is a well-researched topic for adult patients. However, results from adult data are not directly translatable to pediatric population, especially premature infants with different anatomical and radiologic presentation. In this work, we presented a method to accurately segment the lung (including the retro-cardiac region) from premature, neonatal, and pediatric chest x-rays. We demonstrate that generic models fail to translate for premature x-rays and that self-supervised pretraining enhanced the segmentation outcomes. To the best of our knowledge, this is the first study that is designed for premature lung segmentation, paving a way towards precise diagnosis and grading of pulmonary diseases in premature infants such as BPD, pneumonia, and RDS among others.
Acknowledgment
The authors would like to thank Dr. Hector Aguilar (Children’s National Hospital, DC) for assisting in data collection.
This work was supported by NIH NHLBI award R42 HL145669
Contributor Information
Hareem Nisar, Sheikh Zayed Institute for Pediatric Surgical Innovation, Children’s National Hospital, Washington, DC, USA.
Syed Muhammad Anwar, Sheikh Zayed Institute for Pediatric Surgical Innovation, Children’s National Hospital, Washington, DC, USA.
Maria C. Rujana, Division of Pulmonary and Sleep Medicine, Children’s National Hospital, Washington, DC, USA
Abhijeet Parida, Sheikh Zayed Institute for Pediatric Surgical Innovation, Children’s National Hospital, Washington, DC, USA.
Gustavo Nino, Division of Pulmonary and Sleep Medicine, Children’s National Hospital, Washington, DC, USA.
Marius George Linguraru, Sheikh Zayed Institute for Pediatric Surgical Innovation, Children’s National Hospital, Washington, DC, USA.
References
- [1].Thébaud B, Goss KN, Laughon M, Whitsett JA, Abman SH, Steinhorn RH, Aschner JL, Davis PG, McGrath-Morrow SA, Soll RF, and Jobe AH, “Bronchopulmonary dysplasia,” Nature Reviews Disease Primers, vol. 5, p. 78, 11 2019. [Google Scholar]
- [2].Li R and Zhang J, “Diagnostic value of chest ct combined with x-ray for premature infants with bronchopulmonary dysplasia,” Medicine, vol. 97, p. e9723, 3 2018. [DOI] [PMC free article] [PubMed] [Google Scholar]
- [3].Chioma R, Sbordone A, Patti ML, Perri A, Vento G, and Nobile S, “Applications of artificial intelligence in neonatology,” Applied Sciences, vol. 13, p. 3211, 3 2023. [Google Scholar]
- [4].Gilfillan M, Bhandari A, and Bhandari V, “Diagnosis and management of bronchopulmonary dysplasia,” BMJ, vol. 375, p. n1974, 10 2021. [DOI] [PubMed] [Google Scholar]
- [5].Arthur R, “Interpretation of the paediatric chest x-ray,” Paediatric Respiratory Reviews, vol. 1, pp. 41–50, 3 2000. [DOI] [PubMed] [Google Scholar]
- [6].Candemir S, Antani S, Jaeger S, Browning R, and Thoma GR, “Lung boundary detection in pediatric chest x-rays,” Cook TS and Zhang J, Eds., vol. 9418. SPIE, 3 2015, p. 94180Q. [Google Scholar]
- [7].Candemir S and Antani S, “A review on lung boundary detection in chest x-rays,” International Journal of Computer Assisted Radiology and Surgery, vol. 14, pp. 563–576, 4 2019. [DOI] [PMC free article] [PubMed] [Google Scholar]
- [8].Agrawal T and Choudhary P, “Segmentation and classification on chest radiography: a systematic survey,” The Visual Computer, vol. 39, pp. 875–913, 3 2023. [DOI] [PMC free article] [PubMed] [Google Scholar]
- [9].Rajaraman S, Yang F, Zamzmi G, Xue Z, and Antani S, “Can deep adult lung segmentation models generalize to the pediatric population?” Expert Systems with Applications, vol. 229, p. 120531, 11 2023. [DOI] [PMC free article] [PubMed] [Google Scholar]
- [10].Mansoor A, Cerrolaza JJ, Perez G, Biggs E, Nino G, and Linguraru MG, “Marginal shape deep learning: applications to pediatric lung field segmentation,” Styner MA and Angelini ED, Eds., vol. 10133. NIH Public Access, 2 2017, p. 1013304. [Google Scholar]
- [11].Reamaroon N, Sjoding MW, Derksen H, Sabeti E, Gryak J, Barbaro RP, Athey BD, and Najarian K, “Robust segmentation of lung in chest x-ray: applications in analysis of acute respiratory distress syndrome,” BMC Medical Imaging, vol. 20, p. 116, 12 2020. [DOI] [PMC free article] [PubMed] [Google Scholar]
- [12].Fernandes V, Bras G, e Paiva L. F. d, Junior GB, e Paiva A. C. d, and Rivero L, “Transfer learning-based lung segmentation and pneumonia detection for paediatric chest x-ray images,” International Journal of Innovative Computing and Applications, vol. 14, p. 56, 2023. [Google Scholar]
- [13].Hatamizadeh A, Tang Y, Nath V, Yang D, Myronenko A, Landman B, Roth HR, and Xu D, “Unetr: Transformers for 3d medical image segmentation,” Proceedings - 2022 IEEE/CVF Winter Conference on Applications of Computer Vision, WACV 2022, pp. 1748–1758, 3 2022. [Google Scholar]
- [14].Jocher G, Chaurasia A, and Qiu J, “Yolo by ultralytics,” 1 2023. [Google Scholar]
- [15].Anwar SM, Parida A, Atito S, Awais M, Nino G, Kitler J, and Linguraru MG, “Spcxr: Self-supervised pretraining using chest x-rays towards a domain specific foundation model,” 11 2022. [Google Scholar]
- [16].Cardoso MJ, Li W, Brown R, Ma N, Kerfoot E, Wang Y, Murray B, Myronenko A, Zhao C, Yang D, Nath V, He Y, Xu Z, Hatamizadeh A, Zhu W, Liu Y, Zheng M, Tang Y, Yang I, Zephyr M, Hashemian B, Alle S, Darestani MZ, Budd C, Modat M, Vercauteren T, Wang G, Li Y, Hu Y, Fu Y, Gorman B, Johnson H, Genereaux B, Erdal BS, Gupta V, Diaz-Pinto A, Dourson A, Maier-Hein L, Jaeger PF, Baumgartner M, Kalpathy-Cramer J, Flores M, Kirby J, Cooper LAD, Roth HR, Xu D, Bericat D, Floca R, Zhou SK, Shuaib H, Farahani K, Maier-Hein KH, Aylward S, Dogra P, Ourselin S, and Feng A, “Monai: An open-source framework for deep learning in healthcare,” 11 2022. [Google Scholar]
- [17].Pham HH, Nguyen NH, Tran TT, Nguyen TNM, and Nguyen HQ, “Pedicxr: An open, large-scale chest radiograph dataset for interpretation of common thoracic diseases in children,” Scientific Data, vol. 10, no. 1, Apr. 2023. [Google Scholar]








