Although NTM lung infections can cause lung cavities, the most common finding on imaging is bronchiectasis, which may occur with or without cavities. Mycobacterium avium complex (MAC) is the most common cause of NTM lung disease in most countries, including the United States. Classically, MAC infection results in either upper lobe cavities in male smokers with COPD or bronchiectasis in thin, older women; however, it is possible to have both cavities and bronchiectasis in the same patient. Similar to tuberculosis, the presence of cavities in MAC infection is associated with worse outcomes. Mycobacterium kansasii, Mycobacterium xenopi, and the rapidly-growing Mycobacterium abscessus have also been associated with lung cavities. Fungal
Fungal infections that can cause cavitations include histoplasmosis, coccidiomycosis, cryptococcosis, and aspergillosis. Aspergillosis, most commonly caused by Aspergillus fumigatus, can present in four different ways (listed in order of increasing severity): aspergilloma, allergic bronchopulmonary aspergillosis (ABPA), chronic necrotizing aspergillosis, and invasive aspergillosis. All of these are associated with lung cavities except for ABPA, which is a hypersensitivity response associated with bronchiectasis on imaging. An aspergilloma is an infection of a pre-existing lung cavity by Aspergillus species without tissue invasion and results in the formation of a fungal ball. Historically, tuberculosis was the most common cause of the lung cavity (and still is in areas where tuberculosis is endemic); however, the cavity can also be caused by sarcoidosis, bullae, bronchiectasis, or cystic lung disease. Chronic necrotizing aspergillosis and invasive aspergillosis are usually seen in immunocompromised people.
If symptoms or imaging findings have been present for less than three months, the cause is most likely an acute infection; if they have been present for more than three months, the cause is most likely a chronic infection, cancer, or an autoimmune disease.The presence of lung cavities is associated with worse outcomes in lung cancer and tuberculosis; however, if a lung cancer develops cavitation after chemotherapy and radiofrequency ablation, that indicates a good response to treatment. Formal definition
In the 2008 Fleischner Society "Glossary of Terms for Thoracic Imaging", a cavity is radiographically defined as “a gas-filled space, seen as a lucency or low-attenuation area, within [a] pulmonary consolidation, a mass, or a nodule”. Pathologically, a cavity is “usually produced by the expulsion or drainage of a necrotic part of the lesion via the bronchial tree.”

Lung cavity mimics
The first step in evaluating a suspected lung cavity lesion is to exclude other kinds of abnormal air-filled spaces in the lung, including lung cysts, emphysema, bullae, and cystic bronchiectasis. Lung cysts are the most common mimics of lung cavities. Cavities and cysts are similar in that they are both abnormal, air-containing spaces with clearly defined walls. The difference between cavities and cysts is that cavities are thick walled, while cysts are thin walled.