Method and system for detecting illegal additives in food based on surface-enhanced raman spectroscopy
By constructing a standard Raman characteristic peak database for illegal additives and purifying spectral data using a three-layer composite judgment logic, the problems of low signal-to-noise ratio and masked characteristic peaks in the detection of illegal additives in food testing were solved, achieving high-precision detection of illegal food additives.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA ACAD OF INSPECTION & QUARANTINE GUANGDONG-HONG KONG-MACAO GREATER BAY AREA RES INST
- Filing Date
- 2026-05-13
- Publication Date
- 2026-06-09
Smart Images

Figure CN122173905A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of food testing technology, and in particular to a method and system for detecting illegal food additives based on surface-enhanced Raman spectroscopy. Background Technology
[0002] In the field of food safety supervision, the rapid and accurate detection of illegal additives (such as sildenafil, tadalafil, Sudan Red, melamine, etc.) is a crucial link in safeguarding public health. Surface-enhanced Raman spectroscopy (SERS) has been widely used in recent years for on-site screening of trace prohibited substances in food due to its advantages such as high sensitivity, specific molecular fingerprints, and no need for complex pretreatment. However, the actual food matrix (such as dairy products, beverages, condiments, etc.) has a complex composition, often accompanied by strong fluorescence background, scattering noise, and overlapping Raman peaks of multiple chemical components, resulting in low signal-to-noise ratio of the original spectrum, distortion of characteristic peak shapes, or even masking.
[0003] In existing technologies, the common practice for identifying illegal additives in food using spectral data is to directly feed the raw spectrum into a classification model after simple preprocessing (such as smoothing, baseline correction, and normalization). However, raw spectra often contain hundreds or even thousands of wavelengths, the vast majority of which do not originate from the target additive but rather from the sample's matrix components (such as moisture, protein, fat, lactose, etc.) or are introduced by physical scattering, environmental background, and instrument noise. This information, unrelated to the analyte, not only fails to provide effective basis for classification but also interferes with the model's learning process. More importantly, adjacent bands in the spectrum are often highly correlated (correlation coefficients often exceed 0.95), leading to severe data redundancy and multicollinearity. In this situation, the model struggles to accurately assess the true contribution of each band to the discrimination result. For example, in distance- or regression-dependent algorithms such as PLS-DA, SVM, or KNN, redundant bands may disproportionately amplify variance in certain directions, causing the model to focus more on common matrix variations rather than the spectral responses specific to illicit additives. In deep learning frameworks, a large amount of redundant input not only increases training difficulty but also easily leads to local optima in the optimization process, reducing the efficiency and specificity of feature extraction. Ultimately, the model's sensitivity to real chemical differences and its generalization ability are weakened. On the other hand, many typical illicit additives (such as melamine, Sudan Red, and malachite green) typically have weak, narrow bandwidth characteristic peaks in their spectra, often masked near the strong absorption regions of complex matrix components—such as the amide I / II band of proteins, the O–H stretching vibration region of water, or the C–H absorption band of fats. This makes their specific signals easily obscured by background interference, further exacerbating the difficulty of identification using full-spectrum modeling methods. When modeling with unfiltered full-spectrum data, these weak but crucial discriminative signals are easily masked or averaged by the surrounding strong and broad background absorption. For example, in near-infrared spectroscopy, the characteristic peaks of melamine at approximately 1480 nm and 2150 nm may be completely obscured by the broad absorption of water and milk proteins in the sample; in Raman spectroscopy, the sharp peaks of low-concentration illegal dyes may also be drowned out by the fluorescent background or the broad peaks of the principal components. Without prior knowledge guidance or intelligent algorithms focusing on truly sensitive bands, the model will be unable to effectively capture these subtle but crucial chemical fingerprints, leading to blurred category boundaries, increased false positive rates, and significantly reduced recognition accuracy and reliability. Summary of the Invention
[0004] This application aims to at least partially address one of the technical problems in the related art.
[0005] To achieve the above objectives, this application proposes a method for detecting illegal food additives based on surface-enhanced Raman spectroscopy, comprising the following steps: Step 1: Collect raw Raman spectral data of the food sample. The raw Raman spectral data includes several wavenumber points within the wavenumber range and the corresponding Raman scattering intensity values. Step 2: Based on the pre-constructed standard Raman characteristic peak database of illegal additives, determine the target characteristic band set, which consists of several consecutive wavenumber intervals; Step 3: Based on the wavenumber points of the original Raman spectral data, mark the wavenumber points and their corresponding Raman scattering intensity values that do not belong to the target feature band set as irrelevant data and remove them, and mark the remaining wavenumber points and their corresponding Raman scattering intensity values as preliminary screening spectral data. Step 4: Construct a local spectral sequence based on the preliminary screened spectral data, calculate three composite spectral feature indices, and identify overlapping interference regions by combining judgment logic; Step 5: Perform composite judgment logic based on each of the overlapping interference regions, and remove data points according to the judgment results to obtain purified spectral data; Step 6: Based on the purified spectral data, perform candidate peak detection, identify all wavenumber points that satisfy the local maximum condition as candidate peaks, identify valid Raman peaks based on the candidate peaks, construct feature vectors and standardize them as input data for classification model prediction, and output the category of illegal additives.
[0006] Furthermore, based on the preliminary screened spectral data, a local spectral sequence is constructed, three composite spectral feature indices are calculated, and overlapping interference regions are identified using judgment logic, including the following steps: Step 41: Based on each target feature band set of the preliminary screened spectral data, obtain preliminary wavenumber points and corresponding preliminary Raman scattering intensity values, and construct a local spectral sequence based on the preliminary wavenumber points and corresponding preliminary Raman scattering intensity values; Step 42: Construct the peak shape asymmetry index, intensity wavenumber gradient covariance, and local dynamic signal-to-noise ratio based on the local spectral sequence; Step 43: If all three of the following conditions are met simultaneously, the current target feature band set is marked as an overlapping interference region; otherwise, all data points in the current target feature band set are removed. The three conditions are as follows: The peak shape asymmetry index is greater than a preset asymmetry threshold; The intensity wavenumber gradient covariance is greater than a preset upper limit of covariance; The local dynamic signal-to-noise ratio is greater than a preset signal-to-noise ratio threshold.
[0007] Furthermore, a peak shape asymmetry index is constructed based on the local spectral sequence, including: Determine the initial maximum Raman scattering intensity and the corresponding first wavenumber point in the local spectral sequence; Obtain the first and second preliminary Raman scattering intensity values corresponding to the left and right boundaries of the current target feature band set; Based on the maximum value of the initial Raman scattering intensity, the first initial Raman scattering intensity value, and the second initial Raman scattering intensity value, a half-height intensity threshold is generated; Based on the left side of the first wavenumber point, search for the first wavenumber point less than or equal to the intensity threshold at half height along the wavenumber point decreasing direction and mark it as the left wavenumber point at half height; based on the right side of the first wavenumber point, search for the first wavenumber point less than or equal to the intensity threshold at half height along the wavenumber point increasing direction and mark it as the right wavenumber point at half height. The first difference is calculated based on the first wavenumber point and the wavenumber point on the left side of the half-height, and the second difference is calculated based on the first wavenumber point and the wavenumber point on the right side of the half-height. The peak asymmetry index is generated based on the ratio of the first difference and the second difference.
[0008] Furthermore, constructing the intensity wavenumber gradient covariance and local dynamic signal-to-noise ratio based on the local spectral sequence includes: An intensity difference and a wavenumber difference are generated based on adjacent preliminary wavenumber points and preliminary Raman scattering intensity values within the local spectral sequence; the intensity wavenumber gradient covariance is obtained based on the intensity difference and wavenumber difference; a sliding window of a preset width is constructed with the first wavenumber point as the center, and the intensity mean and intensity standard deviation are obtained based on the preliminary Raman scattering intensity values within the sliding window; the local dynamic signal-to-noise ratio is obtained based on the maximum value, mean, and standard deviation of the preliminary Raman scattering intensity.
[0009] Furthermore, based on each of the aforementioned overlapping interference regions, a composite judgment logic is executed, and data points are removed according to the judgment result to obtain purified spectral data, including the following steps: Step 51, first layer of composite judgment logic: determine the global peak-to-valley ratio based on each of the overlapping interference regions. If the global peak-to-valley ratio is less than the first threshold, then all data points in the current overlapping interference region are removed; otherwise, execute the second layer of composite judgment logic. Step 52, second layer composite judgment logic: Based on the current overlapping interference region, perform adaptive wavelet decomposition, extract wavelet decomposition scales at least two scales, construct energy ratio according to the two wavelet decomposition scales, if the energy ratio is greater than the second threshold, then remove all data points in the current overlapping interference region; otherwise, proceed to step 53 to execute the third layer composite judgment logic. Step 53: Based on the pre-constructed database of standard Raman characteristic peaks of illegal additives, illegal additives located in the overlapping interference region are screened and recorded as a candidate substance set; based on the single candidate substance and any two candidate substances in the candidate substance set, a candidate combination substance set is obtained. Step 54: Based on the illegal additives included in the candidate composition material set, and based on the pre-constructed standard Raman characteristic peak database of illegal additives, determine the wavenumber, relative intensity, and peak standard deviation of the main characteristic peaks and construct a Gaussian function together. Calculate the Gaussian value of the Gaussian function at each wavenumber point in the overlapping interference region, and obtain a Gaussian vector based on the Gaussian value. Concatenate the Gaussian vectors of all candidate compositions in the candidate composition material set column-wise to construct a reference spectral matrix. Step 55: Based on the preliminary Raman scattering intensity values at each wavenumber point in the overlapping interference region, construct the measured spectral vector; solve the least squares problem based on the measured spectral vector and the reference spectral matrix to obtain the weight vector; and obtain the reconstructed spectral matrix based on the weight vector and the reference spectral matrix. Step 56: Combine a single candidate substance and any two candidate substances from the candidate substance set to construct single reconstruction error and double reconstruction error based on the reconstructed spectral matrix and the measured spectral vector, respectively. Step 57: If the dual reconstruction error of the current dual-substance combination is less than x times the single reconstruction error, and the main characteristic peak wavenumbers of the two illegal additives in the current dual-substance combination fall within the corresponding standard tolerance range, then retain all data points in the current overlapping interference region; where x is greater than 0. Step 58: If the single reconstruction error of the current single candidate substance is less than the upper limit of the single substance fitting error, and the wavenumber of the main feature peak of the current single candidate substance falls into the corresponding standard tolerance range, then only the wavenumber points of the current single candidate substance in the corresponding component support set are retained. Step 59: If the conditions in Steps 57-58 are not met, all data points in the current overlapping interference area are removed, and the remaining wavenumber points and the corresponding preliminary Raman scattering intensity values are merged to obtain purified spectral data.
[0010] Furthermore, the process of constructing the component support set includes: Calculate the sum of all elements in the Gaussian vector and label it as the Gaussian sum. The Gaussian values of all wavenumber points are accumulated in ascending order to obtain a cumulative value. When the cumulative value is first greater than or equal to 0.025 times the sum of the Gaussian values, the current wavenumber point is marked as the second wavenumber point. The Gaussian values of all wavenumber points are accumulated in descending order to obtain a cumulative value. When the cumulative value is first greater than or equal to 0.025 times the sum of the Gaussian values, the current wavenumber point is marked as the third wavenumber point. Using the second wavenumber point as the left boundary and the third wavenumber point as the right boundary, a component support set is constructed based on the left and right boundaries.
[0011] Furthermore, based on the candidate peaks, valid Raman peaks are identified, and feature vectors are constructed, including the following steps: Step 61: Smooth the purified spectral data using a moving median filter to obtain the estimated background intensity for each wavenumber point; obtain the residual sequence based on the preliminary Raman scattering intensity values and estimated background intensity at the wavenumber points, and calculate the standard deviation of the residual sequence. Step 62: Identify the number of wave points and the preliminary Raman scattering intensity value of the candidate peak, and record them as the peak wave point and peak intensity, respectively. A candidate peak is considered a valid Raman peak if it meets the following three conditions; otherwise, it is considered an ineffective Raman peak. The three conditions are as follows: The estimated background intensity of the peak point is greater than 3 times the standard deviation of the residual sequence; The full width at half maximum (FWHM) of the candidate peak is within the target range; The peak wave number point lies within any consecutive wavenumber point interval; Step 63: Based on all the effective Raman peaks, arrange them in descending order of peak intensity, and select the first two effective Raman peaks as the main peaks; Step 64: Obtain the main peak spacing, normalized intensity ratio, average peak width, minimum local peak-to-valley ratio, and number of effective main peaks based on the main peaks, and then concatenate the main peak spacing, normalized intensity ratio, average peak width, minimum local peak-to-valley ratio, and number of effective main peaks in sequence to form a feature vector.
[0012] Furthermore, the main peak spacing is the difference between the peak values of the first two effective Raman peaks; the normalized intensity ratio is the ratio of the peak intensities of the first two effective Raman peaks; the average peak width is the average of the full width at half maximum (FWHM) of the first two effective Raman peaks; and the minimum local peak-to-valley ratio is the minimum local peak-to-valley ratio of the first two effective Raman peaks.
[0013] Furthermore, the first intensity and the second intensity corresponding to the two nearest local minima to the left and right of the peak wave point are obtained, the average intensity of the first intensity and the second intensity are calculated, and the local peak-to-valley ratio is obtained based on the peak intensity and the average intensity.
[0014] This invention also provides a food additive detection system based on surface-enhanced Raman spectroscopy, comprising the following modules: The data acquisition module is used to acquire raw Raman spectral data of food samples; The data analysis module is used to determine the target feature band set based on pre-constructed standard Raman characteristic peak data of illegal additives; The data processing module is used to mark and remove wavenumber points and their corresponding Raman scattering intensity values that do not belong to the target feature band set as irrelevant data based on each wavenumber point of the original Raman spectral data, and to mark the remaining wavenumber points and their corresponding Raman scattering intensity values as preliminary screening spectral data. The identification module is used to construct a local spectral sequence based on the preliminary screened spectral data, calculate three composite spectral feature indices, and identify overlapping interference regions by combining judgment logic. The elimination analysis module is used to perform composite judgment logic based on each of the overlapping interference regions, and to eliminate data points according to the judgment results to obtain purified spectral data. The detection module is used to perform candidate peak detection based on the purified spectral data, identify all wavenumber points that satisfy the local maximum condition as candidate peaks, identify valid Raman peaks based on the candidate peaks, construct feature vectors and standardize them as input data for a classification model for prediction, and output the category of illegal additives.
[0015] Compared with existing technologies, the surface-enhanced Raman spectroscopy-based method and system for detecting illegal food additives provided in this application, by introducing a pre-constructed standard Raman characteristic peak database for illegal additives, can accurately pinpoint the continuous wavenumber range corresponding to each type of target substance as the target characteristic band set, and directly eliminate all irrelevant bands, effectively eliminating irrelevant signal interference caused by food matrix components such as moisture, protein, and fat, as well as instrument noise. This significantly reduces data redundancy and multicollinearity, allowing subsequent modeling to focus on truly chemically meaningful fingerprint regions, thereby improving the model's generalization ability.
[0016] To address the problem of weak Raman signals and easy peak overlap with coexisting components caused by illegal additives (such as melamine and Sudan Red) in complex food systems, this invention innovatively constructs a three-layer composite judgment logic-driven mechanism for purifying overlapping interference regions. First, it calculates three composite spectral characteristic indicators—peak asymmetry index, intensity wavenumber gradient covariance, and local dynamic signal-to-noise ratio—using local spectral sequences to initially identify potential overlapping regions. Then, it sequentially uses the global peak-to-valley ratio and wavelet decomposition energy ratio for two rounds of coarse screening, efficiently eliminating meaningless or single-component-dominated regions. Most importantly, the third layer of logic constructs Gaussian functions for candidate single-substance and dual-substance combinations to generate a reference spectral matrix, which is then least-squares fitted to the measured spectral vector. The reconstruction error is used to quantitatively assess the matching degree of different substance combinations. This process not only intelligently distinguishes between single-additive and multi-substance coexistence scenarios but also accurately retains effective signal points and eliminates interference tails or spurious responses based on whether the main characteristic peak wavenumber falls within the standard tolerance range and the component support set range, ultimately outputting highly pure spectral data. This purification strategy, which combines physical models with data-driven approaches, greatly enhances the ability to resolve weak, overlapping Raman peaks in complex matrices.
[0017] In the feature extraction stage, this invention selects candidate peaks that simultaneously meet the following criteria: significant background intensity (>3 times the residual standard deviation), full width at half maximum (FWHM) within a reasonable physical range, and located within a continuous effective wavenumber interval, as effective Raman peaks. Based on this, five structured discrimination indicators are further extracted: peak spacing, normalized intensity ratio, average peak width, minimum local peak-to-valley ratio, and number of effective peaks. These indicators are then concatenated to form a low-dimensional, high-information-density feature vector. The design significantly improves prediction accuracy because the main peak spacing reflects the inherent energy difference between molecular vibrational modes, exhibiting high material specificity and effectively distinguishing illegally added substances with similar chemical structures. The normalized intensity ratio eliminates the influence of external factors such as laser power and sample concentration, preserving the relative intensity relationship between different characteristic peaks—a key fingerprint for identifying specific compounds. The average peak width is closely related to the microenvironment and aggregation state of the molecules, helping to determine whether peak broadening is caused by matrix effects or interference from coexisting substances. The minimum local peak-to-valley ratio quantifies the contrast between the main peak and its neighboring valleys, directly reflecting signal clarity and signal-to-noise ratio, and helping to filter weak spurious peaks. The number of effective main peaks provides a macroscopic measure of material complexity, distinguishing between single additives and multi-component mixtures. These five indicators together constitute the feature space, comprehensively characterizing the Raman fingerprint essence of the target substance from multiple dimensions such as peak position, peak intensity, peak shape, and peak distribution. This enables the classification model to make decisions based on more discriminative and robust inputs, thereby significantly improving recognition accuracy, anti-interference ability, and generalization performance. Attached Figure Description
[0018] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 A flowchart illustrating the method for detecting illegal food additives based on surface-enhanced Raman spectroscopy provided in this application embodiment; Figure 2 This is a structural block diagram of the food additive detection system based on surface-enhanced Raman spectroscopy provided in an embodiment of this application. Figure 3 This is a block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0019] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0020] The following describes, with reference to the accompanying drawings, a method and system for detecting illegal food additives based on surface-enhanced Raman spectroscopy, according to embodiments of this application.
[0021] like Figure 1 As shown, the method and system for detecting illegal food additives based on surface-enhanced Raman spectroscopy includes the following steps: Step 1: Collect raw Raman spectral data of the food sample. The raw Raman spectral data includes several wavenumber points within the wavenumber range and the corresponding Raman scattering intensity values.
[0022] This embodiment uses a portable surface-enhanced Raman spectrometer (such as one equipped with a 785nm laser excitation source and a spectral resolution ≤6cm). -1 Commercial equipment with a signal-to-noise ratio ≥300:1 was used for rapid on-site testing of liquid dairy product samples. First, the milk sample to be tested was mixed with a pre-prepared gold-silver core-shell SERS substrate at a 1:1 volume ratio. After thorough shaking, the mixture was allowed to stand for 5 minutes to enrich potential illegal additives (such as melamine) on the surface of the nanoparticles. Then, 10 μL of the mixture was dropped onto a quartz slide and placed in the sample chamber of a portable Raman spectrometer. Raw Raman spectral data were acquired under ambient temperature (25℃), laser power of 50 mW, and integration time of 5 seconds. The obtained spectra covered a wavenumber range of 100 cm⁻¹. -1 Up to 2500cm -1 It contains a total of 2401 equally spaced wavenumber points (step size approximately 1 cm). -1 Each wavenumber point corresponds to a Raman scattering intensity value, forming the original spectral vector.
[0023] Step 2: Based on the pre-constructed standard Raman characteristic peak database of illegal additives, determine the target characteristic band set, which consists of several continuous wavenumber intervals.
[0024] This embodiment first constructs a standard Raman characteristic peak database for illegal additives. This database stores standardized spectral characteristic information of various common illegal food additives (such as melamine, Sudan I, malachite green, etc.) in the form of structured data tables. For each target substance (illegal food additive), the database records not only the wavenumbers of several main characteristic peaks (e.g., 687 cm⁻¹ for melamine), but also... -1 986cm -1 and 1327cm -1 The corresponding relative intensities (ratios normalized to the strongest peak, such as 0.42, 1.0, 0.75) and peak standard deviation (reflecting typical peak width, such as 32cm) are also included. -1 Furthermore, a standard tolerance range is configured for each main characteristic peak (usually set to center wavenumber ±5cm). -1(To accommodate instrument drift and environmental disturbances). For each main characteristic peak wavenumber and its tolerance range, it is extended into a continuous wavenumber range, and appropriately extended outward based on peak width information (e.g., extended outward by ±5cm). -1 This process ultimately forms a local window that covers the complete outline of the peak. After merging all windows corresponding to the main peaks, the overlapping parts are removed and the windows are arranged in ascending order of wavenumber to form a set of target characteristic wavebands specific to the substance. This set is essentially an ordered list composed of several non-overlapping or adjacent continuous wavenumber intervals. For example, the target characteristic waveband set of melamine can be represented as {(680,695),(980,995),(1320,1335)}.
[0025] Step 3: Based on the wavenumber points of the original Raman spectral data, mark the wavenumber points and their corresponding Raman scattering intensity values that do not belong to the target feature band set as irrelevant data and remove them. Mark the remaining wavenumber points and their corresponding Raman scattering intensity values as preliminary screening spectral data.
[0026] Traverse each wavenumber point in the original spectrum and determine whether it falls within any of the aforementioned continuous wavenumber intervals for the target. Taking the target characteristic wavenumber set of melamine as an example, if a wavenumber point is within the range {(680,695),(980,995),(1320,1335)}, then retain that wavenumber point and its corresponding Raman scattering intensity value; if it falls within other regions (such as 100–679 cm⁻¹), then retain the wavenumber point and its corresponding Raman scattering intensity value. -1 696–979 cm -1 996–1319 cm -1 Or 1336–2500 cm -1 If a wavenumber point and its intensity value are not found in the target range, they are marked as irrelevant data and completely removed from subsequent analysis. After this filtering process, only about 45 wavenumber points (680–695 including 16 points, 980–995 including 16 points, and 1320–1335 including 16 points; some endpoints may vary slightly due to rounding) and their corresponding intensity values remain in the original spectrum, constituting the preliminary filtered spectral data. This dataset is stored in a structured array format, containing two columns: one column is the retained wavenumber coordinates, and the other column is the corresponding original Raman scattering intensity.
[0027] Step 4: Construct a local spectral sequence based on the preliminary screened spectral data, calculate three composite spectral feature indices, and identify overlapping interference regions by combining judgment logic.
[0028] Step 41: Based on each target feature band set of the preliminary screened spectral data, obtain preliminary wavenumber points and corresponding preliminary Raman scattering intensity values, and construct a local spectral sequence based on the preliminary wavenumber points and corresponding preliminary Raman scattering intensity values.
[0029] Taking melamine, the substance to be detected, as an example, its target characteristic band set consists of three non-overlapping continuous intervals: {(680, 695), (980, 995), (1320, 1335)}. For each independent band in this set, the corresponding subset data is extracted: First, the first band [680, 695] is processed, and the spectral data is initially screened to select all wavenumber points that satisfy 680 ≤ wavenumber point ≤ 695 and their corresponding Raman scattering intensity values. These are then arranged in ascending order of wavenumber to form an ordered two-dimensional data pair sequence; this sequence is the first local spectral sequence. Similarly, the same operation is performed on the second band [980, 995] to extract 16 points with wavenumbers from 980 to 995 and their intensities, constructing the second local spectral sequence; then, the third local spectral sequence is constructed for the third band [1320, 1335]. Each local spectral sequence is a structured local spectral segment that fully preserves the original sampling resolution and intensity information without any transformation, and covers only the theoretical response region of a single main characteristic peak.
[0030] Step 42: Construct the peak shape asymmetry index, intensity wavenumber gradient covariance, and local dynamic signal-to-noise ratio based on the local spectral sequence; Constructing a peak shape asymmetry index based on the local spectral sequence includes: The process involves: determining the maximum initial Raman scattering intensity and the corresponding first wavenumber point in the local spectral sequence; obtaining the first and second initial Raman scattering intensity values corresponding to the left and right boundaries of the current target feature band set; generating a half-height intensity threshold based on the maximum initial Raman scattering intensity, the first initial Raman scattering intensity value, and the second initial Raman scattering intensity value; searching for the first wavenumber point less than or equal to the half-height intensity threshold along the decreasing wavenumber direction based on the left side of the first wavenumber point and marking it as the left half-height wavenumber point; searching for the first wavenumber point less than or equal to the half-height intensity threshold along the increasing wavenumber direction based on the right side of the first wavenumber point and marking it as the right half-height wavenumber point; calculating a first difference based on the first wavenumber point and the left half-height wavenumber point, calculating a second difference based on the first wavenumber point and the right half-height wavenumber point, and generating a peak asymmetry index based on the ratio of the first difference and the second difference.
[0031] In this embodiment, within the wavenumber range covered by the local spectral sequence, all wavenumber points and their corresponding preliminary Raman scattering intensity values are traversed. The data point with the highest intensity is identified and recorded as the maximum preliminary Raman scattering intensity, and the first wavenumber point corresponding to this maximum value is also recorded. The preliminary Raman scattering intensity values corresponding to the left and right boundary wavenumber points of the local band in the current target feature band set are obtained and recorded as the first and second preliminary Raman scattering intensity values, respectively. Based on these three intensity values, the half-height intensity threshold is calculated: first, the arithmetic mean of the first and second preliminary Raman scattering intensity values is calculated, and then this average is averaged again with the maximum preliminary Raman scattering intensity. The result is the half-height intensity threshold used for subsequent peak width determination.
[0032] Starting from the first wavenumber point, a linear search is performed in both directions of decreasing and increasing wavenumbers: On the left (i.e., the direction of decreasing wavenumbers), the Raman scattering intensity of each wavenumber point is checked point by point, starting from the wavenumber preceding the first wavenumber point, until the first wavenumber point with an intensity less than or equal to the half-height threshold is found, and this is marked as the left half-height wavenumber point; if no wavenumber point satisfying the condition is found after searching along this direction to the left boundary of the target characteristic band, then the left boundary wavenumber point is directly taken as the left half-height wavenumber point. Similarly, on the right (i.e., the direction of increasing wavenumbers), the Raman scattering intensity of each wavenumber point is checked point by point, starting from the wavenumber following the first wavenumber point, to find the first wavenumber point with an intensity less than or equal to the half-height threshold, which is taken as the right half-height wavenumber point; if no point satisfying the condition is found even to the right boundary of the target characteristic band, then the right boundary wavenumber point is taken as the right half-height wavenumber point.
[0033] Calculate the wavenumber difference between the first wavenumber point and the wavenumber point on the left side of the half-height, and denote it as the first difference; calculate the wavenumber difference between the wavenumber point on the right side of the half-height and the first wavenumber point, and denote it as the second difference. Define the ratio of the first difference to the second difference as the peak asymmetry index.
[0034] Constructing the intensity wavenumber gradient covariance and local dynamic signal-to-noise ratio based on the local spectral sequence includes: An intensity difference and a wavenumber difference are generated based on adjacent preliminary wavenumber points and preliminary Raman scattering intensity values within the local spectral sequence; the intensity wavenumber gradient covariance is obtained based on the intensity difference and wavenumber difference; a sliding window of a preset width is constructed with the first wavenumber point as the center, and the intensity mean and intensity standard deviation are obtained based on the preliminary Raman scattering intensity values within the sliding window; the local dynamic signal-to-noise ratio is obtained based on the maximum value, mean, and standard deviation of the preliminary Raman scattering intensity.
[0035] For all adjacent initial wavenumber points and their corresponding initial Raman scattering intensity values in the local spectral sequence, the intensity difference and wavenumber difference between adjacent points are calculated sequentially. For the k-th adjacent wavenumber point pair, the intensity difference is defined as the difference in intensity between the current point and the previous point, and the wavenumber difference is defined as the difference in corresponding wavenumbers; the intensity-wavenumber gradient is the intensity difference divided by the wavenumber difference. The gradient values calculated for all adjacent intervals are used to form a gradient sequence. Two subsequences are constructed from this gradient sequence: the first subsequence is formed by removing the last gradient value from the original gradient sequence, and the second subsequence is formed by removing the first gradient value from the original gradient sequence. Furthermore, the covariance between this gradient sequence and its subsequence shifted one position backward using the covariance formula is calculated, i.e., the intensity-wavenumber gradient covariance. This covariance is used to quantify the orderliness of gradient changes: a typical Raman peak has a positive gradient on the rising edge and a negative gradient on the falling edge, exhibiting an overall pattern of first increasing and then decreasing, resulting in adjacent gradient values having opposite signs and a negative covariance; while intensity fluctuations caused by random noise cause the gradient to jump irregularly, and the covariance tends to be close to zero or positive. Therefore, this covariance is used to determine whether a local spectrum has the typical morphological characteristics of a true Raman peak.
[0036] In practice, a sliding window of a preset width (e.g., ±5 cm) is set centered on the wavenumber at which the detected local peak is located (i.e., the first wavenumber point). -1 The window covers 11 consecutive wavenumber points; if the window exceeds the boundary of the current target characteristic band, it is automatically truncated to the effective range. Within this window, the corresponding preliminary Raman scattering intensity values are extracted, and their mean and standard deviation are calculated. Based on this, combined with the maximum intensity value within the window, the local dynamic signal-to-noise ratio is further calculated, and the calculation method is as follows: (Peak intensity - mean intensity within the window) ÷ standard deviation of intensity within the window.
[0037] This indicator effectively reflects the significance of the peak signal relative to local background fluctuations, helping to distinguish true Raman peaks from random noise or baseline ripples. It reflects the significance of the peak signal relative to local background fluctuations and has the ability to adapt to baseline and noise levels. For example, when the peak intensity is much higher than the local mean and the standard deviation is small, the signal-to-noise ratio is high, indicating that the peak is very likely a true characteristic peak; conversely, it may be noise fluctuation. Ultimately, this local dynamic signal-to-noise ratio, together with the aforementioned peak shape asymmetry index and intensity wavenumber gradient covariance, constitutes a three-layer composite criterion system. Only when all three indicators meet their respective preset threshold conditions is the local spectral sequence determined to be a valid Raman characteristic peak, thereby achieving high-precision and robust intelligent spectral identification and verification.
[0038] Step 43: If all three of the following conditions are met simultaneously, the current target feature band set is marked as an overlapping interference region; otherwise, all data points in the current target feature band set are removed. The three conditions are as follows: The peak shape asymmetry index is greater than a preset asymmetry threshold; The intensity wavenumber gradient covariance is greater than a preset upper limit of covariance; The local dynamic signal-to-noise ratio is greater than a preset signal-to-noise ratio threshold.
[0039] In this embodiment, the overlapping interference region refers to a continuous wavenumber interval in the Raman spectrum. All preliminary wavenumber points within this interval and their corresponding preliminary Raman scattering intensity values together constitute a subset of data judged to be affected by multiple signal superposition interference. This type of region is usually caused by the following reasons: partial or complete overlap of Raman characteristic peaks from multiple different substances at similar wavenumber positions; coupling of strong fluorescence background with the true Raman peak; or broadened spurious peaks caused by abnormal instrument response (such as stray light or detector hotspots). Its typical manifestation is severely asymmetrical peak shape and disordered gradient changes, but due to the superposition effect, it still maintains a high signal-to-noise ratio and is easily misjudged as a valid characteristic peak.
[0040] To accurately identify such regions, the following triple condition determination is performed on the current target feature band set: (1) The peak shape asymmetry index is greater than the preset asymmetry threshold; (2) The intensity wavenumber gradient covariance is greater than the preset upper limit of covariance; (3) The local dynamic signal-to-noise ratio is greater than the preset signal-to-noise ratio threshold.
[0041] Only when all three conditions above are met will the entire wavenumber interval corresponding to the target feature band set (i.e., the continuous range from the wavenumber at the left boundary to the wavenumber at the right boundary of the set) be marked as an overlapping interference region; otherwise, regardless of whether it contains potential signals, all data points in the interval will be completely removed from the subsequent component matching and quantitative analysis process, and only the original data will be retained for log recording or visualization annotation.
[0042] The threshold values were set based on a combination of measured data from a large number of standard samples and Monte Carlo noise simulations. The peak shape asymmetry index of an ideal symmetrical peak approaches 1. Statistical analysis of Raman spectra of 50 common chemicals (such as benzoic acid, ethanol, and polystyrene) under 785 nm excitation showed that 95% of the effective single-peak asymmetry indices were ≤ 2.5. Therefore, the preset asymmetry threshold was set to 2.5; values exceeding this indicate severe peak distortion, possibly influenced by tailing of adjacent peaks or baseline drift.
[0043] Covariance is used to measure the correlation between adjacent gradients. For a pure single-peak Raman signal, its gradient sequence usually exhibits a clear positive-to-negative transition (i.e., a rising edge followed immediately by a falling edge), in which case the covariance is mostly negative, typically within the range of -5 × 10⁻⁵ in practical measurements. 4 to -2×10 5 In contrast, when peaks overlap or a strong fluorescence background is present, gradient changes tend to be random, and the covariance often approaches zero or even becomes positive.
[0044] Statistical analysis of 100 sets of synthesized spectra containing double-peak overlap revealed that when the covariance is greater than -1×10⁻⁶... 4 When this occurs, the probability of peak overlap increases significantly. The upper limit threshold for covariance is set to -5 × 10⁻⁵. 3 In other words, only when the calculated covariance is greater than this negative value is it determined that there may be anomalies (such as overlapping peaks or background interference) in the region, thereby triggering the subsequent processing mechanism.
[0045] Furthermore, the local dynamic signal-to-noise ratio (SNR) is used to quantify the significance of peak intensity relative to its neighboring background fluctuations, essentially reflecting how many standard deviations the peak value exceeds the local mean. Experiments show that the local dynamic SNR of a true weak peak can be as low as 3, while that of strong interference can reach over 50. However, overlapping interference regions exhibit high SNR and distorted peak shapes. Statistics show that when the local dynamic SNR is greater than 15 and accompanied by high asymmetry, over 90% of the peaks are multiple peaks superimposed. Therefore, the preset SNR threshold is set to 15.
[0046] For example, in an unknown sample at 1580–1620 cm -1 A broad peak was detected within the band range: the calculated peak asymmetry index was 3.1, and the intensity wavenumber gradient covariance was +800 (au / cm). -1 ) 2 The local dynamic signal-to-noise ratio is 18.7. All three conditions are met, meaning the range is 1580–1620 cm. -1 The entire wavenumber interval is marked as the overlapping interference region, including all wavenumber points within this interval (e.g., 1580, 1581, …, 1620 cm⁻¹). -1 The values of these peaks and their corresponding intensity values are classified as unreliable data and are not included in the material database matching. Conversely, if a peak is located between 1000 and 1010 cm⁻¹, the corresponding intensity values are considered unreliable data and are not included in the material database matching. -1 In the interval, the local dynamic signal-to-noise ratio is 20, but the asymmetry index is 1.8. Therefore, since the first condition is not met, the interval is 1000–1010 cm. -1 The affected intervals are still excluded as a whole because they do not meet the typical combination characteristics of overlapping interference. This mechanism effectively suppresses the misidentification of spurious peaks in complex matrices, significantly improving the reliability and anti-interference capability of Raman spectroscopy analysis.
[0047] This embodiment only marks the entire target feature band set (i.e., all data points within the wavenumber interval) as an overlapping interference region when all three conditions are met simultaneously. This means that although the region exhibits a high signal-to-noise ratio (easily mistaken for a true strong peak), its peak shape is severely asymmetrical and its gradient changes are chaotic, which conforms to the typical characteristics of multi-peak superposition or broadening interference. If any condition is not met (e.g., high signal-to-noise ratio but symmetrical peak shape, or asymmetrical peak shape but low signal-to-noise ratio), it indicates that the region is neither a reliable true peak nor possesses the complete characteristics of overlapping interference, and is therefore completely eliminated to avoid introducing ambiguity or erroneous information. This strategy of retaining the mark only when all conditions are met and eliminating all others significantly improves the specificity of interference identification: on the one hand, it prevents the over-elimination of effective signals by misjudging isolated noise or weak true peaks as interference regions; on the other hand, it can accurately capture those high-risk regions that "look like strong peaks but are actually superposition artifacts." Ultimately, this method effectively reduces the false positive matching rate, improves the accuracy of component identification and the robustness of quantitative results in Raman spectral analysis of complex matrices (such as biological tissues, mixed chemicals or environmental samples), and provides a reliable data purification foundation for high-throughput, automated spectral analysis.
[0048] Step 5: Perform composite judgment logic based on each of the overlapping interference regions, and remove data points according to the judgment results to obtain purified spectral data; Step 51, first layer composite judgment logic: determine the global peak-to-valley ratio based on each of the overlapping interference regions. If the global peak-to-valley ratio is less than the first threshold, then all data points in the current overlapping interference region are removed; otherwise, execute the second layer composite judgment logic.
[0049] For each identified overlapping interference region, all preliminary Raman scattering intensity values are extracted within its corresponding wavenumber interval, and the global peak-to-valley ratio is calculated within that region: the ratio of the maximum intensity value to the minimum intensity value within that region (where the minimum intensity value is greater than 0, and if a negative value exists, the absolute value is taken). This ratio reflects the strength of the signal's dynamic range within the interference region.
[0050] The calculated global peak-to-valley ratio is compared with a preset first threshold, which is set to 5 after extensive experimental calibration. If the global peak-to-valley ratio of the current overlapping interference region is less than 5, the region is determined to be a weak signal interference region. Typical causes include weak fluorescence fluctuations, low-amplitude electronic noise, or extremely weak and broadened residual real signals. Although these regions meet the aforementioned triple conditions (such as covariance anomalous due to random fluctuations in local gradients), the overall intensity changes are gradual and lack significant peak structures. Such regions do not have the value of being used as effective chemical characteristic peaks and retain information that may introduce redundancy or misleading information. Therefore, all data points contained in this overlapping interference region (i.e., all wavenumbers and their corresponding intensities within the entire wavenumber range) are directly removed and no longer participate in any subsequent analysis process.
[0051] Conversely, if the signal does not exhibit significant intensity fluctuations within the overlapping interference region, it indicates strong signal dynamics. This is highly likely caused by partial or complete overlap of two or more real Raman peaks at similar wavenumber positions. Instead of immediate removal, these regions proceed to the second layer of composite judgment logic to attempt further analysis or retain potential effective component information. This first-layer composite judgment mechanism achieves initial intensity-level screening of overlapping interference regions: it avoids mistaking meaningless weak fluctuations for high-value interference regions, thus avoiding wasting computational resources, while ensuring focused attention on complex overlapping regions with significant intensity structures. This approach improves the precision and reliability of spectral analysis while maintaining analytical efficiency.
[0052] Step 52, second layer composite judgment logic: Based on the current overlapping interference region, perform adaptive wavelet decomposition, extract wavelet decomposition scales at least two scales, construct energy ratio based on the two wavelet decomposition scales, if the energy ratio is greater than the second threshold, then remove all data points in the current overlapping interference region, otherwise, proceed to step 53 to execute the third layer composite judgment logic.
[0053] For the overlapping interference regions retained after passing the first layer of composite judgment logic, the system further executes the second layer of composite judgment logic to determine whether the region is composed of peak overlap of real chemical signals or dominated by non-structural interference such as high-frequency noise and instrument artifacts. The local spectral sequence corresponding to this overlapping interference region is used as the input signal for adaptive wavelet decomposition. The system automatically selects appropriate wavelet basis functions and a suitable number of decomposition layers based on the data length, sampling density, and spectral characteristics of the local spectrum, typically decomposing it into at least three layers to ensure effective extraction of multi-scale features.
[0054] After wavelet decomposition, the focus is on extracting two adjacent high-frequency detail subbands, typically the detail coefficients of the first (finest scale) and second (sub-finest scale). The first-level detail coefficients primarily reflect the fastest and most localized intensity changes in the spectrum, such as sharp jumps or random noise; the second-level detail coefficients capture the slightly gentler but still localized fluctuation features. The energy values of these two detail subbands are calculated separately: for each value in the first-level detail coefficient sequence, it is squared, and then all squared values are summed to obtain the first-level energy value; similarly, the same squared and summed operation is performed on the second-level detail coefficient sequence to obtain the second-level energy value. These two energy values quantify the overall fluctuation intensity of the spectrum at the finest and sub-finest scales, respectively.
[0055] Based on this, an energy ratio is constructed: the energy value of the first layer is divided by the energy value of the second layer. This energy ratio is used to measure the activity of high-frequency details relative to the next higher frequency details. If the ratio is large, it indicates that the fluctuations at the finest scale are much stronger than those at the next finest scale, which is usually a typical manifestation of random noise or interference from non-chemical sources; if the ratio is small, it indicates that the signal has coordinated structural features across multiple scales, which is more consistent with the smooth contour formed by the overlap of multiple real Raman peaks.
[0056] The energy ratio is compared with a preset second threshold (e.g., set to 3). If the energy ratio is greater than the second threshold, the current overlapping interference region is determined to be mainly composed of high-frequency interference and has no value for retention; therefore, all data points in this region are removed. If the energy ratio is less than or equal to the second threshold, the region is considered to potentially contain real overlapping peaks with analytical significance, and these peaks are not removed; instead, the process continues to the third-layer composite judgment logic specified in step 53. Through the above-mentioned second-layer discrimination mechanism based on wavelet multi-scale energy analysis, the system can effectively filter out high-frequency artifacts while retaining valuable overlapping signals, significantly improving the accuracy and reliability of Raman spectroscopy analysis.
[0057] Step 53: Based on the pre-constructed database of standard Raman characteristic peaks of illegal additives, illegal additives located in the overlapping interference region are screened and denoted as a candidate substance set; based on the single candidate substance and any two candidate substances in the candidate substance set, a candidate combination substance set is obtained.
[0058] The database is traversed to identify the standard characteristic peak positions of all illegally added substances. Substances whose wavenumbers for any of their characteristic peaks fall within the current overlapping interference region are selected and grouped into a candidate substance set. For example, if an overlapping interference region is located at 1580 cm⁻¹... -1 Up to 1620 cm -1 The characteristic peak of Sudan I in the database is between 1602 cm⁻¹ and 1602 cm⁻¹. -1 Malachite green is 1615 cm -1 If both are included in the candidate material set, then both will be included in the candidate material set.
[0059] To further address the potential coexistence of multiple illegal additives in real-world samples, this study not only considers the matching possibilities of single substances but also expands the candidate substance set through combination. Specifically, each individual candidate substance in the set serves as a basic unit, and all possible pairwise combinations are generated (i.e., any two different substances selected from the set form a combination), thus constructing a candidate combination substance set. This set includes both single-substance assumptions (e.g., containing only Sudan I) and two-substance mixture assumptions (e.g., the coexistence of Sudan I and malachite green). This combination strategy ensures that subsequent analyses can cover more complex contamination scenarios, avoiding the omission of real-world complex additive cases due to considering only a single component. The final candidate combination substance set will serve as input.
[0060] Step 54: Based on the illegal additives included in the candidate composition material set, and based on the pre-constructed standard Raman characteristic peak database of illegal additives, determine the wavenumber, relative intensity, and peak standard deviation of the main characteristic peak and construct a Gaussian function together. Calculate the Gaussian value of the Gaussian function at each wavenumber point in the overlapping interference region, and obtain a Gaussian vector based on the Gaussian value. Concatenate the Gaussian vectors of all candidate compositions in the candidate composition material set column by column to construct a reference spectral matrix.
[0061] , Let v be the Gaussian value of the current wavenumber point, and A be the relative intensity. Main characteristic peak wavenumber, The standard deviation of the peak value is given.
[0062] For a candidate substance (such as Sudan I), if it contains multiple characteristic peaks in the database (e.g., 1602 cm⁻¹), -1 1350 cm -1 1140 cm -1 If each characteristic peak is a Gaussian function, then these Gaussian functions are superimposed on all wavenumber points covered by the overlapping interference region to obtain the synthetic Gaussian spectral response of the substance in that region.
[0063] Subsequently, each discrete wavenumber point within the overlapping interference region is traversed (e.g., from 1580 cm⁻¹). -1 up to 1620 cm -1 Step length is 1 cm -1 (A total of 41 points), calculate the function value of the synthesized Gaussian function at each wavenumber point to form a Gaussian vector. This vector fully characterizes the theoretical Raman response profile of the candidate material within the current overlapping interference region.
[0064] After constructing Gaussian vectors for all candidate material combinations (including all single-substance combinations and pairwise combinations), these Gaussian vectors are concatenated column-wise to form a two-dimensional reference spectral matrix. Each column of this matrix corresponds to the theoretical spectral response of a candidate material combination, and each row corresponds to a specific wavenumber point in the overlapping interference region. For example, if the candidate material combination set contains 5 single-substance combinations and 10 pairwise combinations, totaling 15 candidates, then the size of the reference spectral matrix is N×15, where N is the number of wavenumber points in the overlapping interference region.
[0065] Step 55: Based on the preliminary Raman scattering intensity values at each wavenumber point in the overlapping interference region, construct the measured spectral vector, solve the least squares problem based on the measured spectral vector and the reference spectral matrix to obtain the weight vector, and obtain the reconstructed spectral matrix based on the weight vector and the reference spectral matrix.
[0066] This embodiment extracts the preliminary Raman scattering intensity value corresponding to each wavenumber point within the overlapping interference region and arranges them in ascending order of wavenumber to form a column vector of length N, denoted as the measured spectral vector y. The measured spectrum is modeled as a linear combination of the columns of the reference spectral matrix, i.e., it is assumed that: Let w be the weight vector to be solved, where each element represents the relative contribution intensity of the corresponding candidate substance in the current mixed signal. To solve this underdetermined or overdetermined linear system, the nonnegative least squares method is used to solve the following optimization problem: `min` represents the minimum value operation. The optimal weight vector `w` is obtained through a numerical optimization algorithm. The reconstructed spectral matrix is calculated by performing matrix multiplication with the reference spectral matrix using this optimal weight vector. This vector represents the best linear approximation of the measured spectrum given the current set of candidate substances.
[0067] Step 56: Combine individual candidate substances and any two candidate substances from the candidate substance set to construct single reconstruction error and double reconstruction error based on the reconstructed spectral matrix and the measured spectral vector, respectively.
[0068] The single reconstruction error and double reconstruction error are obtained based on the Euclidean distance between the measured spectral vectors and the reconstructed spectral matrix of a single candidate substance and any two candidate substance combinations. The columns corresponding to a single candidate substance and any two candidate substance combinations in the reconstructed spectral matrix are selected, and the Euclidean distance is calculated between them and the measured spectral vectors. The minimum value of the Euclidean distance is taken as the single reconstruction error and double reconstruction error.
[0069] Step 57: If the dual reconstruction error of the current dual-substance combination is less than x times the single reconstruction error, and the main characteristic peak wavenumbers of the two illegal additives in the current dual-substance combination fall within the corresponding standard tolerance range, then retain all data points in the current overlapping interference region; where x is greater than 0, 0.7≤x≤0.9; When both the above-mentioned error ratio condition and the main peak position tolerance condition are met simultaneously, it is determined that the current overlapping interference region is most likely contributed by the two substances together, rather than caused by a single component or random noise. In this case, all original data points within the overlapping interference region will be retained without removal or simplification to ensure that subsequent quantitative analysis or report generation can fully reflect the true multi-component mixing state.
[0070] When dealing with overlapping interference regions, the following criterion is adopted: only when the double reconstruction error of a certain two-substance combination is less than x times the single reconstruction error, and the wavenumbers of the main characteristic peaks of the two illegal additives both fall within their respective preset standard tolerance ranges, are all data points in that region retained. From the perspective of fitting error: if a region does indeed contain two target additives (such as melamine and Sudan Red), fitting the entire spectrum with only one substance will inevitably fail to explain the characteristic signal contributed by the other substance, resulting in a large single-substance reconstruction residual; however, after introducing both substances for fitting, the model can more completely restore the measured spectrum, and the overall error is significantly reduced. Therefore, a double reconstruction error that is significantly lower than a single reconstruction error (i.e., less than x times) is a powerful indicator of the coexistence of multiple components. Relying solely on error reduction is insufficient to confirm the authenticity of the components; some noise or background fluctuations may also occasionally lead to a reduction in error. Therefore, it is also necessary to verify whether the main peak positions of the identified substances are reasonable. Requiring the wavenumbers of the main characteristic peaks of the two substances to fall within their respective standard tolerance ranges can effectively eliminate misjudgments due to similar spectra but different chemical natures. Only when both of the above conditions are met can the spectral characteristics of the overlapping region be considered to be jointly generated by the two illegal additives, with clear chemical evidence, and worth retaining the original data for subsequent analysis. Conversely, if the error improvement is not significant, or if any main peak deviates from the standard position, it indicates that the region is likely to be interfered with by noise, fluorescence background drift, or other non-target signals. Forcibly retaining it will introduce false information and affect the final discrimination result. Through this dual verification mechanism combining fitting quality and peak position accuracy, without relying on complex deep learning models, it is possible to effectively identify real multi-component coexistence signals and eliminate unreliable data in the preprocessing stage, thereby improving the reliability of the purified spectrum and the discrimination ability of the classification model. Step 58: If the single reconstruction error of the current single candidate substance is less than the upper limit of the single substance fitting error, and the wavenumber of the main feature peak of the current single candidate substance falls within the corresponding standard tolerance range, then only the wavenumber points of the current single candidate substance in the corresponding component support set are retained.
[0071] This embodiment only applies to combinations where the candidate set contains only a single candidate substance. Under standard experimental conditions (e.g., 785nm laser excitation, integration time 1 s, signal-to-noise ratio >30 dB), a single illegal additive sample with a known concentration is repeatedly measured (e.g., 100 times). The single reconstruction error obtained from each fitting is calculated, and its 95th percentile is taken as the upper limit benchmark. During the judgment process, if the single reconstruction error of a candidate substance is less than this upper limit, it indicates that its theoretical spectrum can well explain the overall shape of the measured signal; however, to further ensure the physical reliability of the identification results, it is also necessary to verify whether the wavenumber of the main characteristic peak of the substance falls within its corresponding standard tolerance range. For example, the nominal wavenumber of the main characteristic peak of melamine is 680 cm⁻¹. -1 The standard tolerance range is set at ±4 cm. -1 (i.e., 676–684 cm) -1 The closest value to 680 cm⁻¹ was detected from the measured spectrum. -1 The local maximum point is located at 676–684 cm. -1 If the location is within the acceptable range, then the main peak is considered to exist and be in a reasonable position.
[0072] When both of the above conditions are met, the candidate substance is deemed highly likely to actually exist in the sample. In this case, instead of retaining all wavenumber points in the entire overlapping interference region, only those wavenumber points in the reference spectrum that belong to the component support set are retained. The component support set refers to the set of all wavenumber positions in the standard spectrum where the substance's intensity exceeds 10% of its peak value, representing the characteristic region where the component has a significant Raman response. For example, if the support set of melamine includes 620, 650, 680, and 710 cm⁻¹... -1 If 12 wavenumber points are selected, only the data from these 12 positions in the measured spectrum will be retained, and the remaining wavenumber points (even those within the original overlapping region) will be discarded or set to zero. This selective retention strategy can focus on the most discriminative feature information while effectively suppressing interference from other coexisting components or background, thereby improving the accuracy and robustness of subsequent qualitative / quantitative analysis.
[0073] In another embodiment, the process of constructing the component support set includes: Calculate the sum of all elements in the Gaussian vector and mark it as the Gaussian sum. Accumulate the Gaussian values of all wavenumber points in ascending order to obtain the accumulated value. When the accumulated value is first greater than or equal to 0.025 times the Gaussian sum, mark the current corresponding wavenumber point as the second wavenumber point. Accumulate the Gaussian values of all wavenumber points in descending order to obtain the accumulated value. When the accumulated value is first greater than or equal to 0.025 times the Gaussian sum, mark the current corresponding wavenumber point as the third wavenumber point. Use the second wavenumber point as the left boundary and the third wavenumber point as the right boundary to construct a component support set based on the left and right boundaries.
[0074] In this embodiment, the method of adaptively determining the left and right boundaries based on the 2.5% energy accumulation ratio of the Gaussian summation can accurately capture the core region with true discriminative and stable characteristics in the spectral response of each substance, namely the area between the starting and ending points where the low-intensity tail transitions to a significant response. This dynamic boundary strategy based on energy distribution not only preserves the main peak and its effective shoulder information but also effectively eliminates edge noise points that contribute little or even harm to component identification, significantly improving the signal-to-noise ratio of feature extraction.
[0075] Secondly, the construction method of this support set is closely coupled with subsequent steps such as error assessment and data point retention. In scenarios with overlapping interference from multiple components, fitting verification and data retention are performed only on the wavenumber points corresponding to this support set, avoiding misjudgments caused by interference from other components across the entire spectrum. For example, when the main peak position of a candidate substance meets the standard tolerance range and the single reconstruction error is within the acceptable range, only the wavenumber points within its support set are retained for final judgment, thus focusing on the most chemically specific information and suppressing cross-interference. Furthermore, since the support set is generated independently based on the spectral shape of each substance, different substances may have different support sets even if their main peaks are similar, which further enhances the algorithm's ability to distinguish structurally similar substances.
[0076] Finally, regardless of variations in the Raman peak width, shape, or relative intensity of candidate substances (e.g., influenced by instrument resolution, sample matrix, or concentration), as long as their Gaussian model can reasonably characterize their spectral features, the support set can automatically adapt to their effective response range without the need for manual parameter presets or frequent threshold adjustments. Therefore, this strategy of constructing component support sets based on energy accumulation ratios not only improves the accuracy and reliability of identifying illegal additives but also provides a solid technical foundation for the rapid screening of trace components in complex food, pharmaceutical, and other real-world samples.
[0077] Step 59: If the conditions in Steps 57-58 are not met, all data points in the current overlapping interference area are removed, and the remaining wavenumber points and the corresponding preliminary Raman scattering intensity values are merged to obtain purified spectral data.
[0078] This application precisely achieves intelligent purification of overlapping interference regions in Raman spectroscopy, thereby effectively distinguishing true component signals from various background interferences. When processing each overlapping interference region, the global peak-to-valley ratio is used as the first screening step: if the region's overall fluctuations are weak (i.e., the peak-to-valley ratio is below the first threshold), it indicates a lack of significant chemical characteristics and is highly likely noise or a smooth baseline drift; therefore, all data points are directly removed to avoid invalid modeling. If it passes the second-level judgment, adaptive wavelet decomposition is performed to extract detail coefficients at multiple scales and calculate the high-to-low frequency energy ratio; if the high-frequency energy ratio is too high (i.e., the energy ratio is greater than the second threshold), it is determined that the region is mainly dominated by fluorescence background abrupt changes, instrument artifacts, or non-component scattering, and is also removed, thus effectively filtering out common physical interferences such as fluorescence drift.
[0079] For regions that pass the first two layers of screening, a pre-constructed database of standard Raman characteristic peaks for illegal additives is used to screen for candidate substances that may exist in this band, generating a candidate set containing single substances and combinations of two substances. For each candidate combination, a Gaussian function is constructed based on its main characteristic peak wavenumber, relative intensity, and peak width parameters to form a reference spectral matrix, which is then fitted with the measured spectral vector using least squares to obtain the reconstructed spectrum and the corresponding weights and errors. Based on this, a third layer of refined discrimination is implemented: if the double reconstruction error of a certain combination of two substances is significantly better than that of a single substance (less than x times the single reconstruction error), and the main peaks of both substances fall within their respective standard tolerance ranges, then it is considered that there are indeed coexisting components in this region, and all data points are retained; if only a single substance meets the upper limit of the fitting error and the main peak position is accurate, then only the data points of that substance within its component support set (i.e., the energy-concentrated, discriminative wavenumber range) are retained, achieving on-demand retention, which retains chemically significant characteristic information while eliminating parts that may be affected by cross-interference from neighboring components.
[0080] Through the aforementioned triple logic, Raman responses genuinely originating from illegal additives are dynamically identified and retained, while noise, fluorescence background, instrument artifacts, and unreliable signals caused by multi-component overlap are systematically eliminated. The final purified spectral data not only clearly presents the characteristic peak structure of the target analyte in complex food matrices (such as samples containing pigments, proteins, or fats), but also significantly reduces false responses, resulting in a substantial improvement in the accuracy and specificity of illegal additive identification and a marked decrease in the false alarm rate. This high-fidelity, low-interference spectral data provides a highly reliable input basis for subsequent qualitative determinations (such as whether Sudan Red is present), effectively enhancing the reliability and practicality of Raman rapid detection technology in real-world regulatory scenarios.
[0081] Step 6: Based on the purified spectral data, perform candidate peak detection, identify all wavenumber points that satisfy the local maximum condition as candidate peaks, identify valid Raman peaks based on the candidate peaks, construct feature vectors and standardize them as input data for classification model prediction, and output the category of illegal additives.
[0082] Traverse all valid wavenumber points (i.e., points that are non-zero or marked as valid after purification) on the entire wavenumber axis, and check whether each point satisfies the local maximum condition: that is, the initial Raman scattering intensity value of the point is strictly greater than the intensity values of several adjacent wavenumber points in its left and right neighborhoods. The size of the neighborhood window can be set according to the instrument resolution and the width of a typical Raman peak, for example, taking 3 wavenumber points on each side (a total of 7 points) to avoid misjudging noise spikes as peaks.
[0083] Step 61: Smooth the purified spectral data using a moving median filter to obtain the estimated background intensity for each wavenumber point; obtain the residual sequence based on the preliminary Raman scattering intensity value and the estimated background intensity for the wavenumber point, and calculate the standard deviation of the residual sequence.
[0084] Set a sliding window width (e.g., 31 wavenumber points, adjustable based on instrument resolution and typical fluorescence background variation scale), and slide it point by point along the entire wavenumber axis. At each center position, take the median of all valid spectral intensity values within the window as the estimated background intensity for that wavenumber point. Choosing the median instead of the mean effectively suppresses interference from residual sharp Raman peaks or outliers on the background estimation, ensuring that the extracted components are smooth and continuous baseline drift components (such as fluorescence background). If there are too few valid points within the window (e.g., below a threshold), interpolation or retaining the previous valid estimate can be used. For each original wavenumber point (especially those within the retained component support set), subtract the estimated background intensity of the corresponding wavenumber point from the initial Raman scattering intensity value (i.e., the original intensity after purification but without background removal) to obtain the residual value for that point. Arrange the residuals of all wavenumber points sequentially to form a complete residual sequence. This residual sequence should theoretically primarily reflect the true Raman signal (since the background has been subtracted) and residual noise. To further quantify data quality, calculate the standard deviation of this residual sequence as a measure of system noise level.
[0085] Step 62: Identify the number of wave points and the preliminary Raman scattering intensity value of the candidate peak, and record them as the peak wave point and peak intensity, respectively. A candidate peak is considered a valid Raman peak if it meets the following three conditions; otherwise, it is considered an ineffective Raman peak. The three conditions are as follows: The estimated background intensity of the peak point is greater than 3 times the standard deviation of the residual sequence; The full width at half maximum (FWHM) of the candidate peak is within the target range; The peak wave number point is located within any consecutive wavenumber point interval.
[0086] Calculate half the peak intensity of the candidate peak. Starting from the peak point and moving left (towards lower wavenumbers), iterate through the peak points, finding the first point with an intensity value less than or equal to half the peak intensity, and denote this as the left boundary. Similarly, iterate right from the peak point and moving right (towards higher wavenumbers), finding the first point with an intensity value less than or equal to half the peak intensity, and denote this as the right boundary. If no point with an intensity value less than half the peak intensity is found on either side (e.g., near the spectral edge), linear interpolation or a maximum search range can be used for boundary estimation. Finally, the full width at half maximum (FWHM) is defined as the wavenumber width corresponding to the difference between the left and right boundaries. This width must fall within a preset target range (e.g., for typical small molecule Raman peaks, the FWHM is typically between 4–25 cm⁻¹). -1 The specific range depends on the instrument resolution, sample properties, and prior database settings. Only when a candidate peak simultaneously meets all three of the above conditions is it ultimately determined to be a valid Raman peak.
[0087] Step 63: Based on all the effective Raman peaks, arrange them in descending order of peak intensity, and select the first two effective Raman peaks as the main peaks.
[0088] Step 64: Obtain the main peak spacing, normalized intensity ratio, average peak width, minimum local peak-to-valley ratio, and number of effective main peaks based on the main peaks, and then concatenate the main peak spacing, normalized intensity ratio, average peak width, minimum local peak-to-valley ratio, and number of effective main peaks in sequence to form a feature vector.
[0089] The main peak spacing is the difference between the peak values of the first two effective Raman peaks. The main peak spacing is calculated by taking the peak values of the first and second main peaks and calculating their absolute difference. This value reflects the wavenumber interval between the two strongest characteristic peaks and has good material specificity.
[0090] The normalized intensity ratio is the ratio of the peak intensities of the first two effective Raman peaks. It is calculated by dividing the peak intensity of the first main peak by the peak intensity of the second main peak. Since the peaks are arranged in descending order of intensity, this ratio is always greater than or equal to 1. This parameter characterizes the relative intensity relationship between the two main peaks and exhibits good stability under different concentrations or instrument conditions.
[0091] The average peak width is the average of the full width at half maximum (FWHM) of the two effective Raman peaks described above: obtain the FWHM of each of the two main peaks, and then calculate their arithmetic mean. This indicator reflects the overall sharpness or broadening of the main peak and can help distinguish between true Raman peaks and broadened background pseudo-peaks.
[0092] The minimum local peak-to-valley ratio is the minimum local peak-to-valley ratio of the first two effective Raman peaks.
[0093] Obtain the first and second intensities corresponding to the two nearest local minima to the left and right of the peak point. Calculate the average of the first and second intensities. Calculate the local peak-to-valley ratio based on the peak intensity and the average intensity. For each main peak, search for the two nearest local minima (i.e., local valleys) to the left and right of its peak point. Specifically, traverse leftward from the peak point to find the first local minima (the point where the intensity stops decreasing and begins to increase), and record its intensity as the first local valley intensity; similarly, find the first local minima to the right and record its intensity as the first local valley intensity. Calculate the average of the first and second local valley intensities, and record it as the local mean. Calculate the ratio of the peak intensity of the main peak to the local mean to obtain the local peak-to-valley ratio.
[0094] A large number of standard Raman spectra of known components were collected, such as spectral data of melamine, Sudan Red, and normal milk powder. For each spectrum, background subtraction and noise suppression were performed first, then the effective Raman peaks were identified, and the two highest-intensity peaks were selected as the main peaks. Based on these two main peaks, the system calculated five discriminative feature indicators: normalized intensity ratio, average peak width, minimum local peak-to-valley ratio, and number of effective main peaks. After generating the original five-dimensional feature vectors for all training samples using the above method, the mean and standard deviation of each feature dimension were calculated over the entire training set, and these statistical parameters were saved. These parameters were then used to standardize the feature vectors of all training samples, i.e., subtracting the mean of the corresponding dimension from each feature value and then dividing by the standard deviation of that dimension, so that each feature dimension has zero mean and unit variance. The standardized feature vectors, together with the corresponding substance category labels, constitute the final training dataset.
[0095] Based on this, a suitable classification model (such as support vector machine or random forest) is selected for training, and the model hyperparameters are optimized through methods such as cross-validation to ensure that the model has good recognition performance on the validation set. After training, the model structure, weights, and the mean and standard deviation parameters required for standardization are saved. In the actual detection stage, the constructed feature vector is standardized using the mean and standard deviation saved during training, and then the processed feature vector is input into the trained classification model to finally output the substance category and confidence level of the sample.
[0096] In practical system design, a clear data validity verification mechanism should be set after feature extraction and before model prediction. For example, if the number of valid main peaks is less than 1, it should be directly judged as an invalid spectrum or undetected; if the absolute value of each dimension of the standardized feature vector is lower than a very small threshold (e.g., 0.001), it should be considered as having no valid features and should be rejected from entering the prediction process. The system can return clear status prompts such as insufficient signal, inability to identify, or suggestion to resample. Only after confirming that the feature vector contains reasonable, non-degenerate valid information should it be input into the trained classification model for substance category prediction. This approach not only improves the robustness and reliability of the system but also meets the basic requirements for data quality control in scientific testing, avoiding false judgments on invalid or unreliable signals.
[0097] The feature vector constructed in this embodiment consists of the main peak spacing, normalized intensity ratio, average peak width, minimum local peak-to-valley ratio, and number of effective main peaks. Each of these components captures essential information closely related to the chemical structure of substances in Raman spectra from different dimensions, and their synergistic effect significantly improves the recognition accuracy of the classification model. First, the main peak spacing directly reflects the energy difference between molecular vibrational modes, serving as an inherent fingerprint feature of a substance. Due to differences in bonding methods and molecular configurations, the strongest Raman peaks of different compounds typically appear at specific and distinguishable wavenumber positions. Therefore, the main peak spacing has high specificity and can effectively distinguish substances with similar structures but different compositions (such as melamine and milk powder). Second, the normalized intensity ratio, by comparing the intensities of the two main peaks, eliminates the absolute intensity drift caused by external factors such as laser power fluctuations, sample concentration changes, or detector response differences. This ensures that the feature remains stable under different experimental conditions or instrument platforms, enhancing the model's generalization ability. Third, the average peak width (i.e., the average of the full width at half maximum (FWHM) of the two main peaks) is closely related to the physicochemical environment of the molecule. For example, crystalline substances usually exhibit narrower peaks, while molecules in amorphous forms or solutions have wider peaks. In addition, adulterants or impurities often cause peak broadening or distortion. Therefore, this indicator helps identify abnormal samples and improves the ability to distinguish isomers or mixtures. Fourth, the minimum local peak-to-valley ratio measures the contrast between the main peak and its neighboring background valleys, reflecting the signal-to-noise ratio and peak sharpness. True Raman peaks usually have obvious sharp contours and high peak-to-valley ratios, while noise or fluorescence spurious peaks show gentle fluctuations. This indicator can effectively suppress the interference of false positive peaks and ensure that the selected main peak has reliable physical meaning. Finally, the number of effective main peaks serves as an integrity verification indicator. It not only verifies whether there is a sufficiently strong characteristic signal in the spectrum, but also provides a basis for judging data quality before standardization. If there are insufficient effective main peaks, the entire feature vector may be unreliable, and the system can refuse to predict accordingly, avoiding incorrect judgments on low-quality data. In summary, these five indicators characterize the Raman response properties of substances from five complementary dimensions: location, intensity ratio, peak width, signal-to-noise ratio, and feature integrity. They not only retain highly discriminative chemical information but also eliminate redundancy and interference. By reducing the input dimension, they improve the robustness and interpretability of features, thereby significantly improving the recognition accuracy and stability of the classification model in complex real-world scenarios.
[0098] like Figure 2 As shown, this embodiment also discloses a food additive detection system based on surface-enhanced Raman spectroscopy, including the following modules: The data acquisition module is used to acquire raw Raman spectral data of food samples; The data analysis module is used to determine the target feature band set based on pre-constructed standard Raman characteristic peak data of illegal additives; The data processing module is used to mark and remove wavenumber points and their corresponding Raman scattering intensity values that do not belong to the target feature band set as irrelevant data based on each wavenumber point of the original Raman spectral data, and to mark the remaining wavenumber points and their corresponding Raman scattering intensity values as preliminary screening spectral data. The identification module is used to construct a local spectral sequence based on the preliminary screened spectral data, calculate three composite spectral feature indices, and identify overlapping interference regions by combining judgment logic. The elimination analysis module is used to perform composite judgment logic based on each of the overlapping interference regions, and to eliminate data points according to the judgment results to obtain purified spectral data. The detection module is used to perform candidate peak detection based on the purified spectral data, identify all wavenumber points that satisfy the local maximum condition as candidate peaks, identify valid Raman peaks based on the candidate peaks, construct feature vectors and standardize them as input data for a classification model for prediction, and output the category of illegal additives.
[0099] To implement the above embodiments, this application also proposes an electronic device. Please see [link to relevant documentation]. Figure 3 , Figure 3 This is a schematic diagram of the structure of the electronic device provided in an embodiment of this application. For example... Figure 3 As shown, the electronic device 500 includes: a processor 501 and a memory 502 communicatively connected to the processor 501; the memory 502 stores computer-executable instructions; the processor 501 executes the computer-executable instructions stored in the memory to implement the method provided in the foregoing embodiments.
[0100] To implement the above embodiments, this application also proposes a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the methods provided in the foregoing embodiments.
[0101] To implement the above embodiments, this application also proposes a computer program product, including a computer program that, when executed by a processor, implements the methods provided in the foregoing embodiments.
[0102] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A method for detecting illegal food additives based on surface-enhanced Raman spectroscopy, characterized in that, Includes the following steps: Step 1: Collect raw Raman spectral data of the food sample. The raw Raman spectral data includes several wavenumber points within the wavenumber range and the corresponding Raman scattering intensity values. Step 2: Based on the pre-constructed standard Raman characteristic peak database of illegal additives, determine the target characteristic band set, which consists of several consecutive wavenumber intervals; Step 3: Based on the wavenumber points of the original Raman spectral data, mark the wavenumber points and their corresponding Raman scattering intensity values that do not belong to the target feature band set as irrelevant data and remove them, and mark the remaining wavenumber points and their corresponding Raman scattering intensity values as preliminary screening spectral data. Step 4: Construct a local spectral sequence based on the preliminary screened spectral data, calculate three composite spectral feature indices, and identify overlapping interference regions by combining judgment logic; Step 5: Perform composite judgment logic based on each of the overlapping interference regions, and remove data points according to the judgment results to obtain purified spectral data; Step 6: Based on the purified spectral data, perform candidate peak detection, identify all wavenumber points that satisfy the local maximum condition as candidate peaks, identify valid Raman peaks based on the candidate peaks, construct feature vectors and standardize them as input data for classification model prediction, and output the category of illegal additives.
2. The method for detecting illegal food additives based on surface-enhanced Raman spectroscopy according to claim 1, characterized in that, Based on the preliminary screened spectral data, a local spectral sequence is constructed, three composite spectral feature indices are calculated, and overlapping interference regions are identified using judgment logic. The process includes the following steps: Step 41: Based on each target feature band set of the preliminary screened spectral data, obtain preliminary wavenumber points and corresponding preliminary Raman scattering intensity values, and construct a local spectral sequence based on the preliminary wavenumber points and corresponding preliminary Raman scattering intensity values; Step 42: Construct the peak shape asymmetry index, intensity wavenumber gradient covariance, and local dynamic signal-to-noise ratio based on the local spectral sequence; Step 43: If all three of the following conditions are met simultaneously, the current target feature band set is marked as an overlapping interference region; otherwise, all data points in the current target feature band set are removed. The three conditions are as follows: The peak shape asymmetry index is greater than a preset asymmetry threshold; The intensity wavenumber gradient covariance is greater than a preset upper limit of covariance; The local dynamic signal-to-noise ratio is greater than a preset signal-to-noise ratio threshold.
3. The method for detecting illegal food additives based on surface-enhanced Raman spectroscopy according to claim 2, characterized in that, Constructing a peak shape asymmetry index based on the local spectral sequence includes: Determine the initial maximum Raman scattering intensity and the corresponding first wavenumber point in the local spectral sequence; Obtain the first and second preliminary Raman scattering intensity values corresponding to the left and right boundaries of the current target feature band set; Based on the maximum value of the initial Raman scattering intensity, the first initial Raman scattering intensity value, and the second initial Raman scattering intensity value, a half-height intensity threshold is generated; Based on the left side of the first wavenumber point, search for the first wavenumber point less than or equal to the intensity threshold at half height along the wavenumber point decreasing direction and mark it as the left wavenumber point at half height; based on the right side of the first wavenumber point, search for the first wavenumber point less than or equal to the intensity threshold at half height along the wavenumber point increasing direction and mark it as the right wavenumber point at half height. The first difference is calculated based on the first wavenumber point and the wavenumber point on the left side of the half-height, and the second difference is calculated based on the first wavenumber point and the wavenumber point on the right side of the half-height. The peak asymmetry index is generated based on the ratio of the first difference and the second difference.
4. The method for detecting illegal food additives based on surface-enhanced Raman spectroscopy according to claim 2, characterized in that, Constructing the intensity wavenumber gradient covariance and local dynamic signal-to-noise ratio based on the local spectral sequence includes: An intensity difference and a wavenumber difference are generated based on adjacent preliminary wavenumber points and preliminary Raman scattering intensity values within the local spectral sequence; the intensity wavenumber gradient covariance is obtained based on the intensity difference and wavenumber difference; a sliding window of a preset width is constructed with the first wavenumber point as the center, and the intensity mean and intensity standard deviation are obtained based on the preliminary Raman scattering intensity values within the sliding window; the local dynamic signal-to-noise ratio is obtained based on the maximum value, mean, and standard deviation of the preliminary Raman scattering intensity.
5. The method for detecting illegal food additives based on surface-enhanced Raman spectroscopy according to claim 1, characterized in that, Based on the overlapping interference regions, a composite judgment logic is executed, and data points are removed according to the judgment results to obtain purified spectral data, including the following steps: Step 51, first layer of composite judgment logic: determine the global peak-to-valley ratio based on each of the overlapping interference regions. If the global peak-to-valley ratio is less than the first threshold, then all data points in the current overlapping interference region are removed; otherwise, execute the second layer of composite judgment logic. Step 52, second layer composite judgment logic: Based on the current overlapping interference region, perform adaptive wavelet decomposition, extract wavelet decomposition scales at least two scales, construct energy ratio according to the two wavelet decomposition scales, if the energy ratio is greater than the second threshold, then remove all data points in the current overlapping interference region; otherwise, proceed to step 53 to execute the third layer composite judgment logic. Step 53: Based on the pre-constructed database of standard Raman characteristic peaks of illegal additives, illegal additives located in the overlapping interference region are screened and recorded as a candidate substance set; based on the single candidate substance and any two candidate substances in the candidate substance set, a candidate combination substance set is obtained. Step 54: Based on the illegal additives included in the candidate composition material set, and based on the pre-constructed standard Raman characteristic peak database of illegal additives, determine the wavenumber, relative intensity, and peak standard deviation of the main characteristic peaks and construct a Gaussian function together. Calculate the Gaussian value of the Gaussian function at each wavenumber point in the overlapping interference region, and obtain a Gaussian vector based on the Gaussian value. Concatenate the Gaussian vectors of all candidate compositions in the candidate composition material set column-wise to construct a reference spectral matrix. Step 55: Based on the preliminary Raman scattering intensity values at each wavenumber point in the overlapping interference region, construct the measured spectral vector; solve the least squares problem based on the measured spectral vector and the reference spectral matrix to obtain the weight vector; and obtain the reconstructed spectral matrix based on the weight vector and the reference spectral matrix. Step 56: Combine a single candidate substance and any two candidate substances from the candidate substance set to construct single reconstruction error and double reconstruction error based on the reconstructed spectral matrix and the measured spectral vector, respectively. Step 57: If the dual reconstruction error of the current dual-substance combination is less than x times the single reconstruction error, and the main characteristic peak wavenumbers of the two illegal additives in the current dual-substance combination fall within the corresponding standard tolerance range, then retain all data points in the current overlapping interference region; where x is greater than 0. Step 58: If the single reconstruction error of the current single candidate substance is less than the upper limit of the single substance fitting error, and the wavenumber of the main feature peak of the current single candidate substance falls into the corresponding standard tolerance range, then only the wavenumber points of the current single candidate substance in the corresponding component support set are retained. Step 59: If the conditions in Steps 57-58 are not met, all data points in the current overlapping interference area are removed, and the remaining wavenumber points and the corresponding preliminary Raman scattering intensity values are merged to obtain purified spectral data.
6. The method for detecting illegal food additives based on surface-enhanced Raman spectroscopy according to claim 5, characterized in that, The process of constructing the component support set includes: Calculate the sum of all elements in the Gaussian vector and label it as the Gaussian sum. The Gaussian values of all wavenumber points are accumulated in ascending order to obtain a cumulative value. When the cumulative value is first greater than or equal to 0.025 times the sum of the Gaussian values, the current wavenumber point is marked as the second wavenumber point. The Gaussian values of all wavenumber points are accumulated in descending order to obtain a cumulative value. When the cumulative value is first greater than or equal to 0.025 times the sum of the Gaussian values, the current wavenumber point is marked as the third wavenumber point. Using the second wavenumber point as the left boundary and the third wavenumber point as the right boundary, a component support set is constructed based on the left and right boundaries.
7. The method for detecting illegal food additives based on surface-enhanced Raman spectroscopy according to claim 5, characterized in that, Based on the candidate peaks, valid Raman peaks are identified, and feature vectors are constructed, including the following steps: Step 61: Smooth the purified spectral data using a moving median filter to obtain the estimated background intensity for each wavenumber point; obtain the residual sequence based on the preliminary Raman scattering intensity values and estimated background intensity at the wavenumber points, and calculate the standard deviation of the residual sequence. Step 62: Identify the number of wave points and the preliminary Raman scattering intensity value of the candidate peak, and record them as the peak wave point and peak intensity, respectively. A candidate peak is considered a valid Raman peak if it meets the following three conditions; otherwise, it is considered an ineffective Raman peak. The three conditions are as follows: The estimated background intensity of the peak point is greater than 3 times the standard deviation of the residual sequence; The full width at half maximum (FWHM) of the candidate peak is within the target range; The peak wave number point lies within any consecutive wavenumber point interval; Step 63: Based on all the effective Raman peaks, arrange them in descending order of peak intensity, and select the first two effective Raman peaks as the main peaks; Step 64: Obtain the main peak spacing, normalized intensity ratio, average peak width, minimum local peak-to-valley ratio, and number of effective main peaks based on the main peaks, and then concatenate the main peak spacing, normalized intensity ratio, average peak width, minimum local peak-to-valley ratio, and number of effective main peaks in sequence to form a feature vector.
8. The method for detecting illegal food additives based on surface-enhanced Raman spectroscopy according to claim 7, characterized in that, The main peak spacing is the difference between the peak values of the first two effective Raman peaks; the normalized intensity ratio is the ratio of the peak intensities of the first two effective Raman peaks; the average peak width is the average of the full width at half maximum (FWHM) of the first two effective Raman peaks; and the minimum local peak-to-valley ratio is the minimum local peak-to-valley ratio of the first two effective Raman peaks.
9. The method for detecting illegal food additives based on surface-enhanced Raman spectroscopy according to claim 4, characterized in that, Obtain the first intensity and the second intensity corresponding to the two nearest local minima to the left and right of the peak wave point, calculate the average intensity of the first intensity and the second intensity, and obtain the local peak-to-valley ratio based on the peak intensity and the average intensity.
10. A food additive detection system based on surface-enhanced Raman spectroscopy, used to perform the food additive detection method based on surface-enhanced Raman spectroscopy as described in any one of claims 1-9, characterized in that, Includes the following modules: The data acquisition module is used to acquire raw Raman spectral data of food samples; The data analysis module is used to determine the target feature band set based on pre-constructed standard Raman characteristic peak data of illegal additives; The data processing module is used to mark and remove wavenumber points and their corresponding Raman scattering intensity values that do not belong to the target feature band set as irrelevant data based on each wavenumber point of the original Raman spectral data, and to mark the remaining wavenumber points and their corresponding Raman scattering intensity values as preliminary screening spectral data. The identification module is used to construct a local spectral sequence based on the preliminary screened spectral data, calculate three composite spectral feature indices, and identify overlapping interference regions by combining judgment logic. The elimination analysis module is used to perform composite judgment logic based on each of the overlapping interference regions, and to eliminate data points according to the judgment results to obtain purified spectral data. The detection module is used to perform candidate peak detection based on the purified spectral data, identify all wavenumber points that satisfy the local maximum condition as candidate peaks, identify valid Raman peaks based on the candidate peaks, construct feature vectors and standardize them as input data for a classification model for prediction, and output the category of illegal additives.