1. Introduction
In the context of the growing popularity of the “Healthy China” concept, the public’s dietary structure is gradually shifting from simply aiming to “fill up” to focusing on “eating well and eating healthy”, with nutritious coarse grains increasingly gaining recognition [
1]. As an important coarse-grain crop, foxtail millet occupies a central position in the dietary system of northern China [
2]. Shanxi, as a major production area for small grains in China, ranks among the top in terms of foxtail millet cultivation area. Its high-quality produce is widely loved by the public [
3]. The foxtail millet is rich in carbohydrates, proteins, fats, vitamins, minerals, and various other nutrients, providing comprehensive and balanced nutritional support for the human body [
4]. Notably, it is rich in essential amino acids that the human body cannot synthesize on its own, which gives it a unique advantage in the content and proportion of essential amino acids. Thus, it serves as a high-quality source of plant protein [
5]. In addition, foxtail millet also contains some health-preserving components, such as gamma-aminobutyric acid (GABA) and vitamin B9, which further enhance its functionality and commercial value [
6,
7,
8].
In the field of nutrition and health, the content and proportion of nutrients in foxtail millet have a significant impact on its nutritional value and health benefits [
9]. GABA is a non-protein amino acid that is widely distributed in microorganisms, plants, and animals [
10]. It offers a range of nutritional benefits. Notably, the GABA content in foxtail millet can reach 20–50 mg/100 g, which is markedly higher than that found in common grains [
11]. This relatively high GABA level makes foxtail millet a valuable source of this important nutrient. Vitamin B9 is an essential vitamin for the human body. It is involved in numerous biochemical reactions and is vital for maintaining normal physiological functions. Vitamin B9 content in foxtail millet ranges from 30 to 50 μg/100 g, which is higher than that in staple crops like corn and wheat [
12]. This higher concentration of vitamin B9 in foxtail millet enhances its nutritional value compared to other commonly consumed grains. Given the superior content of both GABA and vitamin B9 in foxtail millet relative to other crops, achieving rapid and nondestructive detection of these two nutrients holds high practical significance. Traditional chemical detection methods, however, have drawbacks such as long detection cycles, high costs, and sample destruction, making it challenging to meet the demands of modern food nutrition analysis. Therefore, developing a rapid, accurate, and nondestructive analysis technology for GABA and vitamin B9 in foxtail millet is of great importance.
Hyperspectral imaging (HSI), as an emerging nondestructive testing technology, offers advantages such as high spectral resolution, continuous wavelength bands, and rich information, and has been widely applied in fields such as agricultural product quality inspection and food safety monitoring. Guo et al. [
13] systematically reviewed the research progress of the past decade, conducting an in-depth investigation into the application of HSI in the detection of fungal and mycotoxin contamination in grains. They summarized detection cases for different types of grains and used machine learning algorithms such as support vector machines (SVM) and convolutional neural networks (CNN) for key extraction and classification of HSI, enabling early identification of common pathogenic fungi such as Fusarium graminearum and Aspergillus flavus. Aviara et al. [
14] reviewed the frontier applications of HSI in grain quality and safety detection, establishing a correlation model between spectral features and physical indicators of grains by analyzing differences in spectral absorption peaks. Medina-García et al. [
15] focused on sensor technology, data processing algorithms, and machine learning in nondestructive testing of grain quality, aiming to address the challenges of the correlation between food production and dynamic environments. Zhang et al. [
16] utilized NIR-HSI combined with machine learning algorithms to establish a correlation model between spectral features and the protein, starch, and water content of 77 wheat varieties. Chen et al. [
17] constructed a backpropagation neural network model and a partial least squares model to predict the crude fat and water content in hickory seeds. Shi et al. [
18] accurately predicted the vitamin content in wheat using stepwise linear regression (SLR).
At present, with the rapid development of computer science, the fusion of deep learning algorithms and hyperspectral imaging has become a research hotspot for numerous scholars, as evidenced by references [
19,
20,
21]. In this dynamic research field, multiple pioneering studies have emerged. Ren et al. [
22] ingeniously employed four deep learning models, incorporating coordinate attention mechanisms and label smoothing loss functions, to accurately detect soybean seed vigor. Yue et al. [
23] developed LeafTraitNet based on the Visual Geometry Group architecture, integrating features from both deep and shallow networks to estimate the physicochemical parameters of plant leaves. Among various deep learning techniques, the bidirectional long short-term memory network (BiLSTM) is an enhanced version of the traditional LSTM. It has significant advantages in processing sequence data as it can comprehensively extract deep temporal features from sequences, laying a crucial foundation for key extraction of complex spectral sequences in hyperspectral data [
24]. Adaptive boosting (Adaboost) is a well-established ensemble learning algorithm. It combines multiple weak learners into a strong learner, substantially improving the prediction accuracy and generalization ability of the model [
25,
26,
27]. The BiLSTM–Adaboost collaborative model is a cutting-edge approach that integrates the dual advantages of bidirectional key extraction and ensemble optimization. It effectively breaks through the performance limitations of single models, enabling more accurate and reliable analysis. Currently, scholars have actively applied it in multiple fields [
28,
29,
30,
31]. However, there is still a significant research gap in the application of this collaborative model in the field of agricultural science, especially regarding the precise analysis of GABA and vitamin B9 content in foxtail millet, with no relevant research reported so far.
In this work, we measured the GABA and vitamin B9 content in 190 foxtail millet samples from 19 varieties using traditional detection methods, obtained spectral data of the samples using hyperspectral imaging, selected four “coarse-fine” strategies with strong correlation between spectral features and the contents of GABA and vitamin B9, and constructed a BiLSTM–Adaboost collaborative model for precise prediction of GABA and vitamin B9 contents in foxtail millet. The experimental results will enrich the theoretical application of HSI in the field of food science. By exploring the intrinsic relationship between hyperspectral data and food nutritional components, this work provides new theoretical foundations and methodological support for food ingredient detection.
2. Materials and Methods
2.1. Planting and Sample Collection
The 190 foxtail millet samples used in this work (including ‘Changnong No. 35’, ‘Changnong No. 36’, ‘Changenong 38–41’, ‘Changenong 44’, ‘Changenong 46–55’, ‘Jingu 21’, and ‘2021 Variety 56’, totaling 19 varieties) were all planted in the foxtail millet Research Institute of Shanxi Agricultural University, located in the eastern part of Changzhou District, Chizhou City, Shanxi Province (Latitude 36°12′, Longitude 113°08′, Elevation 977 m). The tested millet variety was bred by the Millet Cultivation Research Team of our institute, and its detailed information is shown in
Table S1. This base serves as a core experimental field in the mid-late maturing dry farming area for spring sowing, with an annual average temperature of 10.2 °C, a frost-free period of 185 days, and annual precipitation of 550 mm, which highly matches the drought-resistant and barren-tolerant characteristics of the samples. It is particularly suitable for analyzing the adaptive mechanism of foxtail millet in the mid-late maturing dry farming areas of northwestern China. The foxtail millet was sown on May 12, 2024, in a typical brown soil area (0–20 cm soil layer: organic matter 1.65%, available phosphorus 12.3 mg/kg, pH 7.8). Manual sowing was adopted with a row spacing of 40 cm and a planting density of 450,000 plants per hectare. The base fertilizer consisted of 30,000 kg/hm
2 decomposed sheep manure and 600 kg/hm
2 slow-release fertilizer (N-P
2O
5-K
2O = 20-10-15). Urea was applied at 225 kg/hm
2 during the jointing stage, combined with drip irrigation. Harvesting was performed on 10 October 2024. Ten samples were collected from each variety, with each sample weighing 200 g. The samples were sun-dried, hulled, and underwent further processing.
2.2. Hyperspectral Imaging Data Acquisition
The experiment on data acquisition of foxtail millet samples based on near-infrared hyperspectral imaging was conducted using the push-sweep hyperspectral imaging system, manufactured by Headwall Photonics (Bolton, MA, USA). The system consists of five core functional modules: ① a NIR hyperspectral imaging device with a spectral range of 900–1700 nm (172 bands, spectral resolution of 4.715 nm); ② an electric lifting scanning platform equipped with a precision stepper motor (positioning accuracy of ±0.01 mm); ③ a dual-channel halogen lamp array light source system (color temperature of 3200 K, illumination uniformity > 95%); ④ an industrial-grade control computer with dedicated imaging control system and software; ⑤ a precision push-broom mechanism based on guide rails (stroke of 300 mm). Instrument settings: object distance is 280 mm, push-broom speed is 2.721 mm/s. To eliminate ambient light (<5 lx) and sensor dark current noise (<0.1 DN), the standardized process of “white reference calibration → dark field acquisition → radiometric calibration” was strictly followed. First, a 99% reflectance diffuse standard white panel (Labsphere, North Sutton, NH, USA) was used for white field calibration, followed by capturing the full dark field reference value with the lens cap covered. Finally, radiometric calibration was completed using Equation (1) to ensure the absolute radiometric accuracy of the original spectral data (R
2 > 0.998).
where
R is the corrected image;
R0 is the original image;
Rw is the white reference calibration image (reflectance > 99.9%); and
Rb is the dark background calibration image (reflectance < 0%).
The foxtail millet grain samples were sequentially placed into the same experimental vessel with a diameter of 3 cm and a depth of 1 cm, ensuring the surface of the sample was flat and compact. Each sample was scanned three times, and the data were numbered and saved sequentially. To address the significant signal-to-noise ratio drop at the edges of the spectral response range of the hyperspectral imaging system (<950 nm and >1650 nm), where the relative standard deviation was greater than 15%, the effective modeling wavelength range was determined to be 950–1650 nm based on the principles of spectral stability and key effectiveness. This range, which includes 148 key channels, is suitable for the quantitative detection of GABA and vitamin B9 in foxtail millet.
2.3. Physicochemical Determination of GABA and Vitamin B9 in Foxtail Millet
The samples were ground thoroughly to ensure uniformity. The GABA content was determined using an Ultimate ODS-3 reverse-phase column (4.6 mm × 250 mm, 5 μm) in a high-performance liquid chromatography (HPLC) system. The detection conditions were set as follows: flow rate of 0.6 mL/min, column temperature of 40 °C, wavelength of 331 nm, and injection volume of 10 µL. The stock solution of the GABA standard sample was diluted in a certain proportion to prepare standard solutions of different concentrations for the subsequent construction of the standard curve. An appropriate amount of derivatizing agent was prepared by accurately weighing o-phthalaldehyde, methanol, and dimethylaminoethyl mercaptan chloride, then adding them to a suitable borate buffer solution, and stirring to ensure thorough mixing and accurate component ratios. The scheme follows Syu, K. Y. (2008) [
32] regarding the determination process of GABA using liquid chromatography. The prepared sample solutions and standard solutions were injected sequentially into the HPLC system. The chromatographic peak area corresponding to each standard solution was recorded. Using these data, a standard curve was generated. The unknown sample’s data were then compared with the standard curve to accurately calculate the GABA content.
The ground samples were treated with an appropriate amount of hydrochloric acid to facilitate the dissociation of vitamin B9 more effectively from the samples. Zinc sulfate was then added to help precipitate impurities. After centrifugation and filtration, a relatively pure solution containing vitamin B9 was obtained. The vitamin B9 content was measured using liquid chromatography with a Nova Atom C18 column [
33]. Mobile phase A was acetonitrile, and mobile phase B was potassium dihydrogen phosphate. The column temperature was maintained at 25 °C, the flow rate was stabilized at 1 mL/min, and the detection wavelength was set at 200 nm.
2.4. Data Preprocessing and Sample Set Division
When the hyperspectral imaging system acquires the spectral images of samples, instrument noise, environmental noise, and surface scattering can inevitably interfere with the experimental data. Therefore, preprocessing of the original spectral data is essential to eliminating or reducing the impact of instrument and environmental noise while suppressing the surface scattering effect, thus effectively weakening the interference of external factors on spectral signals.
The Savitzky–Golay (S-G) filter [
34] is primarily used to filter high-frequency noise from the spectral lines, improving the continuity of the data by smoothing the spectral curves. The specific parameters adopted in this work were as follows: polynomial order 1, frame length 3, and window size of 5 for the finite impulse response smoothing filter.
The discrete wavelet transform (DWT) [
35] decomposes the signal into basis functions (wavelets) of different frequency and time to perform time–frequency analysis. Noise typically manifests as high-frequency components, while useful signals are often distributed in low-frequency or specific frequency bands. The signal is subjected to multi-scale wavelet decomposition, yielding approximation coefficients (low frequency) and detail coefficients (high frequency). The detail coefficients are thresholded to retain significant signals and suppress noise. The threshold determination principle of the penalty strategy balances the model’s goodness of fit and complexity, adaptively selecting a global threshold. The signal is reconstructed using the processed coefficients.
The standard normal variate transformation (SNV) [
36] aims to eliminate the influence of surface glossiness, scattering effects, and background interference on the reflection spectra of foxtail millet. After processing using SNV, the reflectance at each point shows regular variation, and each spectral value is standardized for correction.
In the process of modeling spectral data and chemical composition, the sample set partitioning based on the joint x-y distance (SPXY) algorithm [
37] was used to divide the sample set. This method simultaneously optimizes the spectral space (x space) and the chemical parameter distribution (y space) using dual distance metrics, dividing the dataset into a calibration set (143 samples) and a prediction set (47 samples) in a 3:1 ratio. The calibration set is used for model construction and cross-validation, while the prediction set is used to evaluate the prediction performance of the model.
2.5. Key Wavelength Extraction
Hyperspectral imaging has high resolution, which leads to high data dimensions. Direct application often faces issues such as high computational complexity, difficult band selection, and susceptibility to overfitting. By extracting spectral key variables from hyperspectral imaging, data dimensionality can be reduced while retaining key information, simplifying the model. This is beneficial for improving the efficiency of data processing and analysis, as well as enhancing the performance of subsequent algorithms. Therefore, extracting key wavelengths is crucial. In this work, the “coarse-fine” selection strategy was adopted to gradually optimize the spectral variable space of the foxtail millet in order to obtain the optimal variable combination for establishing detection models of GABA and vitamin B9 content.
The interval random frog (iRF) algorithm, based on the random frog partial least squares framework, updates variable subsets by leveraging the principles of survival of the fittest and random search. Through an iterative process, it ranks key bands by their selection probability, facilitates local information transfer, and is used to select optimal key bands [
38]. The interval variable iterative space shrinkage algorithm (iVISSA) is a key selection method combining global and local search. By optimizing band weights via alternating search between global soft shrinkage and local continuous information, it determines the optimal position and width of variable intervals for modeling analysis [
39]. The competitive adaptive reweighted sampling (CARS) algorithm employs adaptive reweighted sampling to emulate the “survival of the fittest” principle. Through multiple weighting rounds, it retains high-weight features, thereby screening strongly predictive variables from high-dimensional data [
40]. The bootstrapped soft shrinkage (BOSS) algorithm addresses inaccurate predictions caused by model collinearity. By statistically analyzing regression coefficients of sub-models and optimizing variable proportions through weighted bootstrapped sampling, it extracts the optimal variable set [
41].
Four “coarse-fine” selection strategies are proposed: iRF-CARS, iRF-BOSS, iVISSA-CARS, and iVISSA-BOSS. The spectral matrix of foxtail millet is represented as X (m × p), and the nutritional index matrix as Y (m × 1). After preprocessing X and dividing the X and Y datasets, the “coarse-fine” selection strategy was applied to extract key variables for the corresponding physiological parameters. The specific steps are as follows:
Step 1 (Coarse Selection): Screening the wavelength intervals with strong interpretability in the form of interval spectral variables significantly reduces the variable space. From the initial larger key wavelength set, spectral intervals with higher correlations and significant information extraction abilities are gradually selected. Coarse selection plays a critical role in this strategy because the wavelengths selected in this step serve as the data source for subsequent steps. If wavelengths related to the corresponding physiological parameters are not retained in this step, the final key wavelengths will lose relevant information, thereby affecting the estimation accuracy of the corresponding physiological parameter models. By dividing X into intervals of a certain width and building models for each interval, the root mean square error of cross-validation (RMSECV) is obtained through cross-validation, and intervals with smaller RMSECV are retained to form the optimal wavelength combination matrix X1 (m × p1). In this step, the iRF and iVISSA were used to perform coarse selection of the foxtail millet spectral full variables. The iRF parameters were set as follows: 1000 iterations, moving window size of 10, 20 sub-intervals, and a maximum of 10 principal components. The iVISSA parameters were set as follows: window-based moving subsampling (WBMS) generates k = 1000 subsets, with an initial weight w0 = 0.5.
Step 2 (Fine Selection): Based on the principle of model cluster analysis, the coarse-selected wavelength set is further refined to eliminate irrelevant and interfering variables and retain important ones. Strongly correlated key wavelengths are meticulously selected from the coarse-selected spectral intervals to improve the robustness and stability of the model. Subsets of wavelengths are generated from X1 (m × p1) using specific sampling methods, and models are built for each subset. The RMSECV is obtained via cross-validation, and wavelengths with smaller RMSECV are retained to form the optimal wavelength combination matrix X2 (m × p2). In this step, the CARS and BOSS were used to fine-select the coarse spectral wavelengths of the foxtail millet, further reducing the variable space. The CARS parameters were set as follows: Monte Carlo sampling (MCS) iterations = 100; the BOSS parameters were set as: window-based subsampling (WBS) iterations = 1000, and the optimal model ratio = 0.1.
2.6. Model Construction
The stacked BiLSTM–Adaboost model adopted in this work is an integrated learning model that integrates BiLSTM and Adaboost. The network structure is shown in
Figure 1. The model stacks multiple layers of BiLSTM as basic weak learners to capture the bidirectional dependencies of the spectral data. It consists of two independent LSTM layers, which extract features from the sequence in both forward and reverse directions. These layers output hidden states containing spectral information, and eventually, the forward and reverse features are integrated through concatenation or weighted fusion to form a comprehensive representation of the spectral sequence. A two-layer BiLSTM is used to extract more complex hierarchical features by increasing the network depth. The two-layer BiLSTM extracts deeper features compared to a single-layer model, thus avoiding underfitting typically associated with shallow models. The number of hidden layer nodes in each BiLSTM layer is set to 6 to balance model complexity and training efficiency. Adaboost is used to iteratively train 10 weak learners. Based on the current sample weights, it trains BiLSTM weak learners and calculates prediction errors. Each weak learner focuses on fitting the samples with larger prediction errors from the previous round and is assigned a weight based on its prediction accuracy. The final prediction is determined by the weighted output of all weak learners—weak learners with smaller errors have higher weights, thereby enhancing the model’s fitting ability for difficult samples. The final prediction is the weighted sum of all weak learners’ outputs. Adaboost progressively corrects the prediction bias of BiLSTM through iterative weighting, especially for noisy spectral data or key wavelengths in foxtail millet, significantly improving the robustness of the model to “abnormal samples”. The iterative weighting mechanism of Adaboost enhances the overall prediction accuracy and robustness of the model. By integrating multiple BiLSTM weak learners, Adaboost gradually optimizes sample weights, reduces prediction bias, and addresses the issues of insufficient accuracy or instability of a single BiLSTM model.
The evaluation metrics for the quantitative detection model in this work include three key statistical indicators:
correlation coefficient (R2),
root-mean-square error (RMSE), and
residual prediction deviation (RPD) [
42].
3. Results
3.1. Analysis of the Differences in GABA and Vitamin B9 Content Among Different Foxtail Millet Varieties
Figure 2 illustrates the differences in GABA and vitamin B9 content among various varieties of foxtail millet. Significant fluctuations in GABA content were observed across different varieties. The GABA content in ‘Changnong No.35’ is relatively low, whereas varieties such as ‘Changnong No.41’ and ‘Changnong No.50’ have higher GABA content, indicating differences in the GABA accumulation ability among varieties. This variation could be related to factors such as the genetic characteristics of the varieties and the activity of related enzymes. Similarly, there is a notable variation in vitamin B9 content across different varieties. ‘Changnong No.54’ stands out with a high vitamin B9 content, while ‘Changnong No.49’ exhibits lower levels of this component. Some varieties, such as ‘Changnong No.54’, show higher total nutritional content, with vitamin B9 making up a significant proportion. On the other hand, ‘Changnong No.49’ has a lower overall nutritional content, and vitamin B9 is particularly scarce, reflecting the differences in the accumulation of this nutrient among the varieties. The ratio of GABA to vitamin B9 also varies among the different varieties. ‘Changnong No.41’ has a higher proportion of GABA, while ‘Changnong No.54’ has a more prominent vitamin B9 content. This suggests that different varieties exhibit distinct tendencies in accumulating these two nutrients. In conclusion, significant differences exist in the contents and ratios of GABA and vitamin B9 among different foxtail millet varieties. These differences provide a basis for selecting foxtail millet varieties with high nutritional quality and reflect how the genetic characteristics or environmental adaptability of the varieties influence the accumulation of these nutrients.
3.2. Spectral Data Response and Preprocessing Results
Figure 3A shows the reflectance characteristics of the original spectral response in foxtail millet in the wavelength range of 950–1650 nm, which result from the interaction between multiple internal chemical components of foxtail millet and light. Reflection valleys appear at 997 nm, 1199 nm, and 1468 nm, while reflection peaks form at 1100 nm and 1298 nm. The variations across different wavelength intervals contain rich chemical information. The wavelength range of 950–997 nm is primarily associated with the vibrational absorption of chemical bonds in components such as water and carbohydrates. This absorption represents the internal energy conversion within molecules, indicating their selective absorption characteristics for light of specific wavelengths [
43]. The wavelength range of 997–1100 nm may correspond to reduced absorption of light by vibrational modes of certain groups, such as proteins or fats, within this interval. This demonstrates the modulatory effects of components like proteins and fats on the spectrum within this wavelength band [
44]. The wavelength range of 1100–1199 nm likely reflects the enhanced combined absorption of carbohydrates like starch. Overlapping absorptions within this range strengthen light absorption, leading to decreased reflectance and highlighting the dominant absorption role of carbohydrates in this spectral region [
45]. The wavelength range of 1199–1298 nm may be related to weakened absorption by certain functional groups, reflecting the influence of combination bands of functional group vibrations on spectral characteristics [
46]. The wavelength range of 1298–1468 nm is likely associated with water absorption. Significant absorption of light energy occurs here, causing a marked decrease in reflectance [
47]. This underscores the critical influence of water on reflectance within this spectral interval. The wavelength range of 1468–1650 nm likely arises from the overlapping and interacting absorption characteristics of multiple components within millet grains, such as proteins, fats, and carbohydrates. Reflectance exhibits specific trends within this range, reflecting the complexity of millet’s composition and the composite nature of its spectral features [
48].
Figure 3B shows the spectral curve after preprocessing of S-G, which effectively reduces random noise while preserving the shape and position of spectral characteristic peaks. Compared to
Figure 3A, the spectral curve in
Figure 3B is smoother, with significantly reduced noise. The identification of characteristic peaks (in intervals such as 1000–1200 nm and 1300–1400 nm) has improved, and the baseline tends to be stable. However, there may still be slight shifts due to sample scattering or background differences. Following S-G smoothing, the data were processed with DWT to decompose the spectral signal into components of different frequencies, removing high-frequency noise while retaining the low-frequency valid signal, as shown in
Figure 3C. The spectral curve is further optimized, noise is more thoroughly suppressed, the resolution of the characteristic peaks is enhanced, and the baseline drift is better corrected, improving the overall spectral stability. SNV corrects the light scattering caused by the differences in particle size and stacking density of foxtail millet, making the spectra more comparable. Combining S-G, DWT, and SNV, the results achieved multiple optimizations, including noise suppression, baseline correction, and scattering correction, as shown in
Figure 3D. The consistency of the spectral curves has been significantly improved, the fluctuation range of reflectance has been narrowed, the deviation caused by scattering has been eliminated, and the regularity of characteristic peaks has become more prominent, greatly enhancing the spectral quality.
3.3. Key Wavelength Extraction and Detection Model Results for GABA in Foxtail Millet
The results of using millet GABA raw data, preprocessing data, and key extraction data combined with the BiLSTM–Adaboost model are shown in
Table S2. The stacked BiLSTM–Adaboost was used to establish an association model between the original spectral data of foxtail millet and the content of GABA. The results showed that R
C2 = 0.3389, RMSE
C = 20.5340, RPD
C = 1.2299, R
P2 = 0.3059, RMSE
P = 22.8755, and RPD
P = 1.2000. After preprocessing the data with combined S-G, DWT, and SNV, the results improved significantly: R
C2 = 0.6539, RMSE
C = 12.1143, RPD
C = 1.7000, R
P2 = 0.6297, RMSE
P = 12.2218, and RPD
P = 1.8022. This indicates that data preprocessing plays a crucial role in the process of constructing a component content detection model using spectral data and can significantly improve the performance of the model. The range of 1275–1341 nm is related to the combined vibration modes of molecules, that is, the coupling effect of multiple chemical bond vibrations (the coordinated vibration of C-H and N-H bonds). The spectral signals in this interval are stable and less affected by noise, which can effectively capture the structural information of the molecular skeleton of the GABA. The prediction results of the model were as follows: R
C2 = 0.7169, RMSE
C = 10.9565, RPD
C = 1.8794, R
P2 = 0.6921, RMSE
P = 11.1451, and RPD
P = 1.8022. The distribution of key wavelengths was shown in
Figure 4. When iVISSA was applied for rough extraction, 42 key wavelengths were obtained, which extended the wavelength range to include 1360–1445 nm, 1483–1558 nm, and 1643–1648 nm. The prediction results of the model at this time are shown in
Figure 5. However, a comparison revealed that the prediction accuracy of the model based on iRF-extracted wavelengths was higher than that of iVISSA. Since iRF focuses on continuous, strong signal intervals—where spectral absorption is intense and the signal-to-noise ratio is high—it directly correlates with the core functional groups of GABA, thereby avoiding interference from weak signal intervals. Although iVISSA extended the wavelength range, the newly added discrete intervals exhibited weak signals and low specificity—potentially containing background noise irrelevant to GABA—which may cause the model to learn erroneous features.
The coarsely extracted key wavelength set was refined using CARS and BOSS. For the key wavelengths initially selected by iRF, CARS refined 23 key wavelengths, while BOSS refined 26. Notably, the model built with the wavelengths selected by BOSS demonstrated higher prediction accuracy, achieving RC2 = 0.7715, RMSEC = 9.6015, RPDC = 2.0920, RP2 = 0.7701, RMSEP = 9.8746, and RPDP = 2.0856. The ultimately optimized wavelength set was determined as 1021, 1025, 1030, 1049, 1058, 1068, 1073, 1077, 1082, 1087, 1091, 1096, 1115, 1124, 1275, 1280, 1299, 1313, 1318, and 1327 nm. For the key wavelengths initially selected by iVISSA, CARS refined 17 key wavelengths, while BOSS refined 16. However, the model built with wavelengths selected by CARS demonstrated higher prediction accuracy, achieving RC2 = 0.5510, RMSEC = 13.4580, RPDC = 1.4924, RP2 = 0.5421, RMSEP = 13.9349, and RPDP = 1.4778. Comparative analysis revealed that the detection model built with the wavelength set refined by iRF-BOSS achieved optimal performance.
3.4. Key Wavelength Extraction and Detection Model Results for Vitamin B9 in Foxtail Millet
The results of using millet vitamin B9 raw data, preprocessing data, and key extraction data combined with the BiLSTM–Adaboost model are shown in
Table S3. The BiLSTM–Adaboost was used to establish an association model between the original spectral data of foxtail millet and the content of vitamin B9. The prediction results are shown in
Figure 5, with performance metrics: R
C2 = 0.6554, RMSE
C = 8.3265, RPD
C = 1.7035, R
P2 = 0.6391, RMSE
P = 10.0447, and RPD
P= 1.6646. After preprocessing with S-G, DWT, and SNV, the results improved: R
C2 = 0.8164, RMSE
C = 6.3903, RPD
C = 2.3338, R
P2 = 0.8083, RMSE
P = 6.5725, and RPD
P = 2.2840.
For vitamin B9, 82 key wavelengths were extracted using iRF, which were distributed in the ranges of 959–1157, 1318–1379, 1398–1464, and 1605–1648 nm. The 959–1157 nm range primarily involves the first overtone of C-H and N-H bonds, which may be related to the aromatic or heterocyclic structures in the folic acid molecule. The 1318–1379 nm range corresponds to the second overtone of the O-H bonds in hydroxyl groups, which could be influenced by hydroxyl groups in the folic acid molecule or moisture. The 1398–1464 nm range is associated with hydrogen bonding interactions within the folic acid molecule. The 1605–1648 nm range may correspond to the characteristic absorption of the glutamic acid group in the side chain of folic acid. The iVISSA rough selection has additional wavelength intervals, of 1157–1318 and 1506–1605 nm, compared to iRF. The 1157–1318 nm range may include interaction signals between folic acid and other components (such as proteins or carbohydrates) or the absorption from specific conjugated structures in the folic acid molecule. The 1506–1605 nm range could involve higher overtones of C-H bonds or vibrations of the overall molecular framework [
49]. By adding these two wavelength intervals, iVISSA covers a more complete spectral key of the folic acid molecule, reducing the omission of key information.
The coarsely extracted key wavelength set was refined using CARS and BOSS. For the key wavelengths initially selected by iRF, CARS refined 36 key wavelengths, while BOSS refined 36 key wavelengths. Meanwhile, through comparison, the model built with the wavelengths selected by BOSS demonstrated higher prediction accuracy, achieving RC2 = 0.9111, RMSEC = 4.7457, RPDC = 3.3539, RP2 = 0.8856, RMSEP = 4.8471, and RPDP = 2.9566. For the key wavelengths initially selected by iVISSA, CARS refined 33 key wavelengths, while BOSS refined 25 key wavelengths. However, through comparison, the model built with the wavelengths selected by BOSS demonstrated higher prediction accuracy, achieving RC2 = 0.9362, RMSEC = 4.0215, RPDC = 3.9590, RP2 = 0.8932, RMSEP = 4.6676, and RPDP = 3.0600. The ultimately optimized wavelength set was determined as 1016, 1073, 1091, 1096, 1101, 1181, 1186, 1190, 1223, 1228, 1233, 1313, 1322, 1341, 1346, 1351, 1360, 1365, 1398, 1445, 1516, 1558, 1624, 1638, and 1648 nm. Comparative analysis revealed that the detection model built with the wavelength set refined by iVISSA-BOSS technology achieved optimal performance, demonstrating excellence in the detection of vitamin B9.
Figure 5.
Detection results of the BiLSTM–Adaboost model. (A,D) are R2 of the calibration set and the prediction set, respectively; (B,E) are the RMSE of the calibration set and the prediction set, respectively; (C,F) are the RPD of the calibration set and the prediction set, respectively.
Figure 5.
Detection results of the BiLSTM–Adaboost model. (A,D) are R2 of the calibration set and the prediction set, respectively; (B,E) are the RMSE of the calibration set and the prediction set, respectively; (C,F) are the RPD of the calibration set and the prediction set, respectively.
4. Discussion
There are significant differences in the GABA and vitamin B9 contents among different varieties of foxtail millet. These differences reflect both the genetic traits of the varieties and the regulatory effects of key enzymes in the metabolic pathways. The higher GABA content in ‘Changnong No.41’ and ‘Changnong No.50’ may be related to the activity of glutamate decarboxylase (GAD), an enzyme that catalyzes the decarboxylation of glutamate to produce GABA. The variations in the expression of its encoding genes may lead to differences in accumulation capacity among varieties. The extreme differences in vitamin B9 content, with ‘Changnong No.54’ exhibiting high levels and ‘Changnong No.49’ exhibiting low levels, may be related to the activity of dihydrofolate reductase in the folic acid synthesis pathway or to gene polymorphism. Notably, some varieties exhibit the characteristic of ‘specific accumulation’. ‘Changnong No.41’ has a particularly high proportion of GABA, while ‘Changnong No.54’ is predominantly rich in vitamin B9. This tendency may be related to the long-term breeding goals or environmental adaptability of the varieties.
As shown in
Figure 3, the wavelength range of 950–997 nm primarily corresponds to the transition between vibrational energy levels of O-H bonds in water molecules and C-H bonds in carbohydrates, where light absorption occurs. The 997–1100 nm range may be associated with vibrational modes of functional groups such as amide groups in proteins or C-H stretching vibrations in lipids. Within the 1100–1199 nm range, complex molecular chain structures contribute to vibrational absorption of bonds like O-H and C-O [
50]. The 1199–1298 nm range likely relates to combination bands of C-H and O-H vibrations. In the 1298–1468 nm range, strong overtone absorption of O-H vibrations dominates. The 1468–1650 nm range may involve coupled stretching vibrations from overtones and combination bands of C-H, C-O, and O-H bonds.
The key wavelength extraction is a key step in spectral modeling, aimed at selecting critical information points highly correlated with the target component from hundreds of wavelengths, thereby reducing data dimensionality and enhancing model efficiency. This work compared two coarse extraction methods, iRF and iVISSA, and found that the performance differences were closely related to the spectral response characteristics of the molecular structure of the components. In GABA detection, iRF outperforms iVISSA. iRF focuses on the continuous strong signal intervals of 955–1124 nm and 1275–1341 nm, corresponding to the first overtone absorption of C-H and N-H bonds and combination vibration modes in GABA molecules [
51]. These regions have strong signals and high signal-to-noise ratios, directly related to amino and methylene functional groups [
52], avoiding interference from weak signal intervals. However, the additional ranges of iVISSA, such as 1360–1445 nm, contain absorption signals of water (O-H overtone) and carbohydrates [
53], which have no direct correlation with the GABA structure, resulting in the model learning redundant information and having a lower prediction accuracy than iRF. In the detection of vitamin B9, iVISSA is superior. The additional 1157–1318 nm and 1506–1605 nm ranges in iVISSA cover the characteristic absorption of the aromatic ring, heterocyclic structures, and side-chain glutamic acid groups of the folate molecules [
54]. These regions, which involve high-order overtones of C-H bonds and fundamental vibrations of the molecular skeleton, constitute integral components of folic acid-specific spectral signatures. In contrast, iRF does not include these ranges, potentially missing key structural information, leading to lower model accuracy than the iVISSA-BOSS combination. Further key wavelength selection through CARS and BOSS revealed that BOSS performed better in both GABA and vitamin B9 detection. This may be due to the different selection mechanisms of the two methods. BOSS retains wavelengths with high stability through guided sampling, while CARS is based on variable weights and exponential decay, which is suitable for integrating strong signal regions and multi-interval features of complex structures in GABA and vitamin B9. Ultimately, the optimal wavelength set focuses on absorption peak vertices or slope mutation points, directly linking molecular structure to spectral response. This strategy avoids the interference of redundant information from continuous intervals, significantly improving the model’s prediction accuracy and generalization ability.
iRF-BOSS selects wavelengths highly concentrated in the strong absorption region of hydrogen-containing groups: 14 wavelengths (accounting for 70%) are distributed in the range of 1021 to 1124 nanometers, representing the most typical spectral characteristics of GABA molecules. These wavelengths exhibit intense signals and high specificity, directly related to the content of amino groups and methylene groups. Moreover, 6 wavelengths covering 1275–1327 nm retain core sensitive points for combination vibrations [
55]. They encompass peak positions in the combination band region (1299 nm, 1313 nm), which are sensitive to the conformational changes of GABA molecules, thereby further enhancing the accuracy of concentration prediction [
56]. The refined wavelengths exist as discrete single points, all located at the vertices or sudden slope changes of the spectral absorption peaks. These serve as “informational anchor points” that maximally reflect the changes in GABA concentration, effectively avoiding the interference from redundant wavelengths in continuous intervals.
iVISSA-BOSS precisely focuses on specific spectral regions of the vitamin B9 molecular core structure: 15 wavelengths (accounting for 60%) are distributed in the range of 959–1157 nanometers, mainly corresponding to the first overtones of C-H and N-H bonds [
57]. This represents the typical spectral key range for the aromatic and heterocyclic structures in folic acid molecules, with signals exhibiting significant specificity that directly correlates with the content information of key structures in folic acid. Within the core sensitive regions reflecting intramolecular interactions, 8 wavelengths are distributed across the 1318–1379 nm and 1398–1464 nm intervals. Among them, 1318–1379 nm is related to the second overtone vibration of the O-H bonds in the hydroxyl groups, which can sensitively capture the impact of the hydroxyl functional groups and water in the folic acid molecule on the spectral signals [
58]. The 1398–1464 nm range corresponds to the characteristic region of hydrogen bond interactions within the molecule, presenting a highly sensitive response to structural changes in the folic acid molecule [
59]. These wavelengths cover the key sites of intramolecular interactions, providing spectral support at the structural level for the precise prediction of vitamin B9 concentration. Additionally, 2 wavelengths located at 1605–1648 nm are presumed to be related to the characteristic absorption of the glutamic acid moiety in the folic acid side chain, effectively supplementing the spectral representation of the overall structure of the molecule. Notably, all refined wavelengths exist as discrete single points, precisely located at the vertices or critical positions of sudden slope changes in the spectral absorption peaks. This strategy avoids the interference from redundant wavelengths in continuous intervals, enabling the model to efficiently extract core spectral information relevant to concentration, thereby achieving accurate detection of vitamin B9 content in foxtail millet. This wavelength selection strategy, focused on key informational anchor points, not only significantly enhances the model’s prediction accuracy but also strengthens the reliability of the detection method in terms of stability and generalization capability.
The stacked BiLSTM–Adaboost model demonstrates significant advantages in GABA detection. Its core strength lies in fully leveraging BiLSTM’s deep processing capability for spectral sequence information, enabling it to accurately capture latent dependencies between different wavelengths [
60]. Simultaneously, by utilizing Adaboost’s ensemble learning mechanism, the model substantially enhances its fitting capacity and generalization ability for complex data. Vergara-Diaz O [
61] established a detection model for wheat NIR spectral data and GABA using PLS, achieving an R
2 = 0.71. Consequently, compared to traditional machine learning models, this stacked model can more efficiently handle the nonlinear relationships and long-range dependencies within spectral data, significantly improving detection accuracy. In the vitamin B9 detection, this model effectively captures the complex spectral features of folic acid molecules, markedly boosting prediction accuracy and stability. Compared to GABA detection, the key wavelengths for vitamin B9 are more broadly distributed, involving more molecular structural characteristics, which places higher demands on the model’s learning capability. The stacked BiLSTM–Adaboost model [
62], with its unique architecture and ensemble learning advantages, successfully meets this requirement.
However, this study still has certain limitations. Firstly, the limited sample size—covering only 190 samples from 19 varieties across one production region—may affect the model’s generalizability. Future research should expand the scope and quantity of samples to enhance the model’s robustness. Secondly, potential issues in broader application exist: as foxtail millet from different regions varies in growth environments (e.g., soil, climate), its GABA and vitamin B9 content and spectral characteristics may differ. The model’s applicability to millet from other production areas requires further validation. Finally, limitations arise in real-time or field applications. The current detection process requires professionals to operate spectrometers and perform data preprocessing, making it challenging to meet the demand for rapid field detection. Subsequent efforts should integrate portable spectral devices and lightweight model algorithms to optimize the detection process and reduce detection time, thereby improving practicality.
5. Conclusions
This study focuses on the application of near-infrared spectroscopy (NIRS) technology for the nondestructive detection of γ-aminobutyric acid (GABA) and vitamin B9 in millet. Innovatively, it proposes four key variable extraction strategies—iRF-CARS, iRF-BOSS, iVISSA-CARS, and iVISSA-BOSS—and establishes detection models centered on these strategies.
Initially, the study systematically analyzed the GABA and vitamin B9 content across diverse millet varieties. The results indicated significant inter-varietal differences, which may be closely associated with factors such as the millet’s genetic characteristics and environmental adaptability. These findings provide a critical foundation for the precise screening of nutrient-rich millet varieties.
Furthermore, the study integrates the four proposed key extraction strategies with a stacked BiLSTM–Adaboost model. The experimental results demonstrate that the key wavelength screening method introduced in this work effectively reduces data dimensionality and enhances critical information. Consequently, the stacked BiLSTM–Adaboost model exhibits significantly improved performance in detecting GABA and vitamin B9 content in millet, achieving not only substantially higher prediction accuracy but also markedly enhanced model stability.
Future research will proceed in several directions:
Expanding the sample size to encompass more millet varieties will facilitate investigation into the specific mechanisms by which genetic and environmental factors influence GABA and vitamin B9 content, aiming to develop more robust variety screening models.
For the stacked BiLSTM–Adaboost model, we plan to optimize its architecture and hyperparameters while exploring integration with other deep learning techniques to enhance its generalization capability and detection efficiency.
Extending the research scope to include spectral detection of other nutritional components in millet, we will leverage existing key extraction strategies and modeling expertise to establish multi-component simultaneous detection models.
This integrated approach will provide comprehensive technical support for millet quality evaluation and functional food development.