Transesophageal echocardiography is similar to an upper gastrointestinal endoscopy. Different views of the heart are taken by a small, flexible instrument positioned in the esophagus (the tube that connects the mouth to the stomach). This allows doctors to create a clear picture of the heart through the wall of the esophagus rather than from outside the body through the muscles, fat, and bones of the chest wall.