# STAVOS: A Medaka Larval Cardiac Video Segmentation Method Based on Deep Learning
## 3 Methods
### Metrics  
This study aims to achieve precise segmentation of target edges, and to better assess the model's segmentation performance, we adopted two evaluation metrics specified in the DAVIS dataset challenge [23], namely, \"Jaccard (J) Per-Sequence\" and \"Boundary (F) Per-Sequence\". These metrics are variations of the Jaccard Index and F-Measure, specifically designed to focus on the performance of each video sequence rather than the entire dataset.  
\"Jaccard (J) Per-Sequence\" calculates the Jaccard Index at the sequence level. The Jaccard Index (also known as Intersection over Union, or IoU) is used to measure the similarity between two sets, calculated by the ratio of the intersection to the union of the predicted segmentation region and the true segmentation region. The formula is as follows:  
\[\text{J}(A,B)=\frac{|\textit{pre}\cap\textit{mask}|}{|\textit{pre}\cup\textit {mask}|} \tag{4}\]  
where \"pre\" represents the predicted segmentation region, and \"mask\" represents the true mask segmentation region. The Jaccard Index ranges from 0 to 1, with a higher value indicating higher overlap, 0 indicating no match, and 1 indicating a perfect match. For the entire VOS dataset, we calculate the Jaccard Index for each frame in each video sequence, and the mean Jaccard Index for that video sequence represents \"Jaccard (J) Per-Sequence\". This process evaluates the model's segmentation accuracy in each video sequence, helping quantify the model's performance for each object segmentation task. Finally, the mean \"Jaccard (J) Per-Sequence\" for the entire dataset represents the overall performance of the model.  
\"Boundary (F) Per-Sequence\" is a video sequence-level segmentation performance evaluation metric, focusing on the measurement of various parameters related to the model-generated segmentation contours and the true segmentation contours, such as F-Measure, Precision, and IoU. Since F-Measure is an effective metric for measuring precision and recall, emphasizing high-quality generation of segmentation contours, this study selects F-Measure as the metric for \"Boundary (F) Per-Sequence\". The formula is as follows:  
\[\text{Precision}=\frac{|\text{pre}\cap\textit{mask}|}{|\textit{pre}|}\ \ \text{ Recall}=\frac{|\textit{pre}\cap\textit{mask}|}{|\textit{mask}|} \tag{5}\]  
\[\text{F}=\frac{2\cdot\text{Precision}\cdot\text{Recall}}{\text{Precision}+ \text{Recall}} \tag{6}\]  
The value of F ranges from 0 to 1, with a higher value indicating better contour segmentation, 0 indicating no correct identification of any positive examples and no recall of any positive examples, and 1 indicating perfect precision and recall in all situations. For each video sequence, we calculate the F-Measure between the model's segmentation contours and the true segmentation contours, evaluating the model's ability to maintain the accuracy of object boundaries in each video sequence.  
The selection of \"Jaccard (J) Per-Sequence\" and \"Boundary (F) Per-Sequence\" emphasizes a detailed assessment of each video sequence. The Jaccard Index focuses on the ratio of the intersection to the union between the segmentation results and the true segmentation, while F-Measure emphasizes the accuracy of segmentation boundaries. In this way, we can comprehensively evaluate the model's performance when dealing with dynamic scenes and changes between consecutive frames. This evaluation method helps capture the model's ability to handle dynamic scenarios and provides more targeted feedback for fine-tuning the model. Therefore, the choice of \"Jaccard (J) Per-Sequence\" and \"Boundary (F) Per-Sequence\" makes the evaluation more accurate and practically meaningful.