# Automatic Quantitative Coronary Analysis Based on Deep Learning
## 2 Materials and Methods
### Boundary-Aware Coronary Artery Segmentation  
The QCA system demands precise measurements of the vascular centerline and vessel diameter, both of which are closely tied to the boundary information of the segmentation results. In the past, segmentation models primarily focused on achieving high accuracy of the overall regions being segmented, but in order to obtain more accurate diameter information, BasNet was implemented as the coronary artery segmentation model. The whole architecture of BasNet includes a prediction module and a refinement module, representing a process from coarsening to refining with the purpose of capturing both high-level global information and low-level detailed information (Figure 3). The predict module is an encoder-decoder network similar to U-Net [35] that learns predictive feature maps from input images. In order to reduce overfitting, each layer of the decoder is supervised by ground truth. To further capture global information, bridge stages are added between the encoder and decoder. The refinement module is a simpler encoder-decoder module that refines coarse maps obtained by the prediction module. The refinement process learns the differences between coarse maps and the ground truth by analyzing residual blocks. Eight side outputs were supervised in the architecture, including seven side outputs in the prediction module and one side output in the refine module. The overall loss is the weighted sum of the eight losses. \[\mathrm{L}=\sum_{k=1}^{K}\alpha_{k}\mathrm{I}^{(k)} \tag{1}\]  
For each loss function of every side output, it contains three types of different losses. On the pixel level, the binary cross entropy loss (BCE Loss) [36] is conducive to the convergence of all pixels, ignoring the label of surrounding pixels, which is the most common loss function in segmentation tasks. The BCE Loss function is shown as follows, where G(r,c)\(\in\)(0,1) represents the true value in row r and column c, and S(r,c) represents the predicted value. \[\mathrm{L}_{\mathrm{bce}}=-\sum\
olimits_{(r,c)}[\mathrm{G}\left(\mathrm{r}, \mathrm{c}\right)\log(\mathrm{S}(\mathrm{r},\mathrm{c}))+(1\ -\ \mathrm{G}\left(\mathrm{r},\mathrm{c}\right))\log(1\ -\ \mathrm{S}(\mathrm{r},\mathrm{c}))] \tag{2}\]  
On the patch level, the structural similarity (SSIM) loss [37] could enhance the relationship of each pixel and the local patch, which helps to strengthen the loss value in edge parts of the object and suppress nonedge information. Therefore, the algorithm can pay more attention to the marginal details of the interested vessels. The SSIM loss function is shown as follows, where \(\mu_{x}\), \(\mu_{y}\) and \(\sigma_{x}\), \(\sigma_{y}\) represent the mean and variance of x and y, \(\sigma_{xy}\) is the covariance of x and y, while C\({}_{1}\) and C\({}_{2}\) are constants to avoid the case of a denominator equal to 0. In general, C\({}_{1}\) = (K\({}_{1}\)/L)\({}^{2}\), C\({}_{2}\) = (K\({}_{2}\)/L)\({}^{2}\), where K\({}_{1}\) = 0.01, K\({}_{1}\) = 0.03, and L = 255 is the maximum pixel value in the image. \[\mathrm{L}_{\mathrm{ssim}}=1\ -\ \frac{(2\mu_{x}\mu_{y}+\mathrm{C}_{1})(2 \sigma_{xy}+\mathrm{C}_{2})}{(\mu_{x}^{2}+\mu_{y}^{2}+\mathrm{C}_{1})(\sigma_{ x}^{2}+\sigma_{y}^{2}+\mathrm{C}_{2})} \tag{3}\]  
Figure 3: Architecture of BasNet for vessel segmentation. On map level, intersection over union loss (IoU Loss) [38] is used to measure the similarity of two sets, which gets the foreground more attention. The following is IoU loss, where S(r,c) and G(r,c) represent the predicted value and true value in row r and column c, respectively.