{'fraction_non_alphanumeric': 0.030671545415411106, 'fraction_numerical': 0.011730520878174774, 'mean_word_length': 5.090670745029495, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Automated Deep Learning Analysis of Angiography Video Sequences for Coronary Artery Disease

The evaluation of obstructions (stenosis) in coronary arteries is currently done by a physician's visual assessment of coronary angiography video sequences. It is laborious, and can be susceptible to interobserver variation. Prior studies have attempted to automate this process, but few have demonstrated an integrated suite of algorithms for the end-to-end analysis of angiograms. We report an automated analysis pipeline based on deep learning to rapidly and objectively assess coronary angiograms, highlight coronary vessels of interest, and quantify potential stenosis. We propose a 3-stage automated analysis method consisting of key frame extraction, vessel segmentation, and stenosis measurement. We combined powerful deep learning approaches such as ResNet and U-Net with traditional image processing and geometrical analysis. We trained and tested our algorithms on the Left Anterior Oblique (LAO) view of the right coronary artery (RCA) using anonymized angiograms obtained from a tertiary cardiac institution, then tested the generalizability of our technique to the Right Anterior Oblique (RAO) view. We demonstrated an overall improvement on previous work, with key frame extraction top-5 precision of 98.4%, vessel segmentation F1-Score of 0.891 and stenosis measurement 20.7% Type I Error rate.


I. INTRODUCTION
C ORONARY artery disease (CAD) was responsible for 18.1% of deaths in Singapore in 2018 [1]. Plaque buildup in the coronary arteries impedes blood flow and affects oxygen supply to the heart, which may cause chest pain and even heart attacks. Coronary angiography is a widely used and increasingly common interventional procedure used to assess the coronary arteries for potential plaque obstruction [2]. An iodinated radiopaque contrast agent is injected into the coronary arteries via a catheter, followed by a fluoroscopy scan that acquires a multi-frame video sequence. Due to the 2D nature of X-ray projections, scans are typically acquired from various angles to obtain more comprehensive visualization.
The interpretation of coronary angiograms requires specialized training and substantial experience in interventional cardiology, and can be time-consuming. As a limited amount of contrast agent dissipates in the vessels, only a limited portion of each fluoroscopy video offers image frames of sufficient quality ("key frames"). These are the frames that display the complete blood vessel of interest with high contrast, allowing cardiologists to make assessments on the degree of plaque obstruction (stenosis). The procedure can have substantial variation in key frame selection, as well as fluctuations in image contrast or visibility due to device angular placement or biological variations [3]. Also, the current reliance on a physician's visual assessment of angiograms is susceptible to inter-observer variability; the same video interpreted as 50% stenosis by one physician might be interpreted as 70% by another [4]. A study of general cardiologists performing angiographic assessments reported a 95% confidence interval of 22 percentage points [5], and even panels of experienced angiographers reading sequential angiograms taken 2 years apart reported substantial intrapanel and interpanel disagreement [6]. These challenges in angiographic reading facing both general and experienced interventional cardiologists highlight the risk of missed/unnecessary interventional treatments, and the need for an objective and automated tool that enables rapid processing and analysis of angiography video sequences. Even resource-heavy core labs staffed with professional angiographers, which are often used in clinical research and trials evaluating patient outcomes, may suffer from the same challenges.
Recent developments in image classification and segmentation with deep learning and neural networks have opened up new possibilities in medical image analysis. In this paper, we developed a deep learning-based set of algorithms for automated analysis of coronary angiography video sequences. Our 3-stage pipeline, which consisted of key frame extraction, vessel segmentation and stenosis measurement, simulated the clinical workflow and broke down the assessment process into explainable steps. By utilizing transfer learning in the evaluation of Right Anterior Oblique (RAO) angiograms, we demonstrated the generalizability of image features between different angiographic views.

II. RELATED WORK
D EEP learning is a powerful family of data-driven techniques for computer vision, and has been successfully implemented in several medical image domains. Convolutional neural networks (CNN) are a particular type of deep learning that have achieved state-ofthe-art accuracy in image classification [7], with several important design innovations such as increasing network depth (VGG) [8], adding shortcut connections between layers (ResNet) [9] and concatenating outputs from layers (DenseNet) [10]. Specifically, the U-Net, in which skip connections are added between layers, achieves a high precision in partitioning images into meaningful components, a task known as image segmentation [11]. Many studies of automated angiography analysis have employed deep learning techniques, described below.
Ongoing efforts to automate angiography video analysis can be categorized into the following tasks: key frame extraction, vessel segmentation, and stenosis measurement. For key frame extraction, classical methods include the use of image processing techniques for vessel detection, such as the Frangi filter or other edge detection algorithms [12]. These techniques are not data-driven, typically require manual parameter tuning, and show limited generalization to images of lower quality or contrast. On the other hand, [13] achieved high performance with a two-stream summarizer-discriminator CNN.
For vessel segmentation, image processing approaches include shape-and-motion-mapping [14] and active contour models [15]. Recent work employing deep learning have proposed using a multi-channel CNN [16], a combination of two CNNs processing local and global image patches [17], and a multi-channel U-Net [18]. The use of more complex U-Net architectures with DenseNet, and InceptionResNet feature backbones enables higher accuracy [19]. Most of these studies achieved a high degree of precision. However, few of them sought to apply their algorithms towards the goal of stenosis measurement.
Stenosis measurement is a crucial clinical measurement. Prior work used spatial-temporal information to track vessel width [20] and an improved Measure of Match (MoM) measurement [21]. Recently, an end-toend analysis was proposed using three CNNs, each responsible for localizing stenosis, segmentation, and comparison between normal and lesion vessel widths [22], although single-frame images (not videos) were used, and localization/segmentation accuracies were ∼70%. Instead of providing quantitative measurements, another research employed a CNN enhanced by a self-attention mechanism to localize and classify stenosis types [23].

III. METHODS
W E propose a 3-stage end-to-end pipeline: a) key frame extraction from video sequences, b) vessel segmentation on key frames, and c) stenosis measurement from segmentation masks (Fig. 1A). Stage 1 picks 5 frames with the highest vessel clarity from each video. Stage 2 performs segmentation on the chosen frames to highlight the key vascular structure. Stage 3 identifies the region of highest stenosis and calculates the percent stenosis from the segmented vessel. Our method can potentially provide end-to-end automatic stenosis measurement while allowing stage-by-stage manual interpretation of intermediate results.

A. Dataset
The coronary arteries consist of the right and left coronary artery. During angiography, images of the coronary arteries are taken at various angular projections, providing comprehensive visualization of the vessels and assessment of stenosis. In this study, we focused primarily on the right coronary artery (RCA) taken in two projections -the left and right anterior oblique (LAO and RAO). The dataset was obtained from a tertiary cardiac institution. The de-identified images of consecutive patients who underwent coronary angiography for assessment of their cardiac status were included. A summary of demographics is presented in Table I. Videos that had low contrast or visibility of vessels, or had 100% stenosis causing a substantial alteration in vessel shape were excluded. We employed a set of LAO videos for training and testing of the deep learning models, and a smaller set of RAO videos for testing. After excluding videos of exceptionally low quality, the LAO dataset comprised 102 videos with 8731 frames of size 512x512 pixels, with an average of 86 ± 22 frames per video.

B. Key Frame Extraction
Key frame extraction was implemented to select highquality frames displaying complete vessel shapes for further analysis. We employed a two-phase algorithm for the training of key frame classification models (Fig. 1B). We first trained a base model on resized 64x64 images using manually generated ground truth labels of 6533 non-key and 2198 key frames. The set of criteria for key frames consists of high vessel clarity, a clear vessel edge, and visibility of the proximal, mid and distal RCA i.e. the contrast agent has reached the crux where the RCA divides into the posterior descending and acute marginal arteries (Fig. 1C). Key frames were labeled by student research assistants (C.Z., T.V.D., H.K.) trained and supervised by an interventional cardiologist (J.Y.) and postdoctoral researcher (K.L.).
The 102 patients are split into training set and test set based on a 4:1 ratio (81 in training set and 21 in test set). The training set is further divided into 4 equal folds for cross-validation. With patient-level splitting, every nontest set patient appears exactly once in the validation set in order to prevent information leakage between training and validation sets. The model runs 500 iterations per epoch for a total of 100 epochs. In each iteration, 16 key and 64 non-key frames are processed, with each key and non-key frame augmented 7-fold and 1-fold in order to mitigate the small and unbalanced nature of our dataset (Training details see Appendix B). Upon completion of training, the classifier is tested on an unseen test set.
The base model was designed as ResNet18, using implementation from [24], which employs neural network shortcut paths for better learning [9]. Dropout layers were used to mitigate overfitting. Two convolutional layers were then added to the base model and the new model was trained on images resized to 128x128 pixels while reusing the weights of the previous phase. This method, known as progressive resizing [25], uses the base model as a global feature extractor, while the second phase preserves local information by upsizing and training on images with higher resolution. This technique also reduces the computational power required to directly train on high-resolution images. We employed a combination of neural network optimizers: RAdam, an improved Adam [26] algorithm which stabilizes training with learning rate warmup [27], and Lookahead, which reduces optimizer variance [28].
Given a single image for prediction, the model generated a score indicating the frame quality (0 -low, 1 -high). Our algorithm then selected 5 frames with the highest scores from each video sequence. In addition to a typical per-frame accuracy metric, we introduced another metric calculating the percentage of true key frames out of the best 5 ("Top-5") output frames of each video sequence (hereafter referred to as the "Top-5 Precision").

C. Vessel Segmentation
After obtaining high-quality key frames, we applied vessel segmentation on them in order to extract clear vessel shapes out of the possibly noisy backgrounds. For vessel segmentation, we implemented a U-Net model [29]. U-Net [11] is widely used in biomedical image segmentation due to its capability to preserve both global structure and local details; its shortcut connections between contracting and expanding paths facilitate feature reconstruction. Our model consisted of 5 convolutional blocks, followed by a symmetric set of 5 up-convolution blocks. Shortcuts by concatenation were introduced between each convolutional block and its corresponding up-convolution block with the same number of channels. The network took a 512x512 pixel image as input and produced a 512x512 pixel segmentation mask. The U-Net segmented the main part of the vessel i.e. the segment between the catheter-vessel junction and the bifurcation point of the RCA (Fig. 1D).
Due to the time-consuming nature of producing precise pixel-level labels for learning segmentation, we implemented semi-supervised label propagation [30]. A small subset (20%) of the whole dataset was manually labeled and a preliminary U-Net was trained using the subset. The U-Net was then used to generate approximate labels for another 20% of the dataset. The vessel masks obtained were manually and efficiently corrected, then added to the training data for a subsequent U-Net, thus further improving the approximate labels. This cycle was repeated for two more times. This procedure was used to generate segmentation labels for 2198 key frames, greatly reducing the amount of manual labor required. Data augmentation was performed to mitigate our limited data. Similar to key frame classification, U-Net training was conducted using 4-fold cross-validation, using the same train/validation/test patient cross-validation folds as before. (Training details see Appendix B)

D. Stenosis measurement
To assess the severity of stenosis, physicians typically estimate the degree of narrowing by observing variations in vessel width. Hence, we introduced a stenosis measurement algorithm as the final stage of our end-to-end pipeline. We adopted a classical approach combining image processing and geometrical analysis of the segmentation mask. First, the segmentation mask was skeletonized [31], [32] and pruned (Fig. 1E a-b) (Appendix A, Algorithm 1) to produce a centerline. Subsequently, the width of the vessel was approximated using the geometry of the vessel slope at multiple points along the smoothed centerline (Fig. 1E c-d). This type of measurement has been previously proposed for direct use on angiograms [33]; we expected it to perform more reliably on a binary mask, which has clear edge boundaries. This vessel width estimation algorithm (Appendix A, Algorithm 2), was repeated for all top-5 key frames from the same video. An estimation of percent stenosis was the quotient of two quantities: the "normal" (non-pathological) width of the vessel, and the minimum (pathological) width. We estimated the normal width by taking the average of the 30 largest point approximations of vessel width per frame. The minimum width was estimated by taking the average of the 3 lowest pixel widths, assuming that the stenosis was of a focal nature. The stenosis severity was then calculated as follows: percent stenosis = (1 − average minimum width average maximum width ) × 100%.

E. Extension to Right Anterior Oblique (RAO) View
Our three-stage pipeline is trained on data from one specific angular projection of a set of up to 9 projections in cardiology practice, namely the LAO straight projection of the right coronary artery. The Right Anterior Oblique (RAO) projection of the RCA is taken at approximately right angles to the LAO, such that the  vessel is the same but has a slightly different shape and appearance due to the orthogonal view projection. Fig.  2 shows examples of side-by-side comparisons between the two views. Given the similarities in vessel anatomy, we tested the ability of our trained classification and segmentation models that had only previously seen LAO data to also interpret RAO data. Through this extension, we examined our algorithms' capability to generalize on unseen but related data. We used a test set of 17 RAO videos with 1500 frames (1038 non-key and 462 key). Subsequent results are generated using the test set. In the first two stages of key frame extraction and vessel segmentation, the RAO videos were processed using the trained LAO model weights. For the purpose of evaluating the generalizability of our model, no additional model training on RAO data was done. In the third stage, the same stenosis measurement algorithm was used.

IV. RESULTS & DISCUSSION
T HE experiments for each stage are conducted in independent settings. Specifically, the key frames used in stage 2 and the segmentation masks used in stage 3 are ground truth labels. This is to serve as a feasibility test (proof of concept) of our proposal. Table II shows the per-frame analysis performance of our model, and the per-video Top-5 Precision metric. On a per-frame basis, we factor in the unbalanced nature of our dataset (6533 non-key vs 2198 key) by including F1-score as a metric. Moreover, in practice it is not necessary for every key frame (often up to 20 available in each video) to be correctly identified; hence the Top-5 metric is intended as a more realistic measure of whether an adequate number of key frames (5 as a convenient threshold) may be identified per video. We observe that the metric adopted by previous work such as Frangi Filter and Edge Detection [12] is different (the percentage of videos whose output contains at least 1 key frame) from top-5 precision, and is hence not a suitable basis for comparison. The apparent improvement demonstrated by our top-5 precision illustrates the robustness of data-driven approaches such as deep learning.

A. Key Frame Extraction
The model performance was partly hindered by "noisy" ground truth labels due to inter-observer variations among our human readers, especially on frames that occurred on the margin of the contrast-enhanced time period in each video. We observed that some of these errors could be "corrected" by the trained model; a key frame erroneously labeled as non-key in manual labeling could be detected by the model, giving the frame a high score; similarly, a non-key frame with incomplete vessel shape erroneously labeled as key frame was detected and given a low score (Fig. 3B).
Since the algorithm was trained on individual frames and analyzed frames one at a time, we did not incorporate temporal information that may provide additional information to the machine learning; alternate designs of convolutional networks incorporating time-series data could be investigated in the future. Nevertheless, our per-frame analysis could reconstruct the temporal relationship within video sequences, where predicted scores showed a characteristic curve (Fig. 3A), as key frames typically cluster around the middle of a video (referred to as the "key frame region"). Frames just before, in, and right after the key frame region are highlighted, illustrating the sensitivity of the model to changes in the visibility and contrast of the vessel anatomy. Table II shows the results of our model, with F1-score as the metric, given by:

B. Vessel Segmentation
.512 truelabel (1) where prediction and truelabel are arrays representing generated and ground-truth masks respectively. Our segmentation model can localize heart vessels with relatively high precision (Fig. 3C). Comparing the performance of our model with Yang et al. [19], our model using a similar but much smaller training dataset (102 vs 1021 patients) was able to reach a comparable result (Table. III). Our neural network architecture was also of lower complexity, requiring less computational power for training, albeit prone to errors especially near the distal RCA bifurcation (Fig. 3E). More complex U-Net architectures and more training data will improve the performance in these difficult areas.

C. Stenosis Measurement
In predicting the stenosis, our algorithm provides the percent stenosis and approximate position of the most severe obstruction (Fig. 3F). The performance of the algorithm was evaluated by comparing its predictions to cardiologists' assessments (Table II). The dataset for evaluation consists of 48 videos with available clinical assessments of the percent stenosis obtained from patients' reports. Here, we did not make a distinction between the training and test sets due to the non-datadriven nature of the algorithm, which means it operates in a "blind" manner. Quantitative metrics include Mean Absolute Error (MAE) and Standard Deviation of Absolute Error (SD of AE).
where truevalue and prediction represent the true clinical assessment of the percent stenosis and machine prediction of the percent stenosis respectively, and n represents the total number of patients. As part of additional qualitative analysis, we also obtained the accuracy for detecting severe and moderate stenosis of the algorithm by binarizing the percent stenosis at the 70% and 50% thresholds as per typical clinical practice for significant lesions and moderate lesions respectively [35]. Patients whose percent stenosis are classified as severe lesions are highly recommended to undergo interventionist surgical procedures to restore normal blood flow, while those with moderate lesions are rated on a case-by-case basis by cardiologists. Our model's performance surpasses the MWCE-End-to-End model [22] but misses the 12feature classifier [34] by a 4.5% margin (Table III). The algorithm relies on simple geometrical relationships to compute percent stenosis, which is intuitive and analogous to human readings. However, its simplicity may have led to a relatively large error margin (15.9% ± 13.3%). Firstly, stenoses in the most severe cases such as complete or near-complete (99%) occlusions were underestimated or missed out due to the algorithm's inability to detect "invisible" vessels i.e. vessels that the contrast agent was unable to reach. Secondly, the model sometimes performed poorly in identifying lesions at the early proximal and late distal segments due to errors in the skeletonization algorithm. Furthermore, this algorithm considers the vessel's maximum width as the reference width, but other options such as local maxima proximal to lesions are also available and can be more intuitive to cardiologists [21], [36].

D. End-to-end pipeline
We developed an end-to-end tool in a prototype software interface that integrates our machine models and algorithms. The software takes in an angiography video as input, and performs analysis, after which the user may navigate the results of key frame extraction, vessel segmentation, and stenosis measurement. The software took approximately 30 seconds for an end-to-end analysis. We believe that this class of automated tools can serve to assist cardiologists in their diagnoses, as well as rapidly generate repeatable and objective measurements on large datasets in a high-throughput fashion.
While our goal was to demonstrate the feasibility of such a multi-stage algorithm, we assessed the performance of each of the three analysis stages separately. The segmentation algorithm was trained and evaluated using all key frames, rather than key frames selected by the key frame classifier. Similarly, the stenosis measurement algorithm was evaluated on all ground truth segmenta- tion masks, rather than actual U-Net predictions. This allowed us to objectively evaluate the algorithmic performance of each stage and compare our results to prior studies, but did not reflect true end-to-end performance.

E. Extension to Right Anterior Oblique View
Key frame extraction and vessel segmentation performance evaluation on LAO and RAO data are presented in Table IV. A slight dip in performance is seen using the RAO view in comparison to LAO, which can be attributed to the fact that the models were intially trained on LAO data. However, results on RAO are remarkably robust, indicating that the trained models have some generalizability to vessels with similar anatomical structures. Segmentation F1-score for the RAO view also did not dip significantly. The predicted masks delineated the RCA vessel structures clearly and included appropriate endpoints at their distal bifurcations (Fig. 3D), which were landmarks learned from LAO labels. Further finetuning of the models on a moderate amount of true RAO labels can greatly boost performance if required.
As a preliminary exploration of how automated measurements of a given lesion from different views may be aggregated, we performed manual visual comparisons between the identified stenosis positions of lesions in LAO and RAO views (Fig. 3G). The algorithm could identify the correct location of the most severe blockage in nearly all videos (14/15 patients). The automatically boxed regions highlighting the most severe stenosis in the LAO and RAO views correspond to each other.
The algorithm evaluates the most severe obstruction in a given view; different views highlight different segments of the vessel, and thus this aggregation of observations from multiple views is expected to improve the accuracy of the prediction, and simulating a cardiologist's practice. We suggest using the higher percent stenosis of the two predictions retrieved from the LAO and RAO views i.e. Max(LAO, RAO). To validate this concept, a subset of 15 patients (test set) with both LAO and RAO readings was used. Using Max(LAO, RAO) gave 12.0 % ± 9.1 % as MAE ± SD of AE. The correct detection rate of the stenosis at the 70% thresholds was 73.3%, reaching 100% at the 50% threshold.
The extension to the RAO view provides inspiration for further research. Future work include expansion to more views such as the anterior-posterior (AP) Cranial view to visualize the more distal vessel segments. Leveraging information from individual views and combining them in an optimal way will improve our model's accuracy. The ability to integrate information from multiple views will be even more critical as we continue work on the left coronary artery, which has a more complex vessel architecture studied from up to 6 view projections.

V. CONCLUSION
We developed a set of algorithms designed as an integrated end-to-end automated tool for analyzing angiography video sequences. Automating the analysis of coronary angiograms could assist cardiologists with visual assessment and report generation of these angiograms, while mitigating inter-observer variability and preventing unnecessary stenting. The capability to process large datasets in a repeatable, objective fashion could also be an important tool in clinical trials and research. Future improvements include: 1. the addition of video sequences with artefacts and near-complete occlusions (99%) into the dataset and subsequent model tuning, 2. incorporation of time-series data into the current classification model, and 3. employing a more complex stenosis measurement algorithm combining information from vessel widths proximal to lesions and other local maxima/minima features. Additionally, regression models are a possible alternative to the current non-datadriven approach utilized in stage 3. Extending these concepts to the left coronary artery and more view projections (cranial, caudal), as well as an evaluation of end-to-end performance on larger unseen datasets will be an essential component in realizing the potential for clinical translation. Ultimately, after rigorous validation by experts, these automated tools could have a role in suggesting recommendations for interventional treatment, with even more value to community or rural hospitals that may lack specialist expertise or infrastructure.
ACKNOWLEDGMENT This work is supported by the Agency for Science, Technology and Research AI and Analytics Seed Grant no. Z20F3RE003.