## 3 Materials and Methods
### Software Features and Algorithm
#### 3.1.7 Kinematic Variables  
Among the identified and assigned animal contours, each individual's centroid (Cartesian position) is determined. Based on this Cartesian position \(x,y\) of individuals over time (video frames; \(f\)), various kinematic variables are computed in algorithm step 1.7. The distance that an animal walks during the video is tracked distance (\(td\)) (Equation (12)). Dividing \(td\) by the total time of the video, the mean velocity can be calculated. Ethoflow also calculates the maximum velocity achieved by the animal.  
\[td=\sum\limits_{i=1}^{f}\sqrt{\left(x_{i+1}-x_{i}\right)^{2}+\left(y_{i+1}-y_{ i}\right)^{2}}. \tag{12}\]  
The average angle that the individual rotated in each frame (turning angle; \(ta\)) is computed by the absolute sum of the angles (\({}^{\circ}\)) of the movement divided by the video frames (\(f\)) (Equation (13)), while the meandering (the average angle that the individual rotated during the video; \(M\)) is divided by tracked distance (\(td\)) (Equation (14)); the angle of the movement is the arctangent of the locomotion in planes \(y\) (\(\Delta y_{i}\)) and \(x\) (\(\Delta x_{i}\)).  
\[ta=\frac{1}{n}\sum\limits_{i=1}^{f}\left|\left(\frac{arctan\left(\frac{\Delta y _{i}}{\Delta x_{i}}\right)180}{\pi}\right)\right|. \tag{13}\]  
\[M=\frac{1}{td}\sum\limits_{i=1}^{f}\left|\left(\frac{arctan\left(\frac{ \Delta y_{i}}{\Delta x_{i}}\right)180}{\pi}\right)\right|. \tag{14}\]  
The movement of individuals is categorized based on the user-defined values. When defining the analysis protocol, the user defines the thresholds for low (\(tl\)) and high movement (\(th\)). Thus, considering the movement of individuals in each frame as \(m\!f\): \(m\!f\leq tl\) is counted as resting (the time associated with no activity of the individual); \(tl<m\!f\leq th\) is counted as mean movement (the time in intermediated activity); \(m\!f>\!th\) is counted as fast movement (the time in high activity). The sum of these counts is divided by the frames per second (\(f\!ps\)) used to sample the video to obtain these values in time.  
The user also sets a threshold for interaction (\(ti\)). The interaction is considered when the individuals approach a distance \(\leq ti\). The sum of all interactions of an individual is defined as centrality. The network density (\(nd\)) is a measurement associated with group interaction (Equation (15)). A network is a set of items in which the vertices are defined as nodes (\(n\)), and the connections among them are defined as edges (\(m\)) [34]. Here, the nodes are the individuals, and the edges represent the number of interactions among them.  
\[nd=\frac{2m}{n(n-1)}. \tag{15}\]If the user defines a region of interest (_ri_), Ethoflow computes how long the individuals stayed inside this region, considering the position (coordinates \(x,y\)) of each individual in the video frames (_f_):  
\[\sum_{i=1}^{f}(x_{i},y_{i})\in\textit{ri}. \tag{16}\]  
Considering the direction unit (_u_) of the individuals (_i_), the proportion of the group polarized (_p_) at each frame is calculated as  
\[p=\frac{1}{i}\left|\sum_{j=1}^{i}u_{j}\right|. \tag{17}\]  
The angular momentum (rotate; _r_) for each frame is a cross product (or vector product; \(\times\)) between the distance (_d_) of an individual to the center of mass of the group and the direction of movement (_u_):  
\[r=\frac{1}{i}\left|\sum_{j=1}^{i}u_{j}\times d_{j}\right|. \tag{18}\]  
These parameters provide information on the global structure of the group [35], such as how much individuals are aligned in a group (polarization; _gp_), how much the group displays low directional alignment between neighboring individuals (swarming; _gs_), and how much the group moves around its center of mass (milling; _gm_). The sum of these counts is divided by the _fps_ to obtain these values in time:  
\[gp=\frac{\sum\ p>0.65\ \text{and}\ r<0.35}{fps}, \tag{19}\]  
\[gs=\frac{\sum\ p<0.35\ \text{and}\ r<0.35}{fps}, \tag{20}\]  
\[gm=\frac{\sum\ p<0.35\ \text{and}\ r>0.65}{fps}, \tag{21}\]