Apparatus is described for imaging a portion of a body of a subject that moves as a result of cyclic activity of a body system of the subject and that also undergoes additional motion. An imaging device acquires a plurality of image frames of the portion. A sensor senses a phase of the cyclic activity of the body system. A control unit generates a stabilized set of image frames of the portion by identifying a given phase of the cyclic activity, and outputting a set of the image frames corresponding to image frames of the portion acquired during the given phase, and by image tracking at least the set of image frames to reduce imaged motion of the portion associated with the additional motion. A display displays the stabilized set of image frames of the portion. Other embodiments are also described.