Doctors use imaging devices such as MRI or ultrasound to detect abscesses that are deep inside the cavity. They may also use endoscopy to visualize the problem.