An Overview on the Use of Near Infrared Spectroscopy (NIRS) on Farms for the Management of Dairy Cows

: Dairy farming is increasingly affected by the digital revolution. To respond to current challenges—such as environmental, economic, and social sustainability—new technologies must be adopted, entering the perspective of precision livestock farming. This is made possible by the development of countless sensors to be adopted in the barn. The technology that is affecting various aspects of dairy cattle breeding is certainly near infrared spectroscopy (NIRS) which is versatile and can be used online/inline to evaluate and control the critical points of the production process by entering the PAT (process analytical technology). In the barn, NIRS currently can obtain information on the chemical-physical composition of raw materials, total mixed ration (TMR), feces and digestibility, chemical and technological analysis of milk. All this in a short time by eliminating the waiting times for analysis response and costs, allowing an improvement of livestock management. Many studies afﬁrm the validity of NIRS as a reliable and predictive technology against multiple relevant parameters in matrices such as raw feed, TMR, feces, and milk. This review highlights the usefulness of NIRS technology in dairy farm with particular attention to portable instrumentation usable directly on the farm.


Introduction
New technologies are strongly influencing the farm management, reducing manual labor, costs, and above all waste; and, consequently, increasing income. The use of innovation in the primary sector has led to the birth of a new type of agriculture, that of 'precision agriculture'. Pierce and Novak [1] defined 'precision agriculture' (PA) as "a system that provides the tools to do the right thing, in the right place, at the right time". Precision agriculture has evolved currently in agriculture 4.0, obtained through the collection, integration, and automatic analysis of data from the environment, sensors, and any other third source [2]. Due to the growing development and use of the Internet of Things (IoT) and Information and Communication Technologies (ICT), today we start talking about Smart Agriculture (SA), or Smart Farming (SF). While PA considers variability in the field, SA goes further [3].
Considering livestock sector, the so-called precision livestock farming (PLF) has developed and concerned the whole sector: from cattle to pigs, to poultry, achieving the best results in cattle farms, especially in dairy farms. Undoubtedly, dairy cattle breeding is one of the most affected by PLF, since it is possible to obtain greater profitability and improvement of animal welfare [4]. Moreover, the adoption of PLF techniques allows to produce safety food with a reduced environmental impact [5].
Results of scientific research have clearly showed that improving animal welfare is an effective tool to increase profits by reducing costs related to poor animal health [6]. Furthermore, consumers are becoming more and more focused to purchase and even spending more for animal products obtained through the satisfaction of animal welfare and protection of the environment.

1.
analysis of chemical composition of raw materials both in the field and in the loading phase of the mixer wagon; 2.
analysis of chemical and physical constituents of the TMR; 3.
analysis of TMR evaluation indices (homogeneity and selection); 4.
analysis of chemical composition of feces, slurry, and manure; 5.
on-line analysis of milk quality (total and individual) in the milking parlor.

Near Infrared Spectroscopy
Near infrared spectroscopy is a technology that uses the infrared region of the electromagnetic spectrum (from about 800 nm to 2500 nm) to investigate the physio-chemical properties of samples in a non-destructive way. Near infrared spectroscopy is a multianalytical technique that allows to predict several parameters at the same time with good precision [11]. The technique is rapid, nondestructive, precise, and cost-effective, compared with other laboratory techniques [12]. All these properties have made the NIRS technique widely accepted in recent years as one of the most used methods for online feed analysis [13].
The first instruments were extremely sophisticated and expensive and destined to the laboratory use. They provided very accurate analytical results but only specialized personnel were able to use them. Over time the instruments have evolved with a significant reduction in their size and weight, allowing the development of portable instruments. There have also been improvements in their performance due to the increase in the speed of the acquisition of spectra, improvement of the signal processing and transmission and hardware and software improvement.
Near infrared spectroscopy measurements can be collected in either transmittance, reflectance or transflection mode. The transmittance mode allows to get information on the entire volume of the sample crossed by the light, while the reflectance mode only from the surface of the sample. Transflectance mode is a combination of the two aforementioned modes, especially suitable for liquid samples such as milk [14].
Calibration is the key to successfully use the NIRS technique [15]. Accurate, robust calibration models are difficult to obtain as their construction requires the use of a large enough number of samples to include all variations of physical and/or chemical properties. Constant calibration is required to adapt devices to new measurements and sample conditions (such as chemical composition, temperature, etc.). However, once calibration curves are in place NIRS does offer a rapid and cost-effective analysis capable of screening large number of samples [16] and is easy to use. Additionally, the use of daily device diagnostics is required to guarantee consistent and accurate results [17]. One limitation of this technique is the low sensitivity for the prediction of mineral content since there is no mineral absorption in the near infrared spectrum region. An alternative way to solve this problem is to combine different detection techniques with NIR spectroscopy, such as Xray fluorescence spectroscopy, UV light, and the electronic nose technique [13].

Near Infrared Spectroscopy
Near infrared spectroscopy is a technology that uses the infrared region of the electromagnetic spectrum (from about 800 nm to 2500 nm) to investigate the physio-chemical properties of samples in a non-destructive way. Near infrared spectroscopy is a multianalytical technique that allows to predict several parameters at the same time with good precision [11]. The technique is rapid, nondestructive, precise, and cost-effective, compared with other laboratory techniques [12]. All these properties have made the NIRS technique widely accepted in recent years as one of the most used methods for online feed analysis [13].
The first instruments were extremely sophisticated and expensive and destined to the laboratory use. They provided very accurate analytical results but only specialized personnel were able to use them. Over time the instruments have evolved with a significant reduction in their size and weight, allowing the development of portable instruments. There have also been improvements in their performance due to the increase in the speed of the acquisition of spectra, improvement of the signal processing and transmission and hardware and software improvement.
Near infrared spectroscopy measurements can be collected in either transmittance, reflectance or transflection mode. The transmittance mode allows to get information on the entire volume of the sample crossed by the light, while the reflectance mode only from the surface of the sample. Transflectance mode is a combination of the two aforementioned modes, especially suitable for liquid samples such as milk [14].
Calibration is the key to successfully use the NIRS technique [15]. Accurate, robust calibration models are difficult to obtain as their construction requires the use of a large enough number of samples to include all variations of physical and/or chemical properties. Constant calibration is required to adapt devices to new measurements and sample conditions (such as chemical composition, temperature, etc.). However, once calibration curves are in place NIRS does offer a rapid and cost-effective analysis capable of screening large number of samples [16] and is easy to use. Additionally, the use of daily device diagnostics is required to guarantee consistent and accurate results [17]. One limitation of this technique is the low sensitivity for the prediction of mineral content since there is no mineral absorption in the near infrared spectrum region. An alternative way to solve this problem is to combine different detection techniques with NIR spectroscopy, such as X-ray fluorescence spectroscopy, UV light, and the electronic nose technique [13]. In most of the studies the quality of NIRS calibration is evaluated in terms of linearity and accuracy. Linearity is indicated by the coefficient of determination (R 2 ), the calibration standard error (SEC), and the ratio of performance to deviation (RPD).

Analysis of the Chemical Composition of Raw Materials with Portable NIRS Instruments
The analysis of the nutritional composition of farm animal feeds is important for the decision-making process with the purpose to improve quantitative and qualitative productions. Near infrared spectroscopy was adopted already in 1970s for the analysis of forages [18], and since then there have been numerous studies on its applicability in support of animal husbandry [19][20][21][22][23][24]. The objectives of those studies were to develop calibration models for fodder and/or raw materials from different environments. These objectives were reached using different tools and different data processing, obtaining many positive results that demonstrated how the NIRS technique had a high potential in predicting the chemical composition of feed. The results of those research have been reported in several reviews [25][26][27].
Initially, the development and use of NIRS calibration for fodder was based on dried and ground material, resulting in several disadvantages including time lost during a long drying procedure, and possible changes of the nutritional value due to feed high temperature treatments which led to unreliable results [28]. The main problems have been highlighted for silages. In these specific feeds, there is the loss of volatile substances such organic acids, alcohols, esters, amines, and ammonia [25]. Alcohols and organic acids are important sources of energy for ruminants and are excellent indicators for the quality of silage fermentation [23].
To avoid an underestimation of these parameters, fresh non-dried material has been analyzed. Several studies [29][30][31] showed that the presence of water does not excessively interfere with the constituents' prediction. This was achieved developing chemometric software, such as correction of light scattering, and improving ability of spectrophotometers to minimize water interference [29,30]. Abrams et al. [31] concluded that despite the impact of water on NIR spectra, NIRS technology could evaluate fresh fodder for dry matter content, total nitrogen, and insoluble nitrogen, but could not adequately predict silage fermentation products. In the study by Sinnaeve et al. [32] on 'fresh' silage, the fermentation products were satisfactorily predicted with R 2 of 0.90-0.93-0.86 and 0.85 for pH, ammonia nitrogen, lactic acid, and acetic acid, respectively. Additionally, the study demonstrated that reflectance mode improved the prediction compared with the transmittance mode. Park et al. [33] reported that NIRS analysis of undried grass silages can provide accurate prediction of a wide range of chemical components, including fermentation products. Sørensen [34] showed that NIRS can be useful in the prediction of lactic acid, acetic acid, pH, NH 3 -N, and ethanol in grass and corn silage. To date, NIRS technology was also used to predict the chemical composition of natural pastures [35,36].
The availability of innovative diode-array spectrometers, a high-quality reflective holographic grid, and In GaAs cooled photodiodes-with minimized optical background noise and improved measurement stability-has expanded the potentials for applying NIRS at on barn level [37].
At least five companies in the world produce portable spectrophotometers designed for on farm hay and/or silage analyses (Table 1).
Recently, several reviews have been published on the use of NIRS technology through portable tools [39][40][41]. However, few studies are present in the literature on barn fodder analyses.
The first study reporting the use of a portable NIRS radiometer to predict alfalfa phytomass for grazing lambs is from 1990 [42]. Berzaghi et al. [22] evaluated the feasibility of using a portable spectrophotometer to analyze corn silage without any prior sample preparation comparing NIRS data with wet chemistry data. The instrument used was Zeiss Corona 45 (Carl Zeiss, Germany), a diode spectrophotometer, with a range of wavelengths between 960 and 1700 nm. In this study, 388 corn silage samples were collected and analyzed over a period of 4 years and over a large geographical area of Italy. Estimation errors indicated by the standard crossvalidation error (SECV) were relatively low, indicating good accuracy of the prediction. The R 2 for DM, neutral detergent fiber (NDF) and protein were 0.87, 0.88, and 0.76, respectively. The authors suggested that the lower value for protein was due to the limited variability of this component in corn silage.
Mertens and Berzaghi [43] compared the predictive capabilities of a laboratory spectrophotometer (NIR Systems 6500, Foss, Hillerød, Denmark) with a portable one (AgriNIR, DinamicaGenerale, Poggio Rusco (MN), Italy) for the determination of silage DM and found that the error of predictions of the diode array was about 50% greater than the laboratory instrument, but the overall error for moisture was lower than 2%. Considering the variation in silage humidity can be greater than 10% from one day to the next, portable instrument allowed a significant correction of the diet, with a considerable improvement in the precision of the quantity of feed provided [43].
A study by Patton et al. [44] on the prediction efficiency of three portable NIRS instruments compared to a laboratory NIRS on forages, showed portable NIRS had a reduced predictive capacity compared to the laboratory instrument. The study involved the analysis of 96 perennial Loliulm samples. The samples were analyzed by a NIRS laboratory instrument (NIR Systems 6500, Foss, Hillerød, Denmark) with a wavelength range 1100-2498 nm. Three portable instruments were used (PN-A, PN-B, and PN-C). PN-A predicted crude protein (CP) and water-soluble carbohydrates (WSC) at a comparable level with Lab-6500 but was unable to accurately predict DM and acid detergent fiber (ADF). PN-B did not replicate Lab-6500 predicted values for all four parameters analyzed. PN-C predicted a similar mean DM to NIR Systems 6500, but not for CP and ADF.
The difficulties in the use of portable NIRS instruments was the poor transfer capacity of robust calibration curves, obtained with a laboratory instrument, towards a portable one. On this regard, Marchesini et al. [37] demonstrated the possibility of transferring calibration curves between a laboratory instrument (FOSS NIRSystems 5000, Silver Spring, MD, USA, scanning monochromator, 1100-2500 nm) to two versions (PL1 and PL2) of new generation diode array portable spectrometer (poliSPEC NIR, 902 at 1680 nm; ITPhotonics, Breganze, Italy). Using the FOSS calibration equations as a reference, the quality of the calibration curves transfer was different between the two poliSPEC versions due to the differences in the construction. PL2 was the new generation version respect to PL1. PL2 had better construction characteristics that allow it to perform better than PL1. Between the two poliSPEC versions, PL1 obtained acceptable predictions for DM and NDF and ash, while PL2 showed a good forecast also for CP and ADF. Good results were also obtained in the use of PL1 as a reference tool.
The application of NIRS technique for on barn feeds analysis must be studied and further deepened. Currently, it can provide a first real-time indication on feeds composition favoring a first intervention by the farmer (Figure 2). PL2 had better construction characteristics that allow it to perform better than PL1. Between the two poliSPEC versions, PL1 obtained acceptable predictions for DM and NDF and ash, while PL2 showed a good forecast also for CP and ADF. Good results were also obtained in the use of PL1 as a reference tool.
The application of NIRS technique for on barn feeds analysis must be studied and further deepened. Currently, it can provide a first real-time indication on feeds composition favoring a first intervention by the farmer (Figure 2).

Analysis of the Chemical and Physical Constituents of the Totally Mixed Ration
The perspective of NIRS use in PLF has expanded considerably, and it has gone, in a very short time, from simple prediction of the chemical composition of raw materials to prediction of chemical and physical composition in mixtures of raw materials or in the totally mixed ration (TMR). The principle of TMR is clear, this type of diet preparation, if designed and prepared correctly, allows animals to ingest balanced meals in terms of nutritional composition and physical structure [45]. If TMR is not done correctly, it will produce adverse effects on animal health, milk production, and milk quality. In recent years, the possibility of obtaining excellent prediction results on raw materials has enabled development of calibration curves for the prediction of chemical-physical constituents, even for TMR. Kwang-Seok et al. [46] tested NIRS to evaluate the chemical composition of the dairy cow diet. Two hundred and fifty-three TMR were scanned by FOSS-NIR 6500 spectrophotometer (Infrasoft International LLC, Port Matilda, PA,USA) in the wavelength range of 400-2500 nm. The results showed a linear relationship between chemical analysis and NIRS analysis, and R 2 was 0.70, 0.97, 0.89, 0.80, 0.93, and 0.89 for moisture, CP, ash, lipid, ADF, and NDF, respectively. The chemical composition predictive capabilities of the TMR have also been confirmed by other authors. Serva et al. [47] in a study in which they compared traditional methods of chemical-physical analysis with portable NIRS to calculate the homogeneity index of the distributed ration, obtained excellent predictive results on the chemical characteristics of the ration. The R 2 was 0.98, 0.82, 0.78, 0.75, 0.94, Figure 2. Use of portable NIRS tool by a breeder on the farm to increase precision feeding.

Analysis of the Chemical and Physical Constituents of the Totally Mixed Ration
The perspective of NIRS use in PLF has expanded considerably, and it has gone, in a very short time, from simple prediction of the chemical composition of raw materials to prediction of chemical and physical composition in mixtures of raw materials or in the totally mixed ration (TMR). The principle of TMR is clear, this type of diet preparation, if designed and prepared correctly, allows animals to ingest balanced meals in terms of nutritional composition and physical structure [45]. If TMR is not done correctly, it will produce adverse effects on animal health, milk production, and milk quality. In recent years, the possibility of obtaining excellent prediction results on raw materials has enabled development of calibration curves for the prediction of chemical-physical constituents, even for TMR. Kwang-Seok et al. [46] tested NIRS to evaluate the chemical composition of the dairy cow diet. Two hundred and fifty-three TMR were scanned by FOSS-NIR 6500 spectrophotometer (Infrasoft International LLC, Port Matilda, PA, USA) in the wavelength range of 400-2500 nm. The results showed a linear relationship between chemical analysis and NIRS analysis, and R 2 was 0.70, 0.97, 0.89, 0.80, 0.93, and 0.89 for moisture, CP, ash, lipid, ADF, and NDF, respectively. The chemical composition predictive capabilities of the TMR have also been confirmed by other authors. Serva et al. [47] in a study in which they compared traditional methods of chemical-physical analysis with portable NIRS to calculate the homogeneity index of the distributed ration, obtained excellent predictive results on the chemical characteristics of the ration. The R 2 was 0.98, 0.82, 0.78, 0.75, 0.94, 0.91, and 0.90 for DM, ash, CP, lipids, NDF, ADF, and starch, respectively. This study was carried out without preliminary treatments of the TMR samples (only scanned) and with a portable spectrophotometer (poliSPEC NIR, ITPhotonics, Breganze, Italy).
Interest was addressed to the physical characteristics of the ration. From a nutritional point of view, the increase in the level and size of forage particles improve the chewing activity, the saliva production and consequently the pH of the rumen, the rumen acetatepropionate ratio and milk fat levels [48]. The excessive presence of long and coarse forage can limit feed intake and digestibility, affecting the animal's energy balance [49]. In contrast, the reduction in the size of feed particles can cause the decrease of milk fat percentage [50][51][52], rumination activity and rumen pH [51,52].
Although the effect of particle size on rumen function and fermentation have been well documented [50,53], routine on-farm analysis of these physical characteristics has only recently attracted attention. From the introduction of the Penn State Particle Separator (PSPS) in 1996, then modified in 2013 [54], guidelines were introduced for checking the Agriculture 2021, 11, 296 7 of 21 correct distribution of particles size of TMR. Although, the use of this sieve has been of great help, today faster technologies are exploited to obtain this type of information. The study by Serva et al. [47] represented a first approach to the analysis of the TMR physical composition using NIR spectroscopy. For the physical component of TMR, they modified the PSPS as follows: 3.81 cm (S1), 1.91 cm (S2), 0.79 cm (S3), 0.38 cm (S4), 0.18 cm (S5), and bottom. The results obtained were discrete for S4 and bottom with a R 2 of 0.87 and 0.94, respectively. The calibration results for S1, S2, S3, S5 were poor, with R 2 of 0.49, 0.39, 0.74, and 0.63, respectively. Their study demonstrates how directly it is possible to get information on the physical composition from on-barn TMR.
The portable instruments for the analysis of TMR characteristics have been designed to be used on-barn directly for feed analysis: inserted on mixer wagons to obtain information in real-time on the composition of the loading feeds or used manually by technical personnel.
For example, it is essential to know the real content of DM since the variations in forages (silage in particular) humidity, even for short periods [55], can cause differences in the ration composition. Such variations may affect dairy cow health and production, including the increase of incidence of displaced abomasum, subclinical acidosis, and fluctuations in average daily milk yield and DMI [56]. Boyd and Mertens [57] concluded that sudden changes in forage DM reduced daily feed intake, but a variation greater than 3% units in forage DM was required to affect milk yield and components in dairy cows. Furthermore, the variability of DM content of TMR tends to modify the palatability and affects the selection of ingredients [58,59] resulting in the consumption of an unbalanced diet. However, it has been assumed that a slight daily variation in the composition of the TMR is inevitable [56].
The ration is formulated by a nutritionist based on DM of feeds and is then prepared and distributed based on its weight as it is. This means that, for the same weight, the nutrient intake will vary according to the moisture content of feeds, leading to the risk of overfeeding or underfeeding the animals particularly when diets are largely based on silages [60]. Mertens and Berzaghi [43] evaluated the effects of daily fluctuations of silage DM and observed that the reduction of DM between 8% and 16% was responsible for the reduction of 2 kg of DM intake, on average, resulting in a loss of milk production. Piccioli-Cappelli et al. [9] evaluated the effect of NIRS tool use on distributed TMR in terms of the right amount of DM. The NIRS applied directly to the mixer wagon aimed to predict the real DM content of the silage during the loading phase. In farms where NIRS was active, a correction of silage amount to be loaded was suggested according to the real measured DM content. Under this operative condition, the actual diet was closer to the target diet compared to farms in which NIRS was not active. When NIRS was not active the DM of the actual diet ranged between 97% and 109.8% of the target diet DM. Using NIRS the amount of DM was closer to the target diet (99.7% to 105.7%). Also, the protein content of TMR tended to be more closed when NIRS was active.
These results are very encouraging considering that corn silage is usually the main ingredient of TMR for dairy cows.

Analysis of TMR Evaluation Indices (Homogeneity and Selection)
A recent utilization of NIR spectroscopy is for evaluating TMR homogeneity and selection index. It becomes economically interesting for the farm management, the possibility of verifying the nutritional characteristics of the TMR and checking if it is correctly distributed along the front of the feeding-line. For the 'mixture' to be defined homogeneous, it must contain the individual ingredients (by chemical composition and physical structure) uniformly distributed without any undesirable and/or harmful deficiencies or excesses. Unfortunately, this is not always the case, the reasons for the non-homogeneity in TMR distribution may be attributable to various factors, including type of mixer wagon and integrity of the cutting elements, the loading sequence, the mixing time, attention of the operator, and possible modifications of raw materials. The TMR homogeneity like its degree of mixing, and the relative granulometric composition are of fundamental importance, since the composition of the ration, from the physical point of view, has a well-defined effect on the stimulation of ruminal activity [61] and on the intensity of fermentations [62]. Non-homogeneous rations lead to a separate ingestion of nutrients due to the easy selection operated by animals; this can lead to the alteration of ruminal efficiency, alteration of production efficiency, and an increase in variability among individuals [63].
Andrighetto [64] reported that homogeneity of TMR can be measured by sampling along the barn feeding-line and subjecting TMR samples to chemical analysis and sieving (by particle size Penn State sieve).
The use of portable NIRS to detect the homogeneity of the TMR, was done for the first time by Serva et al. [47] who developed an algorithm capable of providing a homogeneity estimated for TMR in cattle (beef and dairy). A TMR calibration curve was preliminarily created and the best predicted factors for the creation of a homogeneity index (HI) were considered from the calibration results, appropriately biased in importance regarding the nutritional values of the ration, and by comparison with normal defined standards. After a data filtering phase and removal of random errors, the algorithm calculated the variation of the physical-chemical parameters used during the TMR unloading phase. Additionally, algorithm compared the parameter values with reference standards and determined their deviation from the ideal condition, or from the first to the last moment of unloading in which no change in the physical-chemical composition of the ration was revealed. The algorithm was also able to determine which discharge sector (for each parameter) was most affected by any non-homogeneity.
This algorithm has been tested under field conditions by using portable NIRS [63] to evaluate the possible areas in which the greatest mistakes can be made. The NIRS results showed a better homogeneity of the TMR prepared with the addition of water compared to dry TMR preparation. Different loading moment of the water in the mixer wagon tended to improve the adhesion of fine particles to coarse ones. In detail, the TMR was more homogeneous when the water was loaded after the hay. Significant improvements on final homogeneity were obtained for the TMR prepared with the right attention of the operator compared to those prepared by careless operator. The authors concluded that the availability of a portable NIRS equipped with a specific calibration curve allows to quickly identify rations not correctly prepared both for chemical and physical characteristics.
In our preliminary study (unpublished data), it was shown that TMR preparations with different feed loading sequence affected the TMR homogeneity. In this study, the portable instrument PoliSPEC NIR was used. The NIRS results indicate that the TMR prepared with the following loading sequence: hay-water-concentrates-silage (wagon B) showed greater homogeneity compared to those prepared by inverting the last two feeds: silage and concentrates (wagon A).
Analyzing the data of selection index (SI), the results showed that more homogeneous TMR (wagon B) were less selectable than less homogeneous one (wagon A), this would confirm that a more homogeneous TMR determines less choice by animals.
Comparing the SI at 1, 2, and 4 h after TMR distribution, the final SI increased over time. These data highlights how the selection capacity tends to increase over time probably due also to atmospheric events, such as wind and solar radiation, which tend to reduce the TMR humidity, with a consequent increase in the dry matter, causing a separation of the particles.
In fact, the parameters that were more easily selectable were the physical ones, i.e., those that have shown a lower level of homogeneity.
An interesting result of this study concerns the selection made by the two groups of animals under study, multiparous and primiparous cows. In particular, the final SI showed that the multiparous cows tend to select the constituents of the ration more than primiparous cows. In particular, the major selection have concerned S5, bottom, and starch. A possible explanation could be the different feeding behavior of multiparous cows compared with primiparous cows [65].
Unfortunately, few studies are present in the literature on the ability of NIRS technology to correctly predict the chemical characteristics of TMR; therefore, future research should focus on this aspect.
The analysis of the TMR by NIRS technique should be deepened with more care on the implementation of calibration curves that can be used on a large scale. A future potential application of portable NIRS is the on-line use on the mixer wagon to obtain information on the TMR homogeneity other than chemical composition of incoming raw materials. The application of this technology would allow to significantly increase precision feeding. It would certainly be expensive; therefore, it is advisable to conduct a cost-benefit analysis of this application.

Analysis of the Chemical Composition of Slurry and Manure
The use of NIR spectroscopy to analyze the chemical composition of manure and slurry has been assessed with the aim of obtaining information on the use of this method for both agronomic and zootechnical purposes as well as to reduce pollutant emissions in the environment. The knowledge of the feces chemical composition could provide useful information on: (i) quantity/quality of the nutrients useful for fertilization (total nitrogen, ammonia nitrogen, phosphorus, potassium), quality of the material (humidity, DM, C/N ratio, total carbon) for composting processes or to use them to produce biogas, as well as for the implementation of efficient emission reduction strategies; (ii) information about the digestibility of the ration.
Manure represents a resource that could be used to increase the economic and environmental sustainability of the farm in a virtuous circle of circular economy. It is important for farmers to know the chemical composition of manure to use it appropriately, avoiding excesses. This may determine an excessive release of nutrients to the environment causing air and water pollution, especially in areas with high livestock intensity.
To know the composition of the manure the laboratory analyzes or forecasting models are usually needed. The first, although precise, is an expensive method, not practical in sampling and provides the results in late with respect to the timing of distribution in the field [66,67]. Moreover, laboratory analyzes are methods that generates waste. The forecast models are inexpensive and easy to use but relatively reliable and accurate. The great variability in the composition of slurry makes difficult to use general models. Another problem is the difficulty of taking a representative sample due to the great heterogeneity of livestock manure [68]. Therefore, Malley et al. [69] evaluated the possibility of using NIRS as a rapid method to obtain a real-time information on the characteristics of the manure in the three composting stages. The calibration prediction was evaluated on 179 samples scanned with a portable Zeiss Corona 45 VIS NIR (Carl Zeiss, Germany) spectrometer from 360 to 1690 nm wavelength. The parameters analyzed were pH, total N, total C, organic C, C:N ratio, P, available P, S, K, Na and nitrate + nitrite. Malley et al. [69] confirmed a good prediction for total and organic C (R 2 = 0.91 for both; RPD = 3.30 and 3.44, respectively), adequate result for the C:N ratio, pH and K (R 2 = 0.87, 0.89, 0.83 and RPD = 2.91, 2.98, 2.43, respectively), acceptable results for total N and S (R 2 = 0.74 and 0.73; RPD = 2.14, 1.90, respectively); results about P were useful for screening (R 2 = 0.61; RPD = 1.59). Unsatisfactory results were obtained for nitrate + nitrite, available P, and Na. Reeves and Van Kessel [70] investigated the use of NIRS to determine the concentrations of total C, total N, NH 3 -N, moisture, P, K, and pH on samples of bovine manure, using a FOSS-NIR Systems Model 6500 equipped with a sample transport device (from 400 to 2498 nm wavelength). The results of the calibration were extremely positive and demonstrated that NIRS accurately determined the moisture (R 2 = 0.94), total C (R 2 = 0.95), total N (R 2 = 0.96), and NH 3 -N concentrations (R 2 = 0.97) of bovine manure, but not for P or K concentrations.
The first two are bench instruments, the last two are portable instruments. The substantial differences were the wide spectral band (1000-2500 nm) of the two benchtop and a greater spectral resolution (8 cm −1 and 2 nm), and light dispersion technology compared with portable spectrophotometers (Figure 3). wavelength). The results of the calibration were extremely positive and demonstrated that NIRS accurately determined the moisture (R 2 = 0.94), total C (R 2 = 0.95), total N (R 2 = 0.96), and NH3-N concentrations (R 2 = 0.97) of bovine manure, but not for P or K concentrations.
The first two are bench instruments, the last two are portable instruments. The substantial differences were the wide spectral band (1000-2500 nm) of the two benchtop and a greater spectral resolution (8 cm −1 and 2 nm), and light dispersion technology compared with portable spectrophotometers (Figure 3). The calibration results showed that all instruments were able to accurately predict the DM content with R 2 values between 0.72 and 0.87 and RPD between 2.5 and 3.7.
For the prediction of total N, ash, and organic N, the performance of portable instruments was lower than benchtop instruments. The authors concluded that the inability of The calibration results showed that all instruments were able to accurately predict the DM content with R 2 values between 0.72 and 0.87 and RPD between 2.5 and 3.7.
For the prediction of total N, ash, and organic N, the performance of portable instruments was lower than benchtop instruments. The authors concluded that the inability of these instruments to reach satisfactory prediction of total N in slurries appears to be related more to the instrumental resolution, than to the reduced spectral range, as highlighted by the performance of the models developed from the deresolved spectra of the two benchtop instruments.
Other factors like sample preparation, temperature, and reading configurations may affect the correct prediction of the components [72]. Finzi et al. [72] studied the chemical characteristics of bovine slurry and digestate and tested three sample preparations (filtration, homogenization, and a raw control), two reading configurations (Petri dish and optical fiber), and three sample temperatures (10, 25, and 35 • C). The results showed that the NIRS performance was mainly influenced by two factors: sample preparation and reading configurations; the different temperatures did not determine any significant effect.
Sample preparation, both filtration and homogenization, showed greater R 2 and RPD performance than raw samples. As regards the two reading configurations, the best spectral acquisition was obtained with Petri dishes.
The NIRS technique proves promising in the analysis of different parameters in manure especially if it is compared with the rapid tests currently present such as a slurry meter, densimeter calibrated on the values of the fertilizing elements, Agros N meter, and Quantofix, for ammoniacal nitrogen, the hydrometer for nitrogen, and phosphorus [73][74][75][76][77]. Unlike the NIRS technique, they are not able to quantify several parameters at the same time, since they work on dilutions or require reagents even if most of these "rapid tests" are portable, simple to use, relatively inexpensive, and require rapid times [73]. Van Kessel and Reeves [73] evaluated some of these methods to determine their accuracy in comparison with the laboratory analysis. In this study six rapid tests (Quantofix-N-Volumeter, Agros N, conductivity meter, conductivity pen, reflectometer, and hydrometer) have been evaluated for precision in estimating total nitrogen or NH 4 + /N ratio. The regression results obtained for ammonia nitrogen (NH 4 + /N) were: R 2 = 0.95 (Quantofix-Nvolumeter); R 2 = 0.91 (reflectometer); R 2 = 0.89 (conductivity meter); R 2 = 0.81 (Agros N meter) and R 2 = 0.87 (conductivity pen); for total nitrogen: R 2 = 0.48 (hydrometer). The prediction was significantly improved when the samples were subdivided considering the DM≤ 12% and DM >12%.
A good relationship was observed by Bhogal et al. [77] between the Agros N meter and conventional laboratory analyses for NH 4 + /N content of slurries with R 2 > 0.90. The NIRS technique has considerable capabilities in the on the barn analysis of manure, currently the tests used are limited to a few parameters, while NIRS can be calibrated for multiple parameters. In the near future, it can be used also for this type of analysis.

Diet Digestibility Estimation by NIRS
A relatively recent topic in the use of NIRS is the investigation of the diet digestibility through the combination of feeds and feces information. Since NIRS has proved to be a valid predictive method of feeds chemical/physical composition and feces composition, it was considered suitable to estimate the digestibility of diets administered to ruminants. The use of NIRS to investigate diet digestibility is a relatively recent topic. Digestibility is an important factor affecting the feed efficiency and is affected by diet composition, genetics, and physiological phase of the animal as well as other environmental factors.
The success of using NIRS to predict diet digestibility is based on the principle that feces contain good spectral information that allows to describe the composition of the ingested diet, despite being influenced by the digestive process.
Several studies showed that NIRS can be used to predict chemical composition [78], uNDF240 [79], dry matter digestibility (DMD), and organic matter digestibility (OMD) in feces [80,81]. Knowing uNDF could be a quick and easy method to determine the digestibility of NDF in the gastrointestinal tract (TTNDFD). Recently, Colombini et al. [82] highlight how using NIRS to predict uNDF in feces and TMR, it is possible to estimate TTNDFD by applying a simple equation, the results obtained with this procedure were comparable to those obtained with the in vivo procedure (mean values for TTNDFD were 42.8% vs. 43.2% for NIRS and in vivo data, respectively).
A pioneering study on the use of a NIRS portable instrument to evaluate the chemical composition of feces to obtain information on digestibility was carried out by Allen et al. [83]. The feces were largely taken from the rectal ampoule and partly collected after defecation. The data of the portable spectrophotometer were compared with laboratory analyses. The instrument used was ASD Field Spec NIRS unit (Boulder, CO, USA) with a spectral range from 1100 to 2400 nm. The calibration results were statistically significant for all components (p < 0.01), the calibration regression values were fair to good for CP (R 2 = 0.89), DM (R 2 = 0.69), and NDF (R 2 = 0.62) but not predictive for ADF (R 2 = 0.34) and starch (R 2 = 0.31). The regression values for the validation of the calibration set were found to be low (R 2 < 0.35) and statistically not significant. The authors assumed that the results were probably due to the low number of samples used (58 for calibration and 7 for validation).
Great interest is the potential ability of NIR spectroscopy to predict starch content in stool. Fecal starch (FS) concentration is an excellent indicator of the starch digestibility in the total tract in cattle [84]. Improving the digestibility of starch is an essential topic since the high cost of concentrates. Generally, the starch digestibility in dairy cows varies from 70% to 100% and is affected by multiple factors. Fernandez et al. [85] reported a relationship between starch digestibility and FS for dairy cows, confirmed by Fredin et al. [86] that used NIRS to predict FS in dried ground fecal samples using Foss-NIR System 6500 (Silver Spring, MD). The FS concentration was predicted with good precision for the various spectral mathematical transformations, with high coefficients of determination (R 2 > 0.83) and a low standard error of prediction (SEP = 0.78-0.57) (Figure 4). The high correspondence between the concentration of FS on dry matter basis and the digestibility of the total starch in dairy cows has been demonstrated [84][85][86]. However, when FS was greater than 5%, the NIRS rating was reduced. The authors concluded that it is necessary to increase the number of samples with FS > 5% in NIRS sample sets to improve this prediction. Currently, portable NIRS technology for diet digestibility determination needs to be further studied. Certainly, increasing the number of samples, as suggested by Allent et al. [83], helps to develop a robust and specific calibration curve for different animal species. However, the few studies carried out are encouraging. DM (R 2 = 0.69), and NDF (R 2 = 0.62) but not predictive for ADF (R 2 = 0.34) and starch (R 2 = 0.31). The regression values for the validation of the calibration set were found to be low (R 2 < 0.35) and statistically not significant. The authors assumed that the results were probably due to the low number of samples used (58 for calibration and 7 for validation).
Great interest is the potential ability of NIR spectroscopy to predict starch content in stool. Fecal starch (FS) concentration is an excellent indicator of the starch digestibility in the total tract in cattle [84]. Improving the digestibility of starch is an essential topic since the high cost of concentrates. Generally, the starch digestibility in dairy cows varies from 70% to 100% and is affected by multiple factors. Fernandez et al. [85] reported a relationship between starch digestibility and FS for dairy cows, confirmed by Fredin et al. [86] that used NIRS to predict FS in dried ground fecal samples using Foss-NIR System 6500 (Silver Spring, MD). The FS concentration was predicted with good precision for the various spectral mathematical transformations, with high coefficients of determination (R 2 > 0.83) and a low standard error of prediction (SEP = 0.78-0.57) (Figure 4). The high correspondence between the concentration of FS on dry matter basis and the digestibility of the total starch in dairy cows has been demonstrated [84][85][86]. However, when FS was greater than 5%, the NIRS rating was reduced. The authors concluded that it is necessary to increase the number of samples with FS > 5% in NIRS sample sets to improve this prediction. Currently, portable NIRS technology for diet digestibility determination needs to be further studied. Certainly, increasing the number of samples, as suggested by Allent et al. [83], helps to develop a robust and specific calibration curve for different animal species. However, the few studies carried out are encouraging.

On-Line Analysis of Milk Quality (Total and Individual) in the Milking Parlor
Infrared (IR) spectroscopy represents a rapid, cheap, and easy-to-use technique available both for research and for on-line and off-line analyzes of milk. For liquid matrices

On-Line Analysis of Milk Quality (Total and Individual) in the Milking Parlor
Infrared (IR) spectroscopy represents a rapid, cheap, and easy-to-use technique available both for research and for on-line and off-line analyzes of milk. For liquid matrices such as milk, initially, the analytical spectroscopy used was mid-infrared (MIRS), now the use of NIRS has spread. The main difference is that the absorption in the MIR corresponds to the fundamental bands of molecular vibrations, while the absorption in the NIRS corresponds to overtones and combinations of these. This implies that NIR spectra are much more complicated for the superposition of more bands and therefore much less specific than MIR spectra. Moreover, the light diffusion is greater in the NIRS technique than in the MIRS; therefore, the spectra of the NIR will be much more influenced by factors that interact with the diffusion of light, such as the presence or absence of water.
The complexities in the analysis of raw milk are the heterogeneity of the sample and the high-water content [87]. Water is one of the major contributors to the variation in the NIR spectra that could limit the detection of analytes [8]. Therefore, the most used IR method for milk analysis is the MIRS, which can analyze many samples per day (up to 500 samples/h). However, the MIRS apparatus is very expensive. NIRS has a lower analysis potential (around 150-200 analyses per day) but is cheaper (around 1:20 compared to MIRS) and is not set up to analyze a specific product but can analyze multiple products [88]. In recent years, there have been important improvements in the speed of acquisition of spectra, in the processing and transmission of the signal, as well as the possibility of better connections and NIR spectral management. Moreover, instruments have developed with a notable decrease in size and weight, which have led NIRS to be increasingly used as it is more suitable for use outside the laboratory and therefore directly on the dairy farm.
Portable micro-NIRS instruments are becoming increasingly popular, usable via app on smartphone for milk analysis [89]. The knowledge of milk constituents provides useful feedback to monitor and better manage nutrition. Milk fat and proteins are directly linked to the energy intake and the physical structure and crude fiber in the ration; furthermore, the ratio between fat and proteins is in general a more sensitive indicator of animal metabolic state than fat or proteins used separately. A fat-protein ratio between 1.2 and 1.4 is optimal and implies a positive energy balance [90], fat-protein ratio > 1.4 [91] or 2.0 [92] has been described as index of negative energy balance or subclinical ketosis, respectively.
Knowledge of the proteins and urea content provides indication on the balance between energy supply and protein concentration in the diet [93]. Urea appears to be a powerful indicator concerning dietary control, in fact, it is regularly used by nutritionists to monitor and optimize protein nutrition. An uneven nitrogen balance in the farm, caused by excessive levels of CP in the diet, can be expressed in a high concentration of urea in milk which can vary from 18.0 to 39.0 mg/dL [94].
The knowledge of the concentration of somatic cells count (SCC) allows to have information on the health and functionality of the mammary gland as well as on the technological quality of milk.
Near infrared spectroscopy can be applied to all milk processing chain to check its quality: from raw milk directly on farm in the production line, for routine off-line analysis, and finally on finished products (cheese, yogurt, etc.). Many studies have shown that NIRS gives precise results on the prediction of multiple milk parameters such as fat, proteins, caseins, urea, lactose, somatic cells, fatty acids, etc. [95][96][97][98]. However, most of the research was carried out on milk in off-line mode or rather not directly in the milking parlor. Recently, tests have been carried out using NIRS directly in the milking parlors to have individual check of each animal and to obtain information on milk quality and health status of the cows [8,93,[99][100][101][102][103][104]. Pioneering studies on the possibility of using NIRS instruments on farm were carried out by Tsenkova et al. [87]. The study was conducted on non-homogenized milk, in on-line mode during the milking process and compared the performance of NIRS at different wavelength ranges (from 400 to 2500 nm) and at different sample thicknesses (1-4-10 mm). The results showed that the spectral region and the thickness of the sample are significant factors for the determination of milk fat and total proteins, but not for lactose. Good results were obtained for in-line applications with 700-1100 nm spectral region, but the best precision was obtained in the 1100-2400 nm region and with 1 mm sample thickness. Good prediction of lactose was obtained by Kawamura et al. [102]. Those authors, using a wavelength range of 600-1050 nm, developed calibration models for the prediction of fat, proteins, lactose, SCC, and urea nitrogen (MUN) on non-homogenized milk. The results, expressed as R 2 and SEP of the validation set, showed a good prediction, for fat (R 2 = 0.95, SEP = 0.42%); proteins (R 2 = 0.91, SEP = 0.09%); lactose (R 2 = 0.94, SEP = 0.05%); and MUN (R 2 = 0.90, SEP = 1.33 mg/dL) and poorer for SCC (R 2 = 0.82, SEP = 0.27 log SCC/mL).
Applying NIRS prediction systems on automatic milking robots (AMS), Kawasaki et al. [100] obtained slightly poorer results for the prediction of many milk parameters. Diaz-Olivares et al. [99] by applying a NIRS detector on AMS capable of automatically collecting and analyzing a milk sample for each milking, obtained satisfactory results for the prediction of fat and protein (R 2 > 0.89), poor prediction for lactose (R 2 = 0.64). In-line applications, reported by Melfsen et al. [93], showed very high predictive capabilities for fat, proteins, and lactose and satisfactory for the content of milk urea and SCC. The prediction ability of NIRS instruments on non-homogenized milk has been supported by recent studies [103,104]. Results indicated that NIRS may be used to determine milk quality in real-time during milking by providing information to farmers on milk characteristics and on physiological conditions of every cow [99,100].
Automatic milking systems are growing in the barns also due to reductions in the availability of milking labor and a potential increase in labor costs. It would be interesting to use NIRS that allows real-time checking on the automatic milking robot. This AMS-NIRS combination could be used for detailed and autonomous on-farm monitoring of the milk composition at each single milking.
A crucial index for to diagnose the presence of negative energy balance in dairy cows investigating is the concentration of milk ketone bodies. Fourier transform infrared spectroscopy (FTIR) is the spectrophotometric method used for ketone bodies determination which is based on the mid-infrared spectrum. Several studies have documented the ability of FTIR analysis of milk to predict acetone and β-hydroxybutyrate (BHB) [105][106][107][108]. The determination of these parameters directly in milk is of great advantage, because blood sampling and tests are time-consuming and expensive, and the procedure is invasive and stressful for the cows [109]. Enjalbert et al. [110] suggested that the detection of subclinical ketosis is much easier in milk than in blood, and they also demonstrated high correlation coefficients between blood and milk acetone (r = 0.96). On the contrary, concentration of milk and blood BHB were poorly correlated compared with the concentrations of other ketone bodies. The applicability of these FTIR predictions, in an on-line system applied in the milking parlor, could be enhanced by including cow characteristics that have been related to susceptibility to hyperketonemia (e.g., body condition, week of lactation, or level of milk production) [111]. This use would allow to increase the accuracy of the predicted risk of hyperketonemia per individual registered cow and the optimization of on-farm feeding by limiting cases of ketosis in the future.
NIRS technique has been evaluated as a possible method for monitoring milk progesterone levels on an individual level. Indeed, according to several authors, monitoring progesterone levels in milk represents an ideal and inexpensive means of monitoring reproductive status, detecting heat, and diagnosing pregnancy in cows [112][113][114][115]. The quantification of progesterone with traditional methods has disadvantages including sampling, the use of the equipment and/or sample pretreatments which are expensive and timeconsuming, making routine progesterone determination an expensive and time-consuming waiting [116][117][118]. To overcome these problems, on-site monitoring of progesterone can be implemented at the milking parlor and is believed to be an effective solution [117]. Iweka et al. [116] evaluated the prediction capacity of an on-line NIRS system to be applied in the milking parlor for the detection of progesterone level at each milking and for each cow. This pioneering study has achieved very promising results and lay the first foundations for subsequent studies on the subject. The authors concluded that progesterone monitoring can currently be used as a screening and therefore alone is not sufficient to correctly predict ovulation due to the large variation among animals in the timing of progesterone concentrations decrease relative to ovulation. This technique, when combined with other estrus detection systems, can represent an effective means of detecting the right moment of heat. Tallo-Parra et al. [119] used the NIRS to detect cortisol and progesterone concentrations in cow hair as indicators of stress and reproductive status, respectively. Near-infrared spectroscopy demonstrated its ability to predict cortisol and progesterone concentrations with certain accuracy (R 2 = 0.90 for cortisol and R 2 = 0.87 for progesterone).
There is a strong interest in the real-time company-level analysis, both by the dairy industries and by the farmers who transform their milk on farm, regarding the technological properties of milk. Especially for those who produce types of products with a high standard of quality and typicality. The technological properties of milk are represented by a series of parameters: the coagulation time of the rennet (RCT; min), the hardening time of the curd (k 20 ; min), the firmness of the curd 30 min after adding the rennet to the milk (a 30 ; mm), pH and titrable acidity (TA; Soxhlet-Henkel degrees/100 mL), as well as Ca and P content. Currently the prediction of these parameters was investigated by MIR spectroscopy [120][121][122][123][124][125]. The NIRS technique for analyzing the technological parameters of milk have not been investigated but in the future these parameters could be analyzed by the NIRS; instead, it was more suitable than MIRS, for the prediction of milk micronutrients such as carotenoids, vitamins, and fatty acids as suggested by a study by Soulat et al. [125].
In the field of food safety, much interest is aimed at the use of the NIRS technique to identify fraud and/or adulterations that can occur in the dairy sector such as the addition of water [126] or whey to milk, fraudulent addition of melanin, urea [127], and glucose [128]. Several sources of information are available to discriminate foods obtained from different farming systems, for example fatty acid profile may be used to discriminate milk obtained from different feeding systems [129,130]. The characterization of the fatty acid profile could be also used as a certification of the nutritional properties of milk for human health [131].
Spectroscopic analysis (NIRS and MIRS) of milk in the milking parlor demonstrated to be a valid means to improve management of dairy cattle farming. This is because, under standard dairy practices, cows are milked two or three times a day, which implies that milk samples provide information on the current state of the herd/individual and can also be collected and analyzed regularly without adversely affecting the animal's daily life [101].
Knowing the chemical composition of milk in real-time allows to: (i) monitor the chemical-bromatological and technological quality of the milk to be destined for human consumption or processing/cheesemaking; (ii) monitoring and control to prevent milk fraud; (iii) monitoring reproductive status (at herd level or for individual animals); (iv) monitoring health and physiological status (at herd level or for individual animals); (v) predispose genetic improvements for traits of interest; (vi) reduce the costs incurred for periodic milk analysis.

Conclusions and Future Perspectives
Among the many PF technologies, the declination of NIRS to dairy cow feeding management, is undoubtedly one of the most promising. The use of portable NIR spectrophotometers to evaluate the physio-chemical composition of TMR and manure represent a recently introduced technology. Its application on raw materials, TMR, and feces can obtain, or derive, values and indices, that guide dairy farmer decisions to rapidly implement corrective or preventive actions for improving, or in any case keeping constant over time, the management of dairy farm. The reviewed literature showed that the use on barn NIRS, through appropriate calibrations, is a rapid and accurate analytical technique. The potential benefits, as widely discussed, are enormous.
The new solutions proposed for the control and management of TMR is the use of NIRS systems directly on the mixer wagon. Another advantage, which can be obtained using this tool, is the knowledge of the physical structure of TMR to estimate a homogeneity of distribution and selection index to optimize ruminal efficiency. Additionally, the determination in the barn of the chemical characteristics of feces may allow the estimation of diet digestibility. Moreover, spectroscopic analysis of milk in the milking parlor demonstrates to be a valid means to improve management on several aspects inherent to dairy cattle farming. In particular, the detection of some parameters in milk-such as progesterone, SCC, fat, proteins, etc.-during milking allows to monitor health, physiological, and reproductive status at the herd level or for individual cows, as well as to check milk chemical-bromatological and technological characteristics. Furthermore, the application of NIRS on AMS could be a valuable aid for a more specific control of individual cows, at each individual milking. The spread of AMS is therefore a useful means of improving milk-based controls at the individual level. So, NIRS instrumentation would be extremely useful to analyze all the critical control points in the management of dairy cattle allowing to improve animal welfare, production, reproduction, and sustainability; as well as the farmer's income.
Limitations to the spread of these technologies in the contest of commercial farms includes the investment cost and the difficult amortization for the purchase of technologies, especially in small and medium farms where basic technologies are generally lacking. In addition, the advanced age of the breeders and the low rate of digital tech usage in agriculture sector compared to other sectors should be considered. Another limit is the need for calibration procedures, the management and interpretation of the data. It is therefore advisable to trust on specialized personnel. Therefore, assistance to the breeder is essential for the correct use of these new technologies and will be important for increasing on-farm use of NIRS techniques.
Further research should be carried out to open other fields of NIRS application that are not currently considered. Moreover, NIRS is being developed to be used on farm via smartphone with special apps to have "the technology at hand".