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

Article

# Rapid Detection of Aflatoxins in Ground Maize Using Near Infrared Spectroscopy

Sylviane Bailly<fnref n="1" />, Béatrice Orlando<fnref n="2" /> ID, Jean Brustel<fnref n="3" />, Jean-Denis Bailly 4,* ID and Cecile Levasseur-Garcia 5 ID

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

check for
updates

**Citation:** Bailly, S.; Orlando, B.; Brustel, J.; Bailly, J.-D.; Levasseur-Garcia, C. Rapid Detection of Aflatoxins in Ground Maize Using Near Infrared Spectroscopy. *Toxins* **2024**, *16*, 385. https://doi.org/10.3390/toxins16090385

Received: 26 July 2024
Revised: 29 August 2024
Accepted: 1 September 2024
Published: 4 September 2024

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

**Copyright:** © 2024 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/).

**Abstract:** Aflatoxins are carcinogenic mycotoxins that may contaminate many crops and more especially maize. To protect consumers from these contaminants, many countries set up low regulatory thresholds of few µg/kg. The control of food requires time-consuming analysis for which sampling is a key step. It would therefore be of key sanitary and economic relevance to develop rapid, sensitive and accurate methods that could even be applied on line at harvest, to identify batches to be excluded as soon as possible. In this study, we analyzed more than 500 maize samples taken at harvest during 3 years for their aflatoxin contamination using HPLC-MS. Among them, only 7% were contaminated but sometimes at levels largely exceeding European regulations. We demonstrate that Near InfraRed Spectroscopy (NIRS) could be of great help to classify cereal samples according to their level of aflatoxin contamination (below or higher than E.U. regulation). To build the model, all AF contaminated samples as well as an equivalent number of AF free samples were used. NIRS performance was not sufficient to quantify the toxins with adequate precision. However, its ability to discriminate naturally contaminated maize samples according to their level of contamination with aflatoxins in relation to European regulations using a quadratic PCA-DA model was excellent. Accuracy of the model was 97.4% for aflatoxin B1 and 100% for total aflatoxins.

**Keywords:** aflatoxins; maize; rapid detection; near infrared spectroscopy

**Key Contribution:** This study demonstrates that NIRS can be used to rapidly classify ground maize samples as a function of their aflatoxin level in relation to E.U. regulations.

## 1. Introduction

Aflatoxins (AF) are mycotoxins produced by *Aspergillus* section *Flavi* and that may contaminate many crops [1]. Among cereals, maize is the most susceptible crop and it may be contaminated both in the field, before harvest, or later during storage in case of insufficient drying or remoistening [2]. Both aflatoxin B1 (AFB1) and the mixture of AF (B1, B2, G1 and G2) are classified by IARC in the group I of carcinogenic compounds for Human [3]. Indeed, they are genotoxic, mutagenic and responsible for the appearance of hepatocarcinoma [4]. AF were also demonstrated to induce growth retardation in children and to be toxic for the immune system [5,6]. AFB1 is among the natural contaminants leading to the highest number of DALYs (Disabled Adjusted Life Years) [7].

The toxicity of AF led more than 100 countries to set up regulations to prevent consumers' exposure to these contaminants [8]. As an illustration, for AFB1, in Europe, these limits range between 2 and 12 µg/kg in foods and from 5 to 20 µg/kg in feed as a function

<footnote n="1">1 Mycoscopia, 3 rue Jean Monnet, 31470 Fonsorbes, France; mycoscopia@gmail.com</footnote>

<footnote n="2">2 Arvalis Institut du Végétal, Station Expérimentale, 91720 Boigneville, France; b.orlando@arvalis.fr</footnote>

<footnote n="3">3 Physiologie, Pathologie et Génétique Végétales (PPGV), Université de Toulouse, INP-PURPAN, 75 Voie du Toec, 31076 Toulouse, France; jean.brustel@gmail.com</footnote>

<footnote n="4">4 Laboratoire de Chimie Agro-Industrielle (LCA), Université de Toulouse, INRAE, INPT, École Nationale Vétérinaire de Toulouse, 23 Chemin des Capelles, 31076 Toulouse, France</footnote>

<footnote n="5">5 Laboratoire de Chimie Agro-Industrielle (LCA), Université de Toulouse INRAE INPT, INP-PURPAN, 31076 Toulouse, France</footnote>

<footnote>* Correspondence: jean-denis.bailly@envt.fr; Tel.: +33-(0)561-193-229</footnote>
of the species [9]. Due to the existence of these strict regulatory limits, the classification of crop batches according to their level of contamination with AF at harvest is of primary importance to be able to sort and orient them towards the best possible usage.

To date, the gold method for AF analysis relies on HPLC with different modes of toxin detection. The natural fluorescence of these molecules being often used to detect them after liquid chromatography separation [10]. However, such method requires expensive equipment and is highly dependent of the quality of the sampling. Indeed, mycotoxin contamination is generally heterogeneous, and results may strongly differ as a function of the sampling methodology. Some rules were set up to define the correct sampling procedure for mycotoxin analysis of food and feed batches [11]. But their realization in practice is often complicated due to the high number of subsamples that shall be taken to be representative of a whole batch. Another important limitation is time required for analysis since, for cereals, the time between harvest and storage is often very limited. It is not possible to block batches waiting for the results of the analysis. Other rapid methods were developed for AF analysis, such as immunoassays [12]. But, as HPLC, most are destructive and results directly depends on the sampling quality.

Within this context, the development of analytical methods that could allow an online, non-destructive analysis of AF in grains at harvest would be of major interest. It could help sort grains as a function of their level of contamination and direct them towards the best valorization possible. Among possible methodologies, Near InfraRed Spectroscopy (NIRS) emerge as a good candidate since rapid, non-destructive, and able to simultaneously measure multiple components in complex matrices [13].

NIRS uses Near InfraRed light (800–2500 nm) to analyze the chemical properties of samples. By absorbing specific wavelengths, chemical bonds (C, H, O, N) reveal composition and molecular structure. Applied in agriculture, feed and food industry, pharmaceuticals, environmental monitoring, NIRS is fast, non-destructive, and requires no complex sample preparation.

Many studies have used NIRS to quantify diverse mycotoxins in food and feed [for review, see [14]]. Regarding AFB1 detection, some recent works tried to use NIR spectroscopy to analyze maize grains. Wang (2022) proposed a novel approach for monitoring AFB1 content in maize using deep learning models based on NIR spectra, with the following performance: a Root Mean Square Error of Prediction (RMSEP) of 1.3591 µg/kg and a predictive determination coefficient of 0.9955 [15]. Deng (2022) created Support Vector Machine (SVM) models with an RMSEP of 3.5967 µg/kg, a determination coefficient (R²) of 0.9707, and a Relative Prediction Deviation (RPD) of 5.7538 [16]. Finally, Liu (2022) established back propagation neural network (BPNN) models with a correlation coefficient of 0.9951 and a RMSEP of 1.5606 µg/kg [17]. The main conclusions were that quantification of mycotoxins is possible but not precise enough for targeted thresholds, notably for AFB1 for which very low regulatory thresholds of few µg/kg are set for food in Europe [9]. Moreover, these studies were done using artificially contaminated maize, which can modify spectral response compared to naturally contaminated one.

Within this context, the objective of this study was to develop a new approach based on NIR spectroscopy aiming not to quantify AFB1 in samples but to sort them according to their risk of contamination above or under the regulatory limit of 2 µg/kg for AFB1 and/or 4 µg/kg for total AF, using a set of naturally contaminated samples harvested during three years in French fields.

To develop a method that can be further transferred to the maize sector, we collected spectra using a portable spectrometer which offers numerous advantages: it is compact and easy to carry, allowing for on-site analysis and real-time data collection in various locations (as in silos for grain storage). It can be used directly in real industrial environments, providing accurate and immediate measurements without the need for sample transportation to a laboratory. Additionally, portable spectrometers are generally less expensive compared to traditional laboratory spectrometers, making them a cost-effective solution. These devices are designed to be user-friendly, requiring minimal training to operate, which enhances
efficiency and reduces the likelihood of errors. The simplicity and affordability of portable spectrometers also make advanced analytical techniques accessible to a broader range of users, including small businesses and educational institutions.

## 2. Results and Discussion

### 2.1. Sample Contamination with Aflatoxins

A total of 554 samples was collected from French fields at harvest during 2018–2020. They were analyzed for aflatoxin contamination using HPLC-MS. Table 1 summarizes the obtained results.

<table><caption>**Table 1.** Characteristics of AFB1 and Total aflatoxin contamination of the samples included in the study.</caption><thead><tr><th></th><th>AFB1</th><th>Total Aflatoxins</th></tr></thead><tbody><tr><td>Number of analyzed samples</td><td>554</td><td>554</td></tr><tr><td>Number of contaminated samples</td><td>38</td><td>39</td></tr><tr><td>Minimum (µg/kg)</td><td>0.015</td><td>0.015</td></tr><tr><td>Maximum (µg/kg)</td><td>30.17</td><td>73.07</td></tr><tr><td>Mean of contaminated samples (µg/kg)</td><td>3.78</td><td>5.94</td></tr><tr><td>Samples > regulation *</td><td>11</td><td>9</td></tr><tr><td>Variance (n − 1) (µg/kg)</td><td>55.58</td><td>183.09</td></tr><tr><td>Standard deviation (n − 1) (µg/kg)</td><td>7.46</td><td>13.53</td></tr></tbody></table>

Aflatoxins are still emerging contaminants in France and more than 90% of the samples had no detectable levels of aflatoxins, indicating a large number of samples were either free of aflatoxins or contained them below detectable levels. The maximum level of AFB1 detected was 30.17 µg/kg, while the total AF reached up to 73.07 µg/kg. The mean levels of contamination in contaminated samples were 3.78 µg/kg and 5.94 µg/kg for AFB1 and the sum of AF, respectively. It decreased to 0.270 µg/kg and 0.435 µg/kg when considering all samples.

Aflatoxin B1 showed a variance of 55.58 µg/kg and a standard deviation of 7.46 µg/kg, indicating high variability in the data. Total AF had a higher variance of 183.09 µg/kg and a standard deviation of 13.53 µg/kg, showing greater dispersion and a few extreme values influencing the dataset.

The European Union (EU) has set strict regulatory limits for AF in food to protect public health [9]. Only 2% (n = 11) of samples exceeded the limit of 2 µg AFB1/kg and 1.6% (n = 9) exceeded the limit for total AF content set at 4 µg/kg. Even if in low proportion, contaminated samples sometimes displayed quite high levels of contamination, highlighting the need to identify and exclude them from Human consumption as soon as possible at harvest, and before storing them. Indeed, AF contamination can increase during storage in case of development of aflatoxigenic species due to incomplete drying or remoistening [18]. Such detection requires a rapid method, possibly usable online.

The aim of this study was to develop an infrared prediction model for aflatoxin levels. However, the predominance of samples with low contamination levels could bias the model. To mitigate this, we conducted a targeted sampling that included all samples with detectable aflatoxin levels and an equal number of samples with non-detectable levels. Considering the three years of data, 2018, 2019, and 2020, a Kennard and Stone sampling was performed to select 38 samples with undetectable total aflatoxin levels. These samples were issued from 2018 (n = 7), 2019 (n = 4) and 2020 (n = 28) harvest to mimic the number of contaminated samples for these three years.

### 2.2. Quantification of Aflatoxins Contents Using NIRS

#### 2.2.1. Spectra Acquisition

A MicroNIR OnSite spectrometer (Viavi Solutions Inc., San Jose, CA, USA) was used in reflectance mode to acquire NIR spectra from crushed grains over the spectral range

<footnote>* 2 µg/kg for AFB1 alone or 4 µg/kg for the sum of aflatoxins.</footnote>
of 908–1676 nm, consisting of 125 variables. Each spectrum represents the average of 100 scans, taken with an integration time of 10 ms and a spectral resolution of 6 nm. The raw spectra of all samples are presented on Figure 1.

<figure><img src="image_4.png" /><figcaption>**Figure 1.** Raw spectra of maize samples across Wavelengths 908–1650 nm.</figcaption></figure>

The spectra show notable variations in reflectance, especially in the 900–1000 nm region, which shows a rapid decrease with a significant dip around 960 nm, possibly due to absorptions from water (OH) and organic compounds. The 1100–1300 nm zone is stable with slightly increasing reflectance. In the 1400–1500 nm range, there is a notable increase, plateauing around 1460 nm, often due to the first harmonic of OH and NH bonds. After 1500 nm, reflectance slightly decreases. These spectral variations may indicate differences in the composition and properties of the samples, likely due to the presence of fungi, their metabolism, and the resulting modifications in the maize [19].

### 2.2.2. Partial Least Squares Regression (PLS) Model

A PLS model was developed using AFB1 and total AF contents as the response variables and wavelengths (125 variables) as the explanatory variables. This approach effectively handles collinear and noisy spectral data, reduces dimensionality, and preserves relevant information, resulting in more accurate predictions of AF levels and better contamination monitoring. The model was developed using 80% of the samples, selected with the Kennard and Stone algorithm, and validated on the remaining 20%. So, the calibration set included 54 samples, while the validation set included 12 samples. The percentage of contaminated samples (AFB1 content > 2 µg/kg) was 50% in both the calibration and validation sets. Several commonly used mathematical preprocessings in NIRS were tested on the raw spectra. The modeling on SNV (Standard Normal Variate) + D1 (first derivative) preprocessed spectra showed the best performance for predicting AFB1 content in ground corn samples with a determination coefficient $r^2$cv = 0.97, a Root Mean Square Error of Cross-Validation (RMSECV) of 1.44 µg/kg, a Ratio of Performance to Deviation in Cross-Validation (RPDcv) of 6.3, a $r^2$test of 0.56, a Root Mean Square Error of Prediction (RMSEP) of 6.6 µg/kg, and a RPDtest of 1.4. The best PLS regression model performance was also obtained on SNV + D1 preprocessed spectra for total AF: $r^2$cv = 0.99, RMSECV = 1.88 µg/kg, RPDcv = 9.0, $r^2$test = 0.78, RMSEP = 8.10 µg/kg, and RPDtest = 2.1 (Table 2).
<table><caption>**Table 2.** Performances of best NIR models based using partial least squares (PLS) regression for determining AFB1 and total aflatoxins content.</caption><thead><tr><th>Dataset</th><th>n *</th><th>Preprocessing</th><th>r<sup>2</sup></th><th>RMSE (µg/kg)</th><th>RPD</th></tr></thead><tbody><tr><td>AFB1 calibration</td><td>54</td><td>SNV + D1</td><td>0.97</td><td>1.44</td><td>6.3</td></tr><tr><td>AFB1 testing</td><td>12</td><td>SNV + D1</td><td>0.56</td><td>6.6</td><td>1.4</td></tr><tr><td>Total Aflatoxins calibration</td><td>54</td><td>SNV + D1</td><td>0.99</td><td>1.88</td><td>9.0</td></tr><tr><td>Total Aflatoxins testing</td><td>12</td><td>SNV + D1</td><td>0.78</td><td>8.10</td><td>2.1</td></tr></tbody></table>

SNV + D1 preprocessing can enhance the spectral data by removing multiplicative scatter effects and baseline shifts, leading to more accurate and reliable predictions [20].

The use of SNV+D1 preprocessing improved the model's performance, highlighting the importance of data preparation for spectroscopy models [21]. There is a noticeable difference between the cross-validation and test set performances, especially for AFB1, as for Darnell et al. [22]. This may indicate that the model is too specific to the calibration data (overfitting). However, the performances are interesting, as found by other authors [16,21,23]. But the RMSE values were still too high for targeted thresholds. To mitigate this issue, increasing the number of calibration samples or using more robust regularization techniques could be beneficial.

The model appeared to perform better in predicting total AF compared to AFB1. This could be due to clearer spectroscopic signals associated with maize modifications due to AF and fungi presence.

In conclusion, although the calibration results were excellent, the test set performance indicated that there is still room for improvement to meet the European regulatory thresholds.

### 2.2.3. Artificial Neural Network (ANN) Model Regression

To address the limitations of PLS models, ANN models were developed to predict aflatoxins contents, tuning hyperparameters to optimize the model. Neural networks, with their ability to model complex, non-linear relationships, might offer better precision and generalization compared to traditional PLS regression [24].

The best ANN model for predicting AFB1 was developed using SNV+D1 preprocessed spectra. It had the following characteristics: a hidden layer with 72 neurons, sine activation function, and initial weight assignment randomly following a negative uniform distribution (from -1 to 1). The performance for predicting the AFB1 content in maize samples was: r<sup>2</sup>cv = 0.90, RMSECV = 2.93 µg/kg, RPDcv = 3.1, r<sup>2</sup>test = 0.82, RMSEP = 4.9 µg/kg et RPDtest = 1.8 (Figure 2).

So, the ANN model for AFB1 showed good performance in calibration. However, the performance on the validation set was slightly lower, indicating overfitting of the calibration and some difficulty in generalizing the model to new data. This could be due to the complexity of sample variability or subtle differences in the spectra not captured by the calibration model. The size of the calibration set is limited for ANN training, which displays its full potential from 500 to 1000 calibration samples. Enriching the data set, particularly with spectra from contaminated samples, would help the models to better address their specificities and deliver better performance, while avoiding overlearning.

The best ANN model for predicting total AF content has the following characteristics: 33 neurons in the hidden layer, sine activation function, and initial weight assignment randomly following a negative uniform distribution (from -1 to 1). The modeling on SNV + D1 pretreated spectra was the best for predicting total aflatoxin content in maize samples: r<sup>2</sup>cv = 0.99, RMSECV = 0.91 µg/kg, RPDcv = 20.0, r<sup>2</sup>test = 0.74, RMSEP = 4.9 µg/kg et RPDtest = 1.9 (Figure 3).

<footnote>*: number of samples used.</footnote>
<figure><img src="image_5.png" /><figcaption>**Figure 2.** Performance of the ANN model for predicting AFB1 content in ground maize samples. The scatter plot shows the predicted versus reference values for the training set (grey circles) and the validation set (green circles).</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>**Figure 3.** Performance of the ANN model for predicting Total AF content in maize samples. The scatter plot shows the predicted versus reference values for the training set (grey circles) and the validation set (green circles).</figcaption></figure>
The ANN model for total AF showed excellent performance in calibration, indicating the model's ability to explain almost all the variance in the training data. The performance on the test set was also good, although slightly lower than that of the training set, which was expected. This shows that the model is relatively robust but could still benefit from more data or techniques to improve generalization.

The performance of the best ANN models is recapitulated in Table 3.

<table><caption>**Table 3.** Performance of the best ANN models for predicting AFB1 and total AF contents in maize samples.</caption><thead><tr><th>Dataset</th><th></th><th>Nb. Neurons in the Hidden Layer</th><th>Hidden Layer Activation Function</th><th>Initial Weight Assignment</th><th>Preprocessing</th><th>r<sup>2</sup></th><th>RMSE (µg/kg)</th><th>RPD</th></tr></thead><tbody><tr><td rowspan="2">AFB1</td><td>Cross validation</td><td rowspan="2">72</td><td rowspan="2">sine</td><td>randomly following a negative uniform distribution (from -1 to 1)</td><td>SNV + D1</td><td>0.90</td><td>2.93</td><td>3.1</td></tr><tr><td>Test</td><td></td><td>0.82</td><td>4.9</td><td>1.8</td></tr><tr><td rowspan="2">Total AF</td><td>Cross validation</td><td rowspan="2">33</td><td rowspan="2">sine</td><td>randomly following a negative uniform distribution (from -1 to 1)</td><td>SND + D1</td><td>0.99</td><td>0.91</td><td>20.0</td></tr><tr><td>Test</td><td></td><td>0.74</td><td>4.9</td><td>1.9</td></tr></tbody></table>

To further optimize, we could test other types of algorithms, such as extreme gradient boosting (XGBoost), which is an advanced implementation of gradient-boosted decision trees designed for speed and performance [25]. Additionally, to improve generalization, it would be beneficial to add more samples, include data from more harvest years, and consider testing a round-robin method on the harvest years. The round-robin method involves using data from different years in a rotating mode to ensure that the model generalizes well across different time periods [26].

Overall, the ANN models showed significant improvement compared to PLS models, especially in terms of r² and RMSE, as already demonstrated by other studies [15,17]. This suggests that ANNs can capture complex nonlinear relationships in the data, that PLS models cannot do as effectively. However, improving performance on test sets remains a challenge, highlighting the need for representative sampling and rigorous validation to ensure the models generalize well.

Although the ANN models showed promising performance, their practical use for predicting aflatoxin content must be carefully validated, particularly to ensure they meet regulatory thresholds. Therefore, a classification approach for maize samples was then tested.

### 2.3. Evaluation of the Aflatoxin Risk by NIR S

Characteristics and Performances of the Best Prediction Models for Aflatoxin Content Classes from NIR Spectra

Five mathematical preprocessings—raw, D1, D2, D3, and SNVD—were tested on the maize samples' spectra. The raw preprocessing uses the data without modification. D1, D2, and D3 correspond to the first, second, and third derivatives of the spectra, respectively, to enhance specific features and reduce baseline variations. SNVD (Standard Normal Variate De-trending) normalizes the spectra to correct for scatter and offset variations. These preprocessings improve the quality of spectral data, enabling more accurate analysis of aflatoxins contents. The variables to explain were AFB1 class (less or more than 2 µg/kg) and total AF (less or more than 4 µg/kg). The model used was Principal Component Analysis—Discriminant Analysis (PCA-DA). Models were developed with three discriminant algorithms: Linear Discriminant Analysis (LDA), Quadratic Discriminant Analysis (QDA), and Mahalanobis Distance-based Discriminant Analysis (MDA). The quadratic model on SNVD yielded the best cross-validation performance for both AFB1 and total AF.
The quadratic PCA-DA model was preferred over linear PCA-DA because aflatoxins content classes are likely not linearly separable in the variable space after PCA dimension reduction. Quadratic discriminant analysis can model non-linear decision boundaries, thereby enhancing its ability to capture differences between classes [27].

The model's performances were based on AFB1 contamination of maize, with the following categories: "lower2" (usable maize, containing less than 2 µg AFB1/kg) and "higher2" (maize to be exclude from Human consumption, containing more than 2 µg AFB1/kg). The presented performances were obtained through cross-validation.

In the context of the confusion matrix provided, positive cases were the samples that were contaminated (with more than 2 µg/kg of AFB1). Negative cases were the samples that were not contaminated (AFB1 lower than 2 µg/kg). The acceptance of batches with contaminated corn kernels (false negatives) poses a food safety risk for consumers, while the rejection of batches with mostly harmless corn kernels (false positives) represents an economic loss for producers.

The confusion matrix revealed the following: there were 11 true positives (correctly identified contaminated maize samples), 63 true negatives (correctly identified non-contaminated maize samples), 2 false positives (non-contaminated maize samples incorrectly identified as contaminated), and 0 false negatives (non-identified contaminated maize samples).

For AFB1, the summary is as follows: accuracy (the proportion of true results among the total number of cases examined): 97.4%, precision (the proportion of true positive results among all positive results predicted by the model): 84.6%, recall (sensitivity; the proportion of true positive results among all actual positive cases): 100%, and F1 score (the harmonic mean of precision and recall): 91.7%. These metrics provide a comprehensive evaluation of the model's performance in cross-validation. The results showed very high accuracy and perfect sensitivity, which is essential to ensure that all contaminated maize is correctly identified and excluded from Human consumption. Additionally, the high precision and F1 score indicate that the model made few errors in identifying non-contaminated maize as contaminated (false positives), while maintaining good overall performance.

For total AF, the performance metrics were as follows: accuracy: 100%, precision: 100%, recall (Sensitivity): 100%, and F1 score: 100%. These performance metrics indicate that the model's predictions for total AF contamination in maize were perfect. The accuracy of 100% means that all predictions made by the model were correct. The precision of 100% shows that every sample predicted as contaminated were indeed contaminated, while the recall of 100% demonstrates that the model successfully identified all contaminated samples. This performance is ideal in ensuring compliance with safety regulations, as it guarantees that all ground contaminated maize is correctly identified and also avoid economic losses since no uncontaminated maize is incorrectly classified.

The performance of our models is summarized in Table 4.

<table><caption>**Table 4.** Performance of the best PCA-DA models for predicting AFB1 and total aflatoxins contents in maize samples (cross-validation on 76 samples).</caption><thead><tr><th>Dataset</th><th>Preprocessing</th><th>Accuracy</th><th>Precision</th><th>Recall</th><th>F1-Score</th></tr></thead><tbody><tr><td>AFB1</td><td>SVN + Detrend</td><td>97.4%</td><td>84.6%</td><td>100%</td><td>91.7%</td></tr><tr><td>Total AF</td><td>SVN + Detrend</td><td>100%</td><td>100%</td><td>100%</td><td>100%</td></tr></tbody></table>

The performance was comparable to those reported in other studies [28], even though several of these studies used significantly higher thresholds [28–30]. Additionally, our models outperformed others conducted with larger sample sizes [22,31]. However, it is important to note that these results were obtained through cross-validation on only 76 ground samples. Indeed, in this study, a balanced class distribution was maintained to mitigate potential biases during model training. However, it is important to note that this approach does not entirely represent real-world conditions, where aflatoxin contamination
in commercial maize is relatively rare, even if increasing due to climate changes. As such, future research could benefit from exploring how the model performs with an increased test size, incorporating all available samples to better reflect the actual distribution of contamination. So, while the performance is very encouraging, it should be interpreted with caution and require further validation steps.

SNVD preprocessing of spectra was identified as the most effective one, as in the study by Ferandez-Ibanez et al. [21]. This choice was made based on the classification performance. SNVD reduced interferences from noise and background variations in NIR spectra. SNVD amplifies weak signals, facilitating the detection of compounds of interest.

**3. Conclusions**

AF are major contaminants in many hot regions of the world and emerging threats in Europe due to climate changes. These mycotoxins are potent carcinogenic compounds in Human, justifying the set of very low regulatory limits in food but also feed due to the possible carry over of toxic metabolites in milk. The development of rapid detection methods is of key importance, especially in the maize sector since maize is one of the most susceptible crops to AF contamination. In our study, a Partial Least Square (PLS) model developed using Standard Normal Variate + First derivative (SNV + D1) preprocessing achieved good performance with r² = 0.78, and RMSEP = 8.10 µg/kg for quantifying total AF, and r² = 0.56, and a Root Mean Square Error of Cross-Validation = 6.6 µg/kg for AFB1 content. Artificial Neural Network (ANN) models showed significant improvement over PLS models (RMSEP = 4.9 µg/kg for both Total AF and AFB1), yet still lacked precision compared to European regulatory limits. Principal Component Analysis and Discriminant Analysis (PCA-DA) was then used to classify ground maize samples based on European regulatory limits, achieving high performance metrics: accuracy = 97.4% for AFB1 and 100% for total AF. Our study thus demonstrated that NIR spectroscopy could be of great interest to classify ground maize samples according to their level of contamination. The use of Quadratic PCA-DA models allowed accurate, precise and sensitive classification of samples according to their compliance with EU regulatory limits for AFB1 and/or total AF. Inclusion of other samples and test on whole grains are now required to better validate these models and evaluate their transferability to the maize sector.

**4. Materials and Methods**

**4.1. Maize Samples**

A total of 554 samples was collected in French maize fields during 2018–2020 period (195 in 2018; 183 in 2019 and 176 in 2020). In each field, sampling was done at harvest by taking 3 times 1.5 kg of grains during combine harvester emptying, at three different periods. The three subsamples were mixed to obtain a 4.5 final sample. They were dried 24–48 h at 40 °C and cleaned to eliminate impurities. 1.5 kg from each sample were taken and ground for analysis using a hammer mill equipped with a 1 mm sieve.

**4.2. Aflatoxin Analysis**

Aflatoxins B1, B2, G1 and G2 were analyzed in a COFRAC accredited laboratory using liquid chromatography—tandem mass spectrometry as already described [32]. Limits of detection were 0.1, 0.1, 0.125, and 0.25 µg/kg for AFB1, AFB2, AFG1 and AFG2 respectively. Corresponding limits of quantification were 0.25, 0.25, 0.25 and 0.5 µg/kg for AFB1, AFB2, AFG1 and AFG2 respectively.

**4.3. Collection of NIR Spectra**

A MicroNIR OnSite spectrometer (Viavi Solutions Inc., San Jose, CA, USA) was used in reflectance mode to acquire NIR spectra from crushed grains over the spectral range of 908–1676 nm, consisting of 125 variables. Spectra were taken from a small cup containing 5 g of maize sample (FOSS, Hilleroed, Denmark). Each spectrum represents the average of 100 scans, taken with an integration time of 10 ms and a spectral resolution of 6 nm.
The averaged reflectance spectra were then converted into absorbance spectra using the Viavi spectrometer software, MicroNIR TM Pro v2.5. Additionally, three spectra were collected for each sample, involving refilling between measurements to ensure consistency and accuracy of the data collected.

### 4.4. Statistical Approaches and Data Mining

The aflatoxin B1 (AFB1) and total aflatoxin (TOT AF) concentrations were discretized to align with the European Union regulations. Specifically, the AFB1 levels were categorized based on whether they were above or below the threshold of 2 µg/kg, while the total AF content was categorized using a threshold of 4 µg/kg. To re-balance the classes of aflatoxin concentrations within the dataset, a stratified random sampling was performed XLSTAT Premium statistical software (version 2023.2.0).

Several preprocessing steps were applied to the spectral data: raw spectra, first, second, and third derivatives using Savitzky-Golay, followed by Standard Normal Variate (SNV) correction combined with detrending and Multiplicative Scatter Correction (MSC). Preprocessing was performed on the spectra before and after averaging the repetitions.

A NIPALS Principal Component Analysis (PCA) was performed to reduce the dimensionality of the spectral dataset. Following this, an Analysis of Variance (ANOVA) was conducted between the principal components (PCs) and the categories of AFB1, distinguishing samples with levels higher or lower than 2 µg/kg. An ANOVA was conducted between the principal components and the AF classes (higher or lower than the threshold), followed by a Tukey post-hoc comparison of group means test. They were done using XLSTAT Premium statistical software (version 2023.2.0).

A Partial Least Squares (PLS) regression was performed, using aflatoxin content as the dependent variable to be predicted and the raw or pre-processed spectra of maize samples as the explanatory variables. The model was developed using 80% of the samples, selected with the Kennard and Stone algorithm (package *prospectr* on R version 4.2.2). The model was validated on the remaining 20%. PLS was developed using the mdatools package on R version 4.2.2.

Artificial Neural Network (ANN) models were developed with the elmNNRcpp package, implemented in R version 4.2.2. Hyperparameter tuning was performed to optimize the model, adjusting parameters such as the number of neurons per layer, the activation functions, and the initial weight distributions. The activation functions available in the elmNNRcpp package are sigmoid, sine, radial basis, hard-limit, symmetric hard-limit, satlins, tan-sigmoid, triangular basis, rectifier linear unit and linear. Weights can be initially assigned according to a normal distribution, a negative uniform distribution between -1 and 1, or a positive uniform distribution between 0 and 1. All combinations of activation functions and weights distribution were tested.

The performance of PLS and ANN regression models were assessed using the $r^2$, RMSE, and RPD metrics, both on the training and testing sets. The coefficient of determination, $r^2$, measures the proportion of the total variance of the dependent variable explained by the model. RMSE (Root Mean Squared Error) quantifies the standard deviation of the residuals (prediction errors), providing a measure of the overall accuracy of the model. Finally, RPD (Ratio of Performance to Deviation) compares the precision of the model to the variability in the data, indicating the quality of the prediction relative to the observed variation in the data. The choice of the best model is based on performances on the validation set, with the highest $R^2$ and RPD and the lowest RMSE. Then, the Akaike criterion is as low as possible among the best models.

A Linear Discriminant Analysis (LDA) was performed on the spectral data. Discriminant analysis is a supervised classification method. However, because the number of variables exceeded the number of individuals, it was necessary to reduce the dimensionality before applying the LDA algorithm. To achieve this, a Principal Component Analysis (PCA) was done to extract the most significant principal components. This combined approach, known as PCA-DA, addresses the issue of high dimensionality while retaining the most
important information from the original data. Three discriminant algorithms were tested, including Linear Discriminant Analysis (LDA), Quadratic Discriminant Analysis (QDA), and Mahalanobis Distance-based Discriminant Analysis, to determine which one provided the best performance on our data. With only 76 samples available, external validation was not performed. Instead, cross-validation was used to evaluate the models. The performance is summarized in a confusion matrix. Several performance metrics were calculated from the confusion matrix. Accuracy is the proportion of correct results (both true positives and true negatives) among all cases examined.

$$Accuracy = \frac{(TP + TN)}{(TP + TN + FP + FN)}$$

Precision is the proportion of positive predictions that were correct.

$$Precision = \frac{TP}{(TP + FP)}$$

Recall (or Sensitivity) is the proportion of actual positives that were correctly identified.

$$Recall = \frac{TP}{(TP + FN)}$$

F1 Score is the harmonic mean of precision and recall.

$$F1\ Score = \frac{2 \times (Precision \times Recall)}{(Precision + Recall)}$$

The preprocessing of the spectral data, and the development of the PLS-DA models were done using The Unscrambler (version X, CAMO Software AS, Oslo, Norway).

**Author Contributions:** Conceptualization, C.L.-G., B.O. and J.-D.B.; methodology, S.B. and C.L.-G.; formal analysis, S.B., B.O., J.B. and C.L.-G.; data curation, B.O., J.-D.B. and C.L.-G.; writing—original draft preparation, J.B., J.-D.B. and C.L.-G.; writing—review and editing, S.B., B.O., J.-D.B. and C.L.-G.; project administration, J.-D.B.; funding acquisition, J.-D.B. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by ANSES, grant number EST-19-016 (AFLAFrance project).

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

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Data will be available on request to corresponding author.

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

## References

1. Frisvad, J.C.; Hubka, V.; Ezekiel, C.N.; Hong, S.B.; Novakova, A.; Chen, A.J.; Arzanlou, M.; Larsen, T.O.; Sklenar, F.; Mahakarnchanakul, W.; et al. Taxonomy of *Aspergillus* section *Flavi* and their production of aflatoxins, ochratoxins and other mycotoxins. *Stud. Mycol.* **2019**, 93, 1–63. [CrossRef]

2. Klich, M.A. *Aspergillus flavus*: The major producer of aflatoxin. *Mol. Plant Pathol.* **2007**, 8, 713–722. [CrossRef] [PubMed]

3. IARC. Monographs on the evaluation of carcinogenic risks to humans. *Aflatoxins* **2012**, 100F, 225–244.

4. Benkerroum, N. Chronic and acute toxicities of aflatoxins: Mechanisms of action. *Int. J. Environ. Res. Public Health* **2020**, 17, 423. [CrossRef]

5. Nejad, B.G.; Mostafei, Z.; Rezaabad, A.B.; Mehravar, F.; Zarei, M.; Dehghani, A.; Estabragh, M.A.R.; Karami-Mohajeri, S.; Alizadeh, H. A systematic review with meta-analysis of the relation of aflatoxin B1 to growth impairment in infants/children. *BMC Pediatr.* **2023**, 23, 614. [CrossRef] [PubMed]

6. Meissonnier, G.M.; Pinton, P.; Laffitte, J.; Cossalter, A.M.; Gong, Y.Y.; Wild, C.P.; Bertin, G.; Galtier, P.; Oswald, I.P. Immunotoxicity of aflatoxin B1: Impairment of the cell-mediated response to vaccine antigen and modulation of cytokine expression. *Toxicol. Appl. Pharmacol.* **2008**, 231, 142–149. [CrossRef] [PubMed]
7. Gibb, H.; Devleesschauwer, B.; Bolger, B.M.; Wu, F.; Ezenman, J.; Cliff, J.; Zeilmaker, M.; Verger, P.; Pitt, J.; Baines, J. World Health Organization estimates of the global and regional disease burden of four foodborne chemical toxins, 2010: A data synthesis. *F1000Research* **2015**, *4*, 1393. [CrossRef]

8. Van Egmond, H.P. Worldwide regulation for mycotoxins. *Adv. Exp. Med. Biol.* **2002**, *504*, 257–269. [CrossRef]

9. European Union. Regulation 2023/915 of the commission regarding maximal tolerable concentrations for certain contaminants in foods. *Off. J. Eur. Union* **2023**, L119, 103–157.

10. EN ISO 16050:2011; Determination of AFB1 and the Total Content of Aflatoxins B1; B2, G1 and G2 in Cereals, Nuts and Derived Products. High Performance Liquid Chromatographic Method. International Organization for Standardization: Geneva, Switzerland, 2011.

11. European Union. Regulation 401/2006 laying down the methods of sampling and analysis for the official control of the levels of mycotoxins in foodstuffs. *Off. J. Eur. Union* **2006**, L70, 12–34.

12. Liu, S.; Jiang, S.; Yao, Z.; Liu, M. Aflatoxin detection technologies: Recent advances and future prospects. *Environ. Sci. Pollut. Res. Int.* **2023**, *30*, 79627–79653. [CrossRef]

13. Sun, D.-W. (Ed.) *Infrared Spectroscopy for Food Quality Analysis and Control*; National University of Ireland: Dublin, Ireland; Academic Press: Burlington, MA, USA, 2009.

14. Levasseur-Garcia, C. Updated overview of infrared spectroscopy methods for detecting mycotoxins on cereals (corn, wheat, and barley). *Toxins* **2018**, *10*, 38. [CrossRef] [PubMed]

15. Wang, B.; Deng, J.; Jiang, H. Markov transition field combined with convolutional neural network improved the predictive performance of near-infrared spectroscopy models for determination of aflatoxin B1 in maize. *Foods* **2022**, *11*, 2210. [CrossRef]

16. Deng, J.; Jiang, H.; Chen, Q. Characteristic wavelengths optimization improved the predictive performance of near-infrared spectroscopy models for determination of aflatoxin B1 in maize. *J. Cereal Sci.* **2022**, *105*, 103474. [CrossRef]

17. Liu, T.; He, J.; Yao, W.; Jiang, H.; Chen, Q. Determination of aflatoxin B1 value in corn based on Fourier transform near-infrared spectroscopy: Comparison of optimization effect of characteristic wavelengths. *LWT* **2022**, *164*, 113657. [CrossRef]

18. Hoffmans, Y.; Schaarschmidt, S.; Fauhl-Hassek, C.; van der Fels-Klerx, H.J. Factors during production of cereal derived feed that influence mycotoxin contents. *Toxins* **2022**, *14*, 301. [CrossRef] [PubMed]

19. Weyer, L.; Lo, S. Spectra-structure correlations in the near-infrared. In *Handbook of Vibrational Spectroscopy*; John Wiley & Sons, Ltd.: Hoboken, NJ, USA, 2002; Volume 3, pp. 1817–1837.

20. Pasquini, C. Near infrared spectroscopy: A mature analytical technique with new perspectives—A review. *Anal. Chim. Acta* **2018**, *1026*, 8–36. [CrossRef]

21. Fernández-Ibañez, V.; Soldado, A.; Martínez-Fernández, A.; de la Roza-Delgado, B. Application of near infrared spectroscopy for rapid detection of aflatoxin B1 in maize and barley as analytical quality assessment. *Food Chem.* **2009**, *113*, 629–634. [CrossRef]

22. Darnell, R.E.; Harvey, J.J.; Fox, G.P.; Fletcher, M.T.; Wainaina, J.; Wanjuki, I.; Turner, W.J. NIRS calibration of aflatoxin in maize. *Austr. J. Chem* **2018**, *71*, 868–873. [CrossRef]

23. Shen, G.; Kang, X.; Su, J.; Qiu, J.; Liu, X.; Xu, J.; Shi, J.; Mohamed, S.R. Rapid detection of fumonisin B1 and B2 in ground corn samples using smartphone-controlled portable near-infrared spectrometry and chemometrics. *Food Chem.* **2022**, *384*, 132487. [CrossRef]

24. Abdolrasol, M.G.; Hussain, S.S.; Ustun, T.S.; Sarker, M.R.; Hannan, M.A.; Mohamed, R.; Ali, A.S.; Mekhilef, J.; Milad, A. Artificial neural networks-based optimization techniques: A review. *Electronics* **2021**, *10*, 2689. [CrossRef]

25. Ali, Z.A.; Abdul Jabbar, Z.H.; Taher, H.A.; Sallow, A.B.; Almufti, S.M. Exploring the power of extreme gradient boosting algorithm in machine learning: A review. *Acad. J. Nawroz Univ.* **2023**, *12*, 320–334. [CrossRef]

26. Dardenne, P. Some considerations about NIR spectroscopy: Closing speech at nir-2009. *NIR News* **2010**, *21*, 8–14. [CrossRef]

27. Naes, T.; Isaksson, T.; Fearn, T.; Davies, T. *A User-Friendly Guide to Multivariate Calibration and Classification*; NIR Publications: Chichester, UK, 2002.

28. Pearson, T.C.; Wicklow, D.T.; Maghirang, E.B.; Xie, F.; Dowell, F.E. Detecting aflatoxin in single corn kernels by transmittance and reflectance spectroscopy. *Trans. ASAE* **2001**, *44*, 1247–1254. [CrossRef]

29. Ghilardelli, F.; Barbato, M.; Gallo, A. A preliminary study to classify corn silage for high or low mycotoxin contamination by using near infrared spectroscopy. *Toxins* **2022**, *14*, 323. [CrossRef]

30. Cheng, X.; Vella, A.; Stasiewicz, M.J. Classification of aflatoxin contaminated single corn kernels by ultraviolet to near infrared spectroscopy. *Food Control* **2019**, *98*, 253–261. [CrossRef]

31. Tao, F.; Yao, H.; Hruska, Z.; Liu, Y.; Rajasekaran, K.; Bhatnagar, D. Detection of aflatoxin B1 on corn kernel surfaces using visible-near infrared spectroscopy. *J. Near Infrared Spectrosc.* **2020**, *28*, 59–69. [CrossRef]

32. Bailly, S.; El Mahgubi, A.; Carvajal-Campos, A.; Lorber, S.; Puel, O.; Oswald, I.P.; Bailly, J.D.; Orlando, B. Occurrence and identification of *Aspergillus* section *Flavi* in the context of the emergence of aflatoxins in French maize. *Toxins* **2018**, *10*, 525. [CrossRef]

**Disclaimer/Publisher's Note:** The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.