How does cavitary tuberculosis come about?

Most cavitary TB is a form of secondary TB, and a minority is seen in primary TB (cavitation has been reported to occur in 7%-29% of primary TB).
In those who have secondary TB, the disease develops when the TB bacilli that were latent in the lesions in the patient’s body after the initial infection reignite and proliferate. Chest imaging in patients with cavitary TB can show isolated cavities, or multiple cavities.
Untreated cavitary TB is active TB and is contagious; cured cavitary TB after regular treatment leaves a very small number of purified cavities that are not contagious.