# Automated Hybrid Model for Detecting Perineural Invasion in the Histology of Colorectal Cancer
## 2 Materials and Methods
### Evaluation Metrics  
The performance of the trained segmentation model using pixel-wise accuracy, intersection over union (IoU), sensitivity, precision, and the F1-score was compared. All metrics are defined as follows:  
\[\text{Accuracy}=\sum p|p=g,\forall p\in\text{P},\;g\in\text{G}\]  
\[\text{IoU}=\frac{\text{G}\cap\text{P}}{\text{G}\cup\text{P}}\]  
\[\text{Sensitivity}=\sum_{i}\frac{\sum(p\,\textbf{1}\,\textbf{p}\,\textbf{=}\,i, \varphi\textbf{=}\,\textbf{1},\varphi\textbf{=}\,\textbf{1},\varphi\textbf{=} \,\textbf{1},\varphi\textbf{=}\,\textbf{1},\varphi\textbf{=}\,\textbf{1}, \varphi\textbf{=}\,\textbf{1},\varphi\textbf{=}\,\textbf{1},\varphi\textbf{=} \,\textbf{1},\varphi\textbf{=}\,\textbf{1},\varphi\textbf{=}\,\textbf{1}, \varphi\textbf{=}\,\textbf{1},\varphi\textbf{=}\,\textbf{1},\varphi\textbf{=} \,\textbf{1},\varphi\textbf{=}\,\textbf{1},\varphi\textbf{=}\,\textbf{1}, \varphi\textbf{=}\,\textbf{1},\varphi\textbf{=}\,\textbf{1},\varphi\textbf{=} \,\textbf{1},\varphi\textbf{=}\,\textbf{1},\varphi\textbf{=}\,\textbf{1}, \varphi\textbf{=}\,\textbf{1},\textbf{1},\]  
\[\text{F1}-\text{score}:\text{F1}(\textbf{precision},\;\textbf{recall})=\frac{ 2\;\textbf{precision}\;\textbf{recall}}{\textbf{precision}+\textbf{recall}}\]  
P and G denote predicted value and ground truth, respectively.  
To compare the performance of the PNI classifier, we used region-wise Accuracy\({}_{\text{R}}\), Sensitivity\({}_{\text{R}}\), Specificity\({}_{\text{R}}\), Precision\({}_{\text{R}}\), Negative Predictive Value\({}_{\text{R}}\) (NPV\({}_{\text{R}}\)), F1-score\({}_{\text{R}}\), and the area under the curve (AUC). The metrics used to evaluate the region-wise performance are defined as follows:  
\[\text{Accuracy}_{\text{R}}=\frac{\sum(\text{TP}+\text{TN})}{\sum(\text{TP}+ \text{FN}+\text{FP}+\text{TN})}\]  
Figure 2: Three representative regions of extracted PNI with ground truths (**a**,**c**,**e**) and the corresponding pixel-wise predictions (**b**,**d**,**f**). Based on the spatial arrangement of the tumors (red) and the nerves (purple), a nerve close to a tumor was classified as PNI.  
\[\text{Sensitivity}_{\text{R}}=\frac{\sum(\text{TP})}{\sum(\text{TP}+ \text{FN})}\] \[\text{Specificity}_{\text{R}}= \frac{\sum(\text{TN})}{\sum(\text{FP}+\text{TN})}\] \[\text{Precision}_{\text{R}}=\frac{\sum(\text{TP})}{\sum(\text{TP}+ \text{FP})}\] \[\text{NPV}_{\text{R}}=\frac{\sum(\text{TN})}{\sum(\text{FN}+ \text{TN})}\] \[\text{F1}-\text{score}_{\text{R}}:\text{F1}(\text{precision}, \text{recall})\ =\frac{2\ \text{precision recall}}{\text{precision}+\text{recall}}\]  
True positive, true negative, false positive, and false negative are denoted as TP, TN, FP, and FN, respectively.  
Instead of a stochastic model, a rule-based model was designed. Thus, we used a simple receiver operating characteristic (ROC) curve, which indicates that the classifier predicts PNI as positive when the distance between the tumor and the nerve is zero, and the classifier predicts PNI as negative when the distance is infinite. The confidence interval was calculated by assuming that the distribution of the AUC is similar to that of the accuracy, which is a binomial distribution of sample length and probability.