## 5 Data Processing and Artificial Intelligence Methods
### Sampling and Preprocessing  
The previous chapters highlighted that the use of rumen boluses helps in the continuous monitoring of the animals, thus helping to ensure animal welfare, to reduce the carbon footprint, and to maintain sustainable animal husbandry in general [4]. Unfortunately, developing this bolus with traditional methods is not straightforward. One of the constraints is the limited range of usable sensor modalities described above. This often means that the sensor modality used for the measurement is not optimal. One of the primary purposes of bolus developments is pH measurement; however, lifelong pH monitoring is not yet technically resolved, so it can only be applied for limited periods. Another example is that the characteristics of heart function are easiest to determine with an ECG device, which in turn cannot be used in a lifelong rumen bolus. In practice, with clever signal processing of the data series measured by a three-axis accelerometer, these characteristics (heart rate, heart rate variability, etc. [8]) can be determined. By processing acceleration values, other movement types of the animal (ruminating, general physical activity, etc.) can be separated and quantified. Since all of the mentioned signals are superimposed, determining the different values requires significantly more data-processing steps compared to the data-processing methods of the specialized sensors. This includes preprocessing the measured signals and extracting the valuable signal. Additionally, the orientation of the bolus can be arbitrary inside the rumen, which makes signal processing even more complicated, because physical effects can affect the sensor from different directions.  
A detailed description of the data processing was found for the sensor used to test for rumination by 3D acceleration measurements [7]. Data processing is a complex multistep process, with the following steps:  
* Determination of the derivative of the accelerations per axis (jerk).  
* Calculation of the resultant jerk. After this step, the main movement activities can be observed on the graph of the preprocessed values.
* Additional data-cleaning methods (variance calculation and moving average calculation). This step is required to make further processing more robust.
* Quantifying the preprocessing data with the appropriate metrics.  
These preprocessing steps are used to extract valuable data, and this is followed by special base-level determination and peak detection steps which have already prepared the actual final first-level data processing [7]. An overview of the general data-processing pathway according to acceleration data is given in [65]. It is worth noting that whether we examine rumination movements, accelerations related to heart function (personal communication), or accelerations related to animal activity, the first step in data processing is to determine the derivative function of the acceleration per axis and then the resultant calculation. The preprocessed data obtained during the measurement will usually be the input to the regression calculation or classification. Preprocessing already suggests that the measured values are difficult to interpret due to the large individual variety [5].  
The battery life of a rumen bolus does not allow continuous measurement with a high sample with any of the sensors. Communication systems suitable for a rumen bolus are even more constrained in terms of bandwidth and power source (battery life); therefore, it is not possible to transmit large amounts of data continuously. Thus, a well-chosen sampling strategy and statistically based data processing are needed. This approach increases the standard deviation of the features extracted during primary data processing, which makes it difficult to process the data and achieve the desired accuracy classification [1, 11, 49, 65, 66, 67]. These previous findings suggest that we should use an AI solution at all levels of data processing.