Imaging modalities that use a mechanically rotated endoscopic probe to scan a tubular volume, such as an artery, often suffer from image degradation due to nonuniform rotation distortion (NURD). In this paper, we present a new method to align individual lines in a sequence of images. It is based on dynamic time warping, finding a continuous path through a cost matrix that measures the similarity between regions of two frames being aligned. The path represents the angular mismatch corresponding to the NURD. The prime advantage of this novel approach compared to earlier work is the line-to-line continuity, which accurately captures slow intraframe variations in rotational velocity of the probe. The algorithm is optimized using data from a clinically available intravascular optical coherence tomography (OCT) instrument in a realistic vessel phantom. Its efficacy is demonstrated on an in vivo recording, and compared with conventional global rotation block matching. Intravascular OCT is a particularly challenging modality for motion correction because, in clinical situations, the image is generally undersampled, and correlation between the speckle in different lines or frames is absent. The algorithm can be adapted to ingest data frame-by-frame, and can be implemented to work in real time.