# Detection and Model of Thermal Traces Left after Aggressive Behavior of Laboratory Rodents
## 3 Data Analysis Methods
### Temporal Analysis  
The goal of temporal analysis was the observation of interesting points temperature changes in time.  
The Harris corner detector with a filter size equal 5 and a minimum accepted quality of corners set to 0.000001 was used for the simulated image sequences. The low accepted quality value requirement was caused by the lack of a clear trace border, which was neither observed in the real recordings. The final algorithm of identification saliva trace among all detected corners should include the following steps:  
1. computing the significance of corners using a specific measure, e.g., R score or ranking--rejection of irrelevant points,
2. elimination of corners that do not meet certain conditions: e.g., temperature value within a certain range, location on the animal's body, and
3. prediction of trace localization based on the animal's displacement vectors from previous frames.  
Here, a simplified detection algorithm has been adopted, because the research is aimed at checking the possibility of finding the trend of temperature changes for incomplete observations and not the detection itself. The saliva trace detection in this work has the advantage that the exact location of the simulated trace is known. It consists in searching for a corner at a certain distance from the known simulation place. Setting the search area instead of the exact location of the trace allows for detection similar to the real one, when another point with a large gradient (object boundary, body parts with extreme temperature) located a close distance from the trace is detected with better score.  
The generated traces of saliva were applied to the objects during movement simulation and, therefore, may be incomplete as a result of covering one body by another. Here, we introduce a length ratio (\(LR\)) which is defined as the ratio of the time period within which the saliva trace was detected to the time period when the saliva trace was simulated:  
\[LR=\frac{\text{time period of the detected saliva trace}}{\text{time period of the simulated saliva trace}} \tag{2}\]  
Here, both periods are measured in the number of frames. Time period of detected trace determines the time the trace was visible to the corner detector. The period of time for the simulated data is equal 27 frames (see Figure 4).  
The bite action always takes place during close contact, and often the trace can be spotted only when animals move away from each other. This makes the exact moment of the bite very hard to notice when observing the interaction of animals in the visible light frequency. A fading trace of saliva left on the fur is an evidence of being bitten or groomed. The curve fitted to the corner temperature measurements would additionally allow to calculate the exact moment of these actions.  
For each measurement of the detected corners we have applied the curve fitting procedure. It was followed by the coefficient of determination (\(R^{2}\)) calculation between the measures (fitted curve) and the simulated polynomial function.The definition of the coefficient of determination is  
\[R^{2}=1-\frac{SS_{res}}{SS_{tot}} \tag{3}\]where \(SS_{res}=\sum_{i}(y_{i}-f_{i})^{2}\) is the residual sum of squares, \(y_{i}\)--measurements, \(f_{i}\)--modeled values, \(SS_{tot}=\sum_{i}(y_{i}-\overline{y})^{2}\) is the total sum of squares, \(\overline{y}\)--mean of the observed data.  
We have also used the Pearson correlation coefficient to measure the linear correlation between the length of the trace and the fitting quality:  
\[\rho=\frac{1}{N-1}\sum_{i=1}^{N}\left(\frac{\overline{y_{i}-\mu_{y}}}{\sigma_{ y}}\right)\left(\frac{\overline{f_{i}-\mu_{f}}}{\sigma_{f}}\right) \tag{4}\]  
where  
* is the number of observations, \(\mu_{y}\) and \(\sigma_{y}\) are the mean and standard deviation of measurements, \(\mu_{f}\) and \(\sigma_{f}\) are the mean and standard deviation of the modeled values.