Identifying Cardiomegaly, taking AI Models from Jupyter Notebooks into Real Hospitals

Taking AI Models from Jupyter Notebooks into Real Hospitals

-Rohan Kalluraya

10 June, 2024

Cardiomegaly means enlargement of the heart: the heart muscles thicken, or the chambers become enlarged. Cardiomegaly is not a disease but rather a symptom of another heart condition It is most commonly caused by coronary artery disease. Other etiologies (should we use a simple word like causes here?) include high blood pressure, hypertensive heart diseases, valvular heart diseases, congenital heart disorders, pulmonary diseases like obstructive sleep apnea, and infections like HIV and Chaga disease. Cardiomegaly reduces the heart’s efficiency and can cause congestive heart failure. Doctors prescribe treatment plans according to the condition responsible for the enlarged heart, which can be found via subsequent tests like the ECG or EKG, electrocardiogram, blood test, stress test, and others.

Several methods are used to identify cardiomegaly.



From our discussions with radiologists, we found that the diagnosis of cardiomegaly tends to be subjective. Annotations by two radiologists can lead to two different diagnoses, especially when the case is borderline. This called for an automated and objective method for detecting cardiomegaly, such as using the cardiothoracic ratio (CTR). This ratio is taken between the widest horizontal cardiac diameter and the widest horizontal thoracic diameter (measured between the inner edges of the ribs) in a chest X-ray. If this ratio crosses a certain threshold, cardiomegaly is said to be present.


Chest X-rays are either posteroanterior (PA) or anteroposterior (AP), depending on the direction in which the X-rays enter the body while taking the chest X-ray image. If they enter the chest and exit through the back, then the X-ray is PA. If they enter through the back and exit the chest, then the X-ray is AP.


In AP view, the heart is closer to the X-ray tube and appears larger in the image than it is. To keep this from inflating the CTR threshold for cardiomegaly (or to keep from having to use two different thresholds), we decided to use diameters measured only on PA view X-rays.


We thus developed two neural network models to tackle the two stages of the cardiomegaly detection problem. The first model distinguished between AP and PA view X-rays. The second model measured the cardiac and thoracic diameters from the PA X-rays to calculate the CTR.


All images in our dataset were manually annotated by drawing bounding boxes for the heart and chest. We used DenseNet-121 architecture with ImageNet weights loaded for transfer learning to build the AP/PA classification model. The second model, responsible for the identification and localization of the chest and heart by drawing bounding boxes, was a Mask RCNN with ResNet-50 backbone. COCO weights were used for transfer learning. (there is too much information here. We should not give so much. The network predicted a region of interest for each image by providing bounding coordinates for the heart and chest. These coordinates were used to determine the required diameters and subsequently the CTR. 0.50 was chosen as the cut-off CTR for cardiomegaly.





By classifying the X-rays into AP and PA view, we filtered out AP view X-rays to simplify the working of our cardiothoracic diameters model and improve its accuracy in calculating the CTR. Automatically computing CTR from PA view chest X-rays with high accuracy makes the assessment of cardiomegaly more objective and faster. We can make reporting more objective if the CTR, calculated automatically, is included in medical reports. This will also allow for serial comparison of follow-up X-rays and significantly reduce the efforts to fill-in reports and manually calculate the CTR. Report turnaround time can also be reduced. This tool is valuable in pre-anesthetic fitness where radiography is routinely deployed.


Share this

Related Posts