# Improvements in the Robustness of Mid-Infrared Spectroscopy Models against Chemical Interferences: Application to Monitoring of Anaerobic Digestion Processes

Magida Zeaiter, Éric Latrille, Pascal Gras, Jean-Philippe Steyer, Véronique

Bellon Maurel, Jean-Michel Roger

<figure><img src="image_1.png" /></figure>

## ► To cite this version:

Magida Zeaiter, Éric Latrille, Pascal Gras, Jean-Philippe Steyer, Véronique Bellon Maurel, et al. Improvements in the Robustness of Mid-Infrared Spectroscopy Models against Chemical Interferences: Application to Monitoring of Anaerobic Digestion Processes. AppliedChem, 2022, 2 (2), pp.117-127. 10.3390/appliedchem2020008. hal-04989424

HAL Id: hal-04989424

https://hal.inrae.fr/hal-04989424v1

Submitted on 13 Mar 2025

HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d'enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
<figure><img src="image_3.png" /></figure>

Article

# Improvements in the Robustness of Mid-Infrared Spectroscopy Models against Chemical Interferences: Application to Monitoring of Anaerobic Digestion Processes

Magida Zeaiter <fnref n="1" />, Éric Latrille <fnref n="2" />,<fnref n="3" />, Pascal Gras <fnref n="2" />, Jean-Philippe Steyer <fnref n="2" />, Véronique Bellon-Maurel <fnref n="1" /> and Jean-Michel Roger <fnref n="1" />,<fnref n="3" />,*

**Abstract:** The monitoring and control of bioprocesses rely on the measurement of the main metabolite concentrations. To this end, infrared spectroscopy (IR) is a good candidate with which to perform rapid and non-destructive measurements. However, IR-based measurements rely on a calibration step linking the measured spectra to the concentrations of the compounds of interest. This calibration may suffer with problems of robustness when the measuring conditions change, such as when some chemicals not present in the calibration spectra are added when using the IR sensor. In this study, a method based on orthogonal projection, dynamic orthogonal projection (DOP), was tested for its ability to cope with the robustness problem caused by the addition of ammonia in a pilot-scale anaerobic digester, whose volatile fatty acid concentrations were monitored by mid-IR spectrometry. The results demonstrate that DOP has significant potential as a form of process analytical technology.

**Keywords:** bioprocess monitoring; infrared spectrometry; chemometrics; orthogonal projection; robustness

**Citation:** Zeaiter, M.; Latrille, É.; Gras, P.; Steyer, J.-P.; Bellon-Maurel, V.; Roger, J.-M. Improvements in the Robustness of Mid-Infrared Spectroscopy Models against Chemical Interferences: Application to Monitoring of Anaerobic Digestion Processes. *AppliedChem* **2022**, *1*, 117–128. https://doi.org/10.3390/appliedchem2020008

Academic Editor: Archimede Rotondo

Received: 2 May 2022

Accepted: 16 June 2022

Published: 20 June 2022

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

<figure><img src="image_4.png" /></figure>

**Copyright:** © 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## 1. Introduction

The advanced monitoring and control of bioprocesses rely on the use of appropriate sensors to measure the concentrations of major metabolites with sufficient accuracy and long-term stability under minimum maintenance. Infrared (IR) spectroscopic sensors offer many advantages in this field. Near-infrared spectrometry (NIRS) is the most frequently used technique online, because the wavelength range (700–2500 nm) allows the light to penetrate deeply into the sample. Wang et al. [1] provide a comprehensive review of NIRS online applications for liquid media. These include alcoholic and non-alcoholic beverages, oils and milk. The objectives of these applications include quality assessment, classification, and adulteration control. However, since NIRS is strongly affected by water, mid-infrared spectrometry (MIRS) offers an interesting alternative to NIRS for aqueous media. Karoui et al. [2] provide a review of MIRS applications in food, including milk, meat, fish, oil, and cereals. They conclude that MIRS is a good candidate to be used online, not only for food processing. In [3], a review of the application of MIRS to monitoring processes reported that MIRS can predict glucose, ethanol, methanol, glucuronic acid, and ammonium concentrations with fair accuracy. Consequently, MIRS is a good potential process analytical technology (PAT).

<footnote n="1">¹ ITAP, INRAE, Institut Agro, University Montpellier, 34060 Montpellier, France; magida_z@yahoo.com (M.Z.); veronique.bellon@inrae.fr (V.B.-M.)</footnote>

<footnote n="2">² INRAE, University Montpellier, LBE, 102 Avenue des Etangs, 11100 Narbonne, France; eric.latrille@inrae.fr (É.L.); pascal.gras@inrae.fr (P.G.); jean-philippe.steyer@inrae.fr (J.-P.S.)</footnote>

<footnote n="3">³ ChemHouse Research Group, 34196 Montpellier, France</footnote>

<footnote>* Correspondence: jean-michel.roger@inrae.fr</footnote>
However, the calibration of IR-based sensors for bioprocess monitoring is still a chal-
lenging robustness problem due to the overlapping absorbance features and the metabolic
interactions and correlations among the major metabolites. The former problem may
cause some difficulties in retrieving the part of the spectrum that is related to the com-
pound of interest. The latter problem may lead to the building of a calibration of a com-
pound A, on the basis of the spectral response of a compound B, correlated to A. Partial
least-squares regression (PLSR) is often used to calibrate spectra with overlapping absorb-
ance features. However, only few methods have pointed out specifications for model cal-
ibration to circumvent the correlation problem for reactive mixtures [4,5] and cell-culture
reactions [6,7]. The robustness of PLSR models used with infrared spectroscopy data was
widely addressed in the literature, from a theoretical point of view [8–13]. Various factors
may affect this robustness. Different pre-processing methods were developed to correct
physical- and chemical-factor interference. Among these, approaches based on orthogonal
projection methods make it possible to subtract the unwanted signal from the spectra be-
fore calibration [14,15].

Anaerobic digestion (AD) is a biological process during which organic carbon is con-
verted through oxidation-reduction reactions to both its most oxidized state (CO2) and its
most reduced form (CH4) [16]. The methane produced is a versatile energy carrier that can
be used for generating power and heat, injecting into the gas grid, or use as a fuel for
vehicles. In Europe, incentive policies have led to the emergence of a biogas industry,
mainly based on agricultural feedstocks (agricultural residues, energy crops, and catch
crops) which are the largest available deposits of organic matter [17,18]. However, AD
processes are very sensitive, and they can face a large number of disturbances due the
fluctuating characteristics and quantities of the waste they handle. Thus, the monitoring
of AD processes is an imperative task in order to ensure optimized operations and to pre-
vent failures and serious consequences during the running of plants [19].

In this paper, dynamic orthogonal projection [20] is applied to circumvent the prob-
lem of overlapping absorbance features in the MIR spectra collected on a pilot-scale an-
aerobic digester to monitor volatile fatty acid (VFA) concentrations.

**2. Materials and Methods**

## 2.1. *Experimental Procedure*

2.1.1. Process

A 1-cubic-meter pilot-scale AD fixed-bed reactor was used to assess the response to organic overloads and toxicant shock loads. The prime objective was to use advanced online instrumentation available in the process to analyze, in dynamic conditions, the effects of disturbances on the overall efficiency of the process. Among the different possible disturbances (e.g., modification of the feed characteristics, presence of a toxicant, change in process temperature, etc.), only the effect of ammonia addition on the measurement of total volatile fatty acids using MIRS was studied in the present work.

The effluents used were raw industrial wine wastewaters obtained from local winer-
ies in the area of Narbonne, France [21]. The process involved an up-flow anaerobic fixed-
bed reactor made of a circular column 3.5 m in height, 0.6 m in diameter, and with a useful
volume of 0.948 m³ [22]. The reactor was highly instrumented, with the following meas-
urements available online every two minutes: input and recirculation liquid flow rates,
pH of the reactor and of the input wastewater, temperature, biogas output flow rate, CO2,
CH4 and H2 composition in the gas phase, and total organic carbon (TOC) in the reactor.
Every half hour, measurements were taken using a titrimetric sensor and a MIR spectrom-
eter [23] to measure: total volatile fatty acids (VFA), soluble chemical oxygen demand
(COD), bicarbonate concentrations, and total and partial alkalinity in the liquid phase.
Since VFA are very important intermediates in the AD reaction scheme and can inhibit
the overall process, their measurement was considered in this study, together with their
robustness to the ammonia addition.
### 2.1.2. Addition of Ammonia in the Reactor

Ammonia-addition experiments were performed to assess robustness of the fixed-bed reactor when facing toxicant shock loads. In these experiments, ammonia from $NH_4Cl$ was chosen as the toxic compound, since it is known to be a strong inhibitor of methanogenesis [24–26].

During the process, different additions of ammonia took place at different times (days 0.0, 5.7, and 13.7). Table 1 and Figure 1 show the various events that occurred during this 15-day period.

<table><caption>**Table 1.** List of the events during the batch process and their impact on the VFA prediction.</caption><thead><tr><td>Time (Days)</td><td>Addition of Chemicals</td><td>Impact on the Predictions</td></tr></thead><tbody><tr><td>0</td><td>Addition of $NH_4Cl$ (low conc.)</td><td>Moderate negative bias</td></tr><tr><td>4.0</td><td>Addition of NaOH</td><td>Weak positive bias</td></tr><tr><td>5.7</td><td>Addition of $NH_4Cl$ (medium conc.)</td><td>Strong negative bias</td></tr><tr><td>9.3</td><td>Discharge and water circulation</td><td>None</td></tr><tr><td>10.0</td><td>Re-charge with wine waste</td><td>None</td></tr><tr><td>11.5</td><td>Stopping of the reactor</td><td>None</td></tr><tr><td>13.0</td><td>Restart of the reactor</td><td>None</td></tr><tr><td>13.7</td><td>Addition of $NH_4Cl$ (high conc.)</td><td>Strong negative bias</td></tr></tbody></table>

<figure><img src="image_5.png" /><figcaption>**Figure 1.** VFA concentration evolution measured by the reference titrimetric sensor (blue) and predicted by the raw PLSR (red). Vertical lines indicate the main events (Cf Table 1). Horizontal arrows indicate the measurements used for calibration and testing of the PLSR model.</figcaption></figure>

### 2.1.3. MIR Spectra Collected on the Bioreactor

MIR spectrometer (Nicolet AVATAR 360) was used to collect transmission spectra using a recirculation loop and a 50-micrometer flow cell. The resolution was set to 4 cm$^{-1}$. The fingerprint range (1572–1000 cm$^{-1}$) was kept, corresponding to 150 wavenumbers. A total of 616 spectra and corresponding VFA concentrations (mg/L) were measured online on equally spaced instants, over the course of 15 days.
## 2.2. Chemometrics

### 2.2.1. Notations

Capital bold characters are used for matrices, e.g., $\mathbf{X}$; small bold characters for column vectors, e.g., $\mathbf{x}_j$ denote the jth column of $\mathbf{X}$; row vectors are denoted by the transpose notation, e.g., $\mathbf{x}_i^T$ denotes the ith row of $\mathbf{X}$; non-bold characters are used for scalars, e.g., indexes, as $i$. When needed for clarity purposes, matrix dimensions are indicated as $\mathbf{X}_{(n,p)}$, where $n$ is the number of rows and $p$ the number of columns.

#### Model calibration

From the acquired dataset, two subsets were drawn (see Figure 1):

* A calibration set ($\mathbf{X}_0, \mathbf{y}_0$) made up of 100 spectra and VFA concentrations obtained during a sequence where the process was in a standard mode, i.e., between approx. days 9 and 13 (see Table 1 and Figure 1). This period corresponded to the restart of the reactor, so that the $\mathbf{y}_0$ values covered a wide range of VFA concentrations.

* A test set ($\mathbf{X}_1, \mathbf{y}_1$) was made up of all the acquired samples, containing 616 couples of spectra and VFA concentrations. This test set included various states of functioning, including normal states and ammonia-addition events.

VFA estimation from MIR spectra was carried out by means of a PLSR [27], without any preprocessing of the spectra apart from column mean centering. PLSR estimates a response $\mathbf{y}$ by a linear combination of the columns of $\mathbf{X}$: $\hat{\mathbf{y}} = \mathbf{X}\mathbf{b} + \mathbf{r}$. Since columns of $\mathbf{X}$ are highly correlated, an ordinary least-squares regression cannot be used. Instead, PLSR proceeds by first calculating a latent variables, which are linear combinations $\{\mathbf{u}_1, \mathbf{u}_2, ..., \mathbf{u}_a\}$ of the columns of $\mathbf{X}$, which maximize $cov^2(\mathbf{X}\mathbf{u}_i, \mathbf{y})$ with the constraint $\mathbf{X}\mathbf{u}_i \perp \mathbf{X}\mathbf{u}_j, \text{ for } i \neq j$. Next, a linear regression is calculated between $(\mathbf{X}\mathbf{u}_i)$ and $\mathbf{y}$. Subsequently, the vector $\mathbf{b}$ is obtained by merging the latent variable loadings $\mathbf{U}$ and the regression coefficients of the linear regression. To set the number of latent variables $a$, a 2-random-blocks cross-validation was performed and repeated 10 times. The value of $a$ was set as the one yielding the lower RMSECV. The raw PLSR model was thus built on 5 latent variables and yielded the predictions reported in Figure 1.

### 2.2.2. Dynamic Orthogonal Projection

When a perturbation $\delta\mathbf{x}$ is added to a spectrum $\mathbf{x}$, an error $\delta\hat{\mathbf{y}} = \delta\mathbf{x}^T\mathbf{b}$ is added to the estimation of the response $\hat{\mathbf{y}}$. Orthogonal projection (OP) methods aim to reduce this error by constraining the PLSR to build a $\mathbf{b}$ orthogonal to $\delta\mathbf{x}$, thus lowering $\delta\hat{\mathbf{y}}$. OP methods start by identifying the subspace spanned by the $\delta\mathbf{x}$ (detrimental subspace). An orthonormal basis $\mathbf{P}_{(pk)}$ of this subspace is calculated, and then $\mathbf{X}_{(np)}$ is projected onto the subspace orthogonal to $\mathbf{P}$, resulting in the corrected spectra:

$$ \tilde{\mathbf{X}}_{(np)} = \mathbf{X} - \mathbf{XPP}^T \quad (1) $$

This projection acts by removing linear combinations of columns of $\mathbf{X}$, i.e., it removes a spectral subspace from the space spanned by $\mathbf{X}$. The estimation of $\mathbf{P}$ is the key to orthogonal correction. This estimation commonly uses a set of dedicated experiments, incorporating systematic variations. Let $\mathbf{D}_{(mp)}$, be a matrix of $m$ spectra generated by the detrimental variations only. A PCA is carried out on $\mathbf{D}$ and the first $k$ loadings are inserted in $\mathbf{P}$. Different methods are used to build the $\mathbf{D}$ matrix. In the IIR method [28], the matrix $\mathbf{D}$ is built with samples that do not contain the component of interest but include variations due to the influencing factors. Its main disadvantage is that it requires two matrices to correct the spectra, which are often not available. In the EPO method [12], the matrix $\mathbf{D}$ is built using a small set of appropriate samples measured at different levels of the influence factor. This method does not require the $\mathbf{y}$ reference measurements. However, only known influence factors (temperature, scale, instruments, etc.) can be considered, while unknown factors cannot.

The DOP method [20] was developed to cope with variations due to unknown factors. The specific advantage of DOP over other OP methods is that it does need standard
samples, nor experimental designs. It uses a few control points, for which the true value of y is known. Let (X₀, y₀) be a calibration set containing n₀ samples. Let yᵣ be the values of y measured at nᵣ control points and Xᵣ the corresponding acquired spectra. The DOP method runs as follows:

* First, estimate the ideal spectra Zᵣ, which should be measured in the absence of influencing factors. This produces two matrices (Xᵣ, Zᵣ) similar to those measured in the case of standard samples used for calibration transfer or calibration qualification test, except that these samples are rarely available for online applications.

* Second, compute the D matrix as the difference between the measured spectra and the ideal spectra:

$$D = X_r - Z_r \quad (2)$$

* Third, extract the k first loadings of a PCA computed on D and insert them in P.

* Project X₀ orthogonal to P and recalibrate the model.

Estimating Zᵣ is the cornerstone of the DOP approach. This estimation must be performed using only the calibration set (X₀, y₀), and the control points yᵣ. The most straightforward method consists in computing a linear combination A(nᵣn₀) of y₀ that estimates yᵣ and then to applying it to X₀:

* Calculate A so that:

$$y_r \approx Ay_0 \quad (3)$$

* Apply A on X₀:

$$Z_r = AX_0 \quad (4)$$

The calculation of A can be performed in different ways. The kNN (nearest-neighbors) method consists of calculating the distance between the sample to be estimated and all the samples from the calibration database to select the k nearest ones used for estimation. Different variants of this method can be used, such as giving more weight to the closest samples. This method is commonly used in classification. This is a simple method that makes no statistical assumption about the normality of distribution. The kernel methods generalize the kNN; they use a kernel function to estimate the density function of a population, which can then be used to weigh an estimate. Different kernel functions can be used: uniform, triangular, Gaussian, etc. Gaussian kernels are commonly used.

In this study, a Gaussian kernel was used, so that the A matrix was calculated as follows:

$$a_{ij} = \frac{1}{\varepsilon\sigma_0\sqrt{2\pi}} e^{-\frac{(y_{0i}-y_{rj})^2}{2\varepsilon^2\sigma_0^2}} \quad (5)$$

where σ₀ is the standard deviation of y₀ and ε is a parameter adjusting the width of the kernel. In [20], it is theoretically justified that a good value for ε is 1/n₀, if y₀ is uniformly distributed. It was verified that this value is adapted to most distributions of y₀ and it was adopted as a rule of thumb. The same approach was therefore applied in this study.

Since the original calibration database is transformed by means of an orthogonal projection, the correction is embedded into the model [14,15]. Consequently, there is no need to correct new spectra when using the model.

### 2.2.3. Figures of Merit

The quality of prediction was assessed by means of the following figures of merit:

* Root Mean Square Error of Calibration:

$$RMSEC = \sqrt{\frac{\sum (y_i - y_{i0})^2}{N - LV - 1}} \quad (6)$$
* Root Mean Square Error of Cross-Validation:

$$RMSECV = \sqrt{\frac{\sum (\hat{y}_i - y_i)^2}{N}} \qquad (7)$$

* Root Mean Square Error of Prediction:

$$RMSEP = \sqrt{\frac{\sum (\hat{y}_i - y_i)^2}{N}} \qquad (8)$$

* Bias:

$$Bias = \frac{\sum (\hat{y}_i - y_i)}{N} \qquad (9)$$

### 3. Results and Discussion

The cross-validation of the raw PLSR model exhibited a RMSECV of about 58 mg/L for five latent variables. In [29], tests using regular conditions yielded RMSEP values of 156 mg/L and 235 mg/L for the acetic acid and propionic acid, respectively. In [30], a RMSEP of 372 mg/L was exhibited for the VFA prediction. Considering that the RMSEP is usually higher than the RMSECV, and considering that our samples were dependent, we consider that the performance we observed was in accordance with the literature.

The PLSR model was applied to the entire test set. Its global bias was -626 mg/L and the RMSEP was 1310 mg/L. The predictions are reported as a function of time in Figure 1. In the interval between days 9.3 and 13.0, which corresponds more or less to the calibration data, the predictions fit the reference value very well, despite small variations. However, Figure 1 shows that all the ammonia additions (days 0, 5.7 and 13.7) had a very detrimental effect on the model. After each addition, the VFA prediction was strongly negatively biased. The intensity of the bias was related to the amount of ammonia added. The effect on the model was immediate, showing that the model was directly affected by the ammonia spectra.

Figure 2 shows the MIR spectra, as a function of time. The effect of ammonia additions on the spectra is clearly visible. After the addition of ammonia, the intensity of the spectral deformation slowly decreased as the spectral ammonia contribution disappeared. The ammonia had an effect on the model because the ammonia spectrum had peaks in areas where the b-coefficients of the PLSR were non-null. In [31], MIR spectra of various forms of ammonia are analyzed. A peak at 1450 cm⁻¹ is reported as being linked to the symmetric deformation mode v4 of NH₄⁺. This peak corresponds to the main peak appearing in Figure 2 at each ammonia addition.
<figure><img src="image_6.png" /><figcaption>**Figure 2.** The MIR spectra collected with the addition of ammonia.</figcaption></figure>

In order to correct the PLSR model for the effect of the ammonia absorbance in the spectral region of interest, the DOP method was used. Two correction points were chosen at day 0.2 (spectrum number 10) and time 6.2 (spectrum number 270) to perform the DOP with ε = 0.01 and using the maximal number of components for the orthogonalization, i.e., k = 1 and k = 2, respectively. The number of latent variables of the DOP-corrected models was set to 4, for both correction points. Figure 3 shows the prediction after DOP application, clearly demonstrating the improvement in the PLSR model predictions resulting from the DOP. After the first DOP correction, it can be observed that the negative bias of the raw model was almost completely corrected by the DOP. After the large addition of ammonia, on day 5.7, it can be observed that the DOP corrected model still suffered from a negative bias, albeit much less intense than in the raw model. After the second DOP correction, the model became completely insensitive to ammonia additions, including a very significant addition of ammonia at day 13.7. It is also noticeable that the model continued to work in the absence of ammonia, i.e., from day 9 to day 13. This shows that the DOP correction does not simply compensate for the influence, as would be the case in a bias/slope correction, but also makes the model independent of the influence, whatever its level.
<figure><img src="image_7.png" /><figcaption>**Figure 3.** Prediction of the raw PLSR model (red) and of the DOP PLSR model (blue) after correction with DOP at point 1 after first addition of ammonia and point 2 after the second, more concentrated, addition of ammonia. Points A, B, and C correspond to low VFA/low ammonia; medium VFA/low ammonia; and high VFA/high ammonia. Dotted vertical lines show the moments of ammonia addition (cf. Figure 1 and Table 1). Dashed vertical lines show the control points used by DOP.</figcaption></figure>

The implementation of the DOP requires the setting of the value of two parameters: ε, related to the width of the kernel, and *k*, the dimension of the subspace removed by the orthogonalization step. In this study, the value of ε was fixed following the rule of thumb proposed in [20], and the value of *k* was chosen as its maximum value, i.e., the number of available control points. In real industrial applications, these two parameters must be set according to each particular situation. The value of ε depends only on the y-distribution of the calibration set and can be adjusted when setting up the model. The value of *k* must be adjusted each time the DOP correction is performed. This can be achieved through various generic orthogonal projection methods, as described in [15]. The goal of this adjustment is to remove enough dimensions to correct the problem found by the control points, while preserving the predictive power of the model. A method well suited to DOP is to observe the cross-validation error of the PLS as a function of *k*, and then adopt the largest value of *k* that does not alter the model.

After DOP correction, the PLSR model presented a bias of -19.1 mg/L and an RMSEP of 127 mg/L that were 30 and 10 times less than those of the raw model, respectively. The effect was spectacular, since DOP correction reduced the bias by a factor of approximately 30 and the RMSEP by a factor of approximately 10. The RMSEP of the corrected model was lower than the values reported in the literature, discussed above.

Figure 4 shows the effect of the DOP correction on the three spectra corresponding to points A, B, and C on Figure 3. These three points correspond to VFA amounts of 623, 1476, and 2060 mg/L, respectively, i.e., to three levels in proportions of approximately 1, 2, and 3. The spectra of points A and B were not affected by the ammonia, while the spectrum of point C was. In Figure 4a, which represents the raw spectra, we can observe that there was no proportionality at all between the three spectra, especially in the range of 1300–1500 cm⁻¹. In Figure 4b, we can observe that the three spectra are properly ordered, in a proportional scale, over the whole wavenumber range after the DOP correction. More precisely, the three spectra coincide over a wide range, from 1000 to 1350 cm⁻¹ and separate in two peaks in the zone of 1350–1700 cm⁻¹. It is clear from these figures that the DOP
removed all the features that were affected by the ammonia, thus producing very mean-
ingful corrected spectra.

<figure><img src="image_8.png" /><figcaption>**Figure 4.** Illustration of the DOP correction. Spectra of the three points, A, B, and C, shown in Figure 3, corresponding to VFA = 623, 1476, and 2060 mg/L. (a) Before DOP correction. (b) After DOP correction.</figcaption></figure>

A point of discussion must be addressed regarding spectra pretreatments. First, it
should be noted that DOP is not really a form of preprocessing. It is a method that changes
the calibration of the PLS, forcing it to produce a model that is insensitive to the problems
that arise. Second, preprocessing is generally used to improve the performance of the cal-
ibration by removing detrimental information contained in the spectra, such as additive
or multiplicative effects. Some authors also claim that pretreatments increase the robust-
ness of the models [32]. This is only true if the effect removed by the preprocessing is the
one added by the event causing the robustness problem. For example, if the robustness
problem is caused by a change in light scattering, it is likely that a baseline reduction will
have a beneficial effect on the robustness. Therefore, preprocessing can address the ro-
bustness problems that are known when the calibration is performed. This article ad-
dresses a case in which the events causing the robustness problem were not known when
the calibration was performed, i.e., ammonia addition. This is why it was decided to not
preprocess the spectra at all.

In this study, the power of the DOP correction was demonstrated and described, on
the basis on two well-chosen control points. Indeed, they were chosen at two instants just
after ammonia addition (days 0 and 5.7). In order to test the influence of the number of
control points and of their placements on the process, the following procedure was carried
out: *N* points were drawn at random across the whole time range; next, the DOP correction was applied using 1, ..., *N* points, simulating the real process; and subsequently, the RMSEP was calculated. These steps were repeated 100 times, for *N* ranging from 1 to 15. Figure 5 reports the results of these simulations, using boxplots. It can be observed that even for a low number of control points, the DOP produced efficient corrections in the majority of cases. Until *N* = 3, some DOP-corrected models were worse than the raw model, indicating that an appropriate choice of control points is important when they are few. It is possible to imagine that if the control points for calculating DOP are determined when there is no difference between the online and calibration conditions, the correction does not work correctly. This possibility becomes less and less likely as *N* increases. This confirms, as seen previously, that DOP correction is effective with a small number of points that are chosen when disturbances are present. This highlights the potential of integrating DOP in the toolbox of process analytical technology [33].

<figure><img src="image_9.png" /><figcaption>**Figure 5.** Summaries of RMSEP obtained after DOP correction, as a function of the number of control points used. Each boxplot represents the distribution of the RMSEP values obtained after 100 repetitions with randomly chosen control points. Horizontal red line indicates the median, while the edges of the boxes are the first and third quartiles. Dashed whiskers extend to the most extreme data not considered as outliers. Horizontal dashed line indicates the RMSEP of the raw PLSR.</figcaption></figure>

**4. Conclusions**

This study highlighted the potential of infrared spectroscopy for the advanced monitoring of complex biological processes, such as anaerobic digestion. In particular, the proposed usage of the dynamic orthogonal projection method significantly improved the robustness of the calibration model and can circumvent the problem of unexpected changes in process operations (e.g., the presence of reactive compounds not accounted for during the calibration phase). This was demonstrated on a 1-cubic-meter pilot-scale anaerobic digester by online measurements of volatile fatty acid concentrations, which were still accurate despite the presence of ammonia. This creates significant possibilities for the optimization of anaerobic digestion processes. Indeed, organic overloads and toxicant shock loads can damage the performances of digesters and strongly affect biogas production. The proposed approach, by efficiently handling these disturbances, paves the way to industrial applications.

**Author Contributions:** Data curation, M.Z., É.L., P.G., J.-P.S. and J.-M.R.; formal analysis, M.Z. and J.-M.R.; investigation, J.-P.S.; methodology, J.-M.R.; software, J.-M.R.; supervision, J.-P.S., V.B.-M. and J.-M.R.; validation, É.L., J.-P.S. and V.B.-M.; writing—original draft, M.Z.; writing—review and editing, J.-P.S. and J.-M.R. All authors have read and agreed to the published version of the manuscript.
**Funding:** This research received no external funding.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Not applicable.

**Conflicts of Interest:** The authors declare no conflict of interest.

## References

1. Wang, L.; Sun, D.W.; Pu, H.; Cheng, J.H. Quality analysis, classification, and authentication of liquid foods by near-infrared spectroscopy: A review of recent research developments. *Crit. Rev. Food Sci. Nutr.* **2017**, *57*, 1524–1538.

2. Karoui, R.; Downey, G.; Blecker, C. Mid-infrared spectroscopy coupled with chemometrics: A tool for the analysis of intact food systems and the exploration of their molecular Structure-Quality relationships—A review. *Chem. Rev.* **2010**, *110*, 6144–6168.

3. Kornmann, H.; Valentinotti, S.; Duboc, P.; Marison, I.; Von Stockar, U. Monitoring and control of Gluconacetobacter xylinus fed-batch cultures using in situ mid-IR spectroscopy. *J. Biotechnol.* **2004**, *113*, 231–245.

4. Amrhein, M. *Reaction and Flow Variants/Invariants for the Analysis of Chemical Reaction Data (No. THESIS)*; EPFL: Lausanne, Switzerland, 1998.

5. Amrhein, M.; Srinivasan, B.; Bonvin, D.; Schumacher, M.M. Calibration of spectral reaction data. *Chemom. Intell. Lab. Syst.* **1999**, *46*, 249–264.

6. Chung, H.; Arnold, M.A.; Rhiel, M.; Murhammer, D.W. Simultaneous measurements of glucose, glutamine, ammonia, lactate, and glutamate in aqueous solutions by near-infrared spectroscopy. *Appl. Spectrosc.* **1996**, *50*, 270–276.

7. Rhiel, M.; Cannizzaro, C.; Valentinotti, S.; Marison, I.; von Stockar, U. *Comprehensive In-Situ Bioreactor Monitoring and Control Based on a Mid-Infrared Spectroscopic Sensor System*; EPFL Scientific Publications: Lausanne, Switzerland, 2000.

8. Brown, S.D.; Huwei, T.; Feudale, R. Improving the robustness of multivariate calibrations. In *ACS Symposium Series*; Oxford University Press: Oxford, UK, 2005; Volume 894, pp. 15–30.

9. Dabros, M. Robust Model Development and Enhancement Techniques for Improved On-Line Spectroscopic Monitoring of Bio processes. Ph.D. Thesis, EPFL Scientific Publications: Lausanne, Switzerland, 2008.

10. Zeaiter, M.; Roger, J.M.; Bellon-Maurel, V.; Rutledge, D.N. Robustness of models developed by multivariate calibration. Part I: The assessment of robustness. *TrAC Trends Anal. Chem.* **2004**, *23*, 157–170.

11. Zeaiter, M.; Roger, J.M.; Bellon-Maurel, V. Robustness of models developed by multivariate calibration. Part II: The influence of pre-processing methods. *TrAC Trends Anal. Chem.* **2005**, *24*, 437–445.

12. Roger, J.M.; Chauchard, F.; Bellon-Maurel, V. EPO-PLS external parameter orthogonalisation of PLS application to temperature-independent measurement of sugar content of intact fruits. *Chemom. Intell. Lab. Syst.* **2003**, *66*, 191–204.

13. Chauchard, F.; Roger, J.M.; Bellon-Maurel, V. Correction of the temperature effect on near infrared calibration—Application to soluble solid content prediction. *J. Near Infrared Spectrosc.* **2004**, *12*, 199–205.

14. Boulet, J.C.; Roger, J.M. Pretreatments by means of orthogonal projections. *Chemom. Intell. Lab. Syst.* **2012**, *117*, 61–69.

15. Roger, J.M.; Boulet, J.C. A review of orthogonal projections for calibration. *J. Chemom.* **2018**, *32*, e3045.

16. Brémond, U.; de Buyer, R.; Steyer, J.P.; Bernet, N.; Carrere, H. Biological pretreatments of biomass for improving biogas production: An overview from lab scale to full-scale. *Renew. Sustain. Energy Rev.* **2018**, *90*, 583–604.

17. Weiland, P. Biogas production: Current state and perspectives. *Appl. Microbiol. Biotechnol.* **2010**, *85*, 849–860.

18. Brémond, U.; Bertrandias, A.; Steyer, J.P.; Bernet, N.; Carrere, H. A vision of European biogas sector development towards 2030: Trends and challenges. *J. Clean. Prod.* **2021**, *287*, 125065.

19. Jimenez, J.; Latrille, E.; Harmand, J.; Robles, A.; Ferrer, J.; Gaida, D.; Wolf, C.; Mairet, F.; Bernard, O.; Alcaraz-Gonzalez, V.; et al. Instrumentation and control of anaerobic digestion processes: A review and some research challenges. *Rev. Environ. Sci. Bio/Technol.* **2015**, *14*, 615–648.

20. Zeaiter, M.; Roger, J.M.; Bellon-Maurel, V. Dynamic orthogonal projection. A new method to maintain the on-line robustness of multivariate calibrations. Application to NIR-based monitoring of wine fermentations. *Chemom. Intell. Lab. Syst.* **2006**, *80*, 227–235.

21. Batstone, D.J.; Steyer, J.P. Use of modelling to evaluate best control practice for winery-type wastewaters. *Water Sci. Technol.* **2007**, *56*, 147–152.

22. Steyer, J.P.; Bouvier, J.C.; Conte, T.; Gras, P.; Sousbie, P. Evaluation of a four year experience with a fully instrumented anaerobic digestion process. *Water Sci. Technol.* **2002**, *45*, 495–502.

23. Steyer, J.P.; Bouvier, J.C.; Conte, T.; Gras, P.; Harmand, J.; Delgenes, J.P. On-line measurements of COD, TOC, VFA, total and partial alkalinity in anaerobic digestion processes using infra-red spectrometry. *Water Sci. Technol.* **2002**, *45*, 133–138.

24. Koster, I.W.; Lettinga, G. The influence of ammonium-nitrogen on the specific activity of pelletized methanogenic sludge. *Agric. Wastes* **1984**, *9*, 205–216.

25. Koster, I.W.; Lettinga, G. Anaerobic digestion at extreme ammonia concentrations. *Biol. Wastes* **1988**, *25*, 51–59.

26. Hansen, K.H.; Angelidaki, I.; Ahring, B.K. Anaerobic digestion of swine manure: Inhibition by ammonia. *Water Res.* **1998**, *32*, 5–12.
27. Geladi, P.; Kowalski, B.R. Partial least-squares regression: A tutorial. *Anal. Chim. Acta* **1986**, *185*, 1-17.

28. Hansen, P.W. Pre-processing method minimizing the need for reference analyses. *J. Chemom. A J. Chemom. Soc.* **2001**, *15*, 123-131.

29. Falk, H.M.; Reichling, P.; Andersen, C.; Benz, R. Online monitoring of concentration and dynamics of volatile fatty acids in anaerobic digestion processes with mid-infrared spectroscopy. *Bioprocess Biosyst. Eng.* **2015**, *38*, 237-249.

30. Wolf, C.; Gaida, D.; Rehorek, A.; Bongards, M. Online monitoring of AD processes using a fully automated, low maintenance middle-infrared (MIR) measurement system. In Proceeding of the 2nd International Conference Biogas Science 2014, Vienna, Austria, 26-30 October 2014; Volume 2014, pp. 24-25.

31. Max, J.J.; Chapados, C. Aqueous ammonia and ammonium chloride hydrates: Principal infrared spectra. *J. Mol. Struct.* **2013**, *1046*, 124-135.

32. de Noord, O.E. The influence of data preprocessing on the robustness and parsimony of multivariate calibration models. *Chemom. Intell. Lab. Syst.* **1994**, *23*, 65-70.

33. Challa, S.; Potumarthi, R. Chemometrics-based process analytical technology (PAT) tools: Applications and adaptation in pharmaceutical and biopharmaceutical industries. *Appl. Biochem. Biotechnol.* **2013**, *169*, 66-76.