## 4 Discussion  
In this study, we demonstrated an approach to estimating heart rate in Danionella larvae using a frame-differencing algorithm applied to video recordings. By extracting a fixed region of interest (ROI) around the visible cardiac area and analyzing luminance fluctuations between consecutive frames, we were able to detect periodic motion patterns corresponding to cardiac contractions. The optimal parameters are relatively robust because they capture the main heart movements, even if the ROI is slightly off-center, as long as it covers the entire heart. However, if the ROI is significantly off-center, noise increases and accuracy decreases. This technique, when paired with binary thresholding, effectively transformed subtle movements of blood flow into quantifiable image features. One of the major strengths of this method lies in its simplicity and accessibility. The rhythmic increase in white pixel count--indicating heartbeat--was reliably detected across different time segments in the video. The average relative error is approximately 12.74%, indicating that the heart rate estimation system performs reasonably well, although there are some cases with larger individual errors (up to 25.97%). The parameter set with diff_threshold = 13 and movement_count \(\geq\) 1 px yielded the best results for three of the four fish, suggesting this as a reliable baseline setting. The system could capture physiological variability, and these estimates were validated against manual counting using a handheld counter, which served as the gold standard in this study. The high degree of visual and quantitative agreement between the two methods supports the validity of our algorithm. Heart rate monitoring in the zebrafish cardiovascular system has traditionally been performed manually (using a stopwatch) to count heartbeats. However, these methods are labor-intensive, time-consuming, and require specific training to execute. As a result, several automated measurement techniques have been developed [16, 17, 18]. Many of these methods detect changes in active pixels between frames, defining the heart region as an area and detecting heartbeats within the frame. However, these detection software tools are commercially available, and some are difficult to implement [19, 23, 24, 25]. Compared to these existing methods, our proposed approach offers a more accessible and practical solution. For example, [PERSON] et al. (2018) [26] proposed an automated heart rate measurement method using digital motion analysis; that technique is the use of a half-heart mask  
Figure 4: The relative errors in the estimated heart rate compared to the visual heart rate when the brightness threshold and the threshold for the sum of white pixels are changed. Orange: movement_count \(\geq\) 1 px, Blue: movement_count \(\geq\) 2 px. combined with empirical mode decomposition (EMD) and high-pass filtering. However, their system still required relatively sophisticated image processing setups and was limited in flexibility for varying experimental conditions. While this method can effectively screen for cardiac abnormalities, it faces several limitations: the accuracy and robustness of mask generation are highly sensitive to noise and individual variability, mask creation often requires manual adjustments due to variations in lighting, heart position, and orientation, and the EMD process can become unstable, especially when low-frequency noise sources, such as respiration, overlap with the cardiac signal. Moreover, EMD is computationally intensive, which may restrict its suitability for real-time monitoring. In contrast, our method focuses on simplifying the heart rate measurement process while maintaining reasonable accuracy, reducing both technical barriers and computational demands.