Pesticide residue detection method and system based on surface-enhanced raman spectroscopy

By constructing a multidimensional spectral library and a neural network model, combined with channel and spatial attention optimization, the sensitivity and accuracy issues of pesticide residue detection in complex backgrounds were solved, and efficient identification and quantitative analysis of low-concentration pesticides were achieved.

CN120522158BActive Publication Date: 2025-10-21CHINA JILIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511021397.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-24
Publication Date
2025-10-21
Estimated Expiration
2045-07-24

AI Technical Summary

Technical Problem

Existing technologies have difficulty in effectively separating and enhancing the SERS characteristic signals of low-concentration pesticides that are overwhelmed by complex backgrounds and noise, resulting in insufficient sensitivity and accuracy in the detection of trace pesticide residues. In addition, existing models have poor generalization and robustness in complex backgrounds.

Method used

A pesticide residue detection method based on surface-enhanced Raman spectroscopy is adopted. By constructing a multidimensional spectral library and a neural network model, utilizing channel and spatial attention optimization, a physically guided feature enhancement strategy, and combining a dual-task collaborative architecture, precise enhancement of spectral characteristic peaks and suppression of background interference are achieved.

Benefits of technology

It significantly improves the signal-to-noise ratio, enhances the sensitivity and accuracy of pesticide residue detection, enhances the robustness of the model to complex background interference, and improves the detection rate and discrimination accuracy of low-concentration samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120522158B_ABST
    Figure CN120522158B_ABST
Patent Text Reader

Abstract

The application discloses a pesticide residue detection method and system based on surface-enhanced Raman spectroscopy, and relates to the technical field of spectral analysis and machine learning, and specifically comprises the following steps: preparing a to-be-detected solution based on a to-be-detected agricultural product sample; collecting a Raman spectrum of the to-be-detected solution to obtain a to-be-detected spectrum; inputting the to-be-detected spectrum into an identification model to synchronously output a pesticide type identification result and a residual level semi-quantitative analysis result; wherein, the construction steps of a training data set are as follows: preparing a test data sample; collecting a Raman spectrum of the test data sample to construct a multi-dimensional spectrum library; inputting the Raman spectrum into a spectrum decomposition model to output a real pesticide spectrum; calculating the residual error of the measured Raman spectrum of the mixed sample and the real pesticide spectrum, and constructing a simulated residual error; superimposing the simulated residual error on the real pesticide spectrum to construct an enhanced mixed spectrum; and combining the multi-dimensional spectrum library to construct the training data set. The application can realize high-precision detection of trace pesticides under a complex background.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of spectral analysis and machine learning, and more particularly to a pesticide residue detection method and system based on surface-enhanced Raman spectroscopy. Background Art

[0002] Surface-enhanced Raman spectroscopy (SERS) has become a crucial tool in pesticide residue detection, thanks to its exceptional sensitivity and ability to provide unique molecular "fingerprint" information. It can identify trace amounts of target compounds. Furthermore, machine learning models, such as convolutional neural networks (CNNs), demonstrate powerful automated feature extraction and pattern recognition capabilities in spectral analysis, providing an effective means for intelligent analysis of complex spectral data.

[0003] However, in actual SERS detection scenarios, the characteristic spectral signals of pesticide residues are often overwhelmed by the strong background of the extraction solvent, the Raman signal of the substrate itself, and environmental noise, making it difficult to clearly identify the characteristic peaks, significantly increasing the actual detection limit (LOD) of the method. Traditional analytical methods usually directly process mixed spectra containing multiple interferences, making it difficult to effectively separate weak pesticide characteristic information, especially at low residue concentrations. The detection accuracy is seriously insufficient. In addition, although the CNN model has potential, the existing technology has two key bottlenecks: first, it is very difficult to obtain a large amount of high-quality SERS training data that covers complex background changes, different concentration gradients, and is accurately labeled; second, the existing model has poor generalization and robustness when faced with highly complex and variable background interferences in actual samples, making it difficult to stably and accurately identify the characteristic spectra of low-concentration pesticides.

[0004] Therefore, how to effectively separate and enhance the SERS characteristic signals of low-concentration pesticides that are overwhelmed by complex background and noise, and improve the sensitivity, accuracy and reliability of trace pesticide residue detection, is an urgent problem that technicians in this field need to solve. Summary of the Invention

[0005] In view of this, the present invention provides a method and system for detecting pesticide residues based on surface-enhanced Raman spectroscopy, which overcomes the above-mentioned defects.

[0006] In order to achieve the above object, the present invention adopts the following technical solutions:

[0007] A method for detecting pesticide residues based on surface-enhanced Raman spectroscopy, comprising the following steps:

[0008] The agricultural product sample to be tested is extracted with an extraction reagent and prepared into a solution to be tested;

[0009] Collecting the Raman spectrum of the solution to be tested to obtain a spectrum to be tested;

[0010] The spectrum to be tested is preprocessed and input into the pre-trained recognition model, which simultaneously outputs the pesticide type identification result and the semi-quantitative analysis result of the residue level;

[0011] Among them, the steps for constructing the training data set of the recognition model are:

[0012] Prepare test data samples, including pure pesticide samples, blank samples and mixed samples;

[0013] Collect Raman spectra of test data samples, label the Raman spectra, and build a multidimensional spectral library;

[0014] Preprocess the Raman spectra in the multidimensional spectral library, input the preprocessed Raman spectra into the spectral decomposition model, and output the real pesticide spectra;

[0015] The residual spectrum between the measured Raman spectrum of the mixed sample and the real pesticide spectrum is calculated, and the wavenumber points of the residual spectrum are randomly reorganized to generate multiple sets of simulated residuals. The simulated residuals are superimposed on the real pesticide spectrum to construct an enhanced mixed spectrum. A training dataset is constructed based on the enhanced mixed spectrum and a multidimensional spectral library.

[0016] Optionally, the steps for obtaining the test solution are:

[0017] Extracting the agricultural product sample to be tested using an extraction reagent to obtain an extraction solution;

[0018] The leaching extract is mixed with the substrate to produce the test solution.

[0019] Optionally, the preprocessing includes smoothing, baseline correction, standard normal variable transformation and area normalization.

[0020] Optionally, the spectral decomposition model is constructed based on physical linear decomposition and a neural network, wherein the neural network includes:

[0021] The input layer is used to receive the mixed spectrum and the extraction reagent, and extract and analyze the pesticide type and concentration based on the mixed spectrum, and extract the pH value of the extraction reagent based on the extraction reagent;

[0022] The hidden layer is used to fuse the spectral features of the mixed spectrum, the type of pesticide, the pesticide concentration, and the pH value of the extraction reagent through a nonlinear activation function to learn the relationship between the mixed spectrum and the pesticide concentration;

[0023] The output layer is used to output the real pesticide spectrum and the relative concentration ratio of the pesticide in the mixed sample.

[0024] Optionally, the steps for acquiring the enhanced mixed spectrum are:

[0025] The mixed spectra are divided into multiple groups according to the consistency of pesticide type, pesticide concentration and pH value of the extraction reagent, so that the signal intensity, background distribution and pesticide molecular state of the mixed spectra in the same group meet the preset similarity conditions;

[0026] Decompose the mixed spectra of the same group, extract the true pesticide spectrum of each mixed spectrum, and calculate the average true pesticide spectrum;

[0027] Calculate the residual spectrum between each mixed spectrum in the same group and the average real pesticide spectrum, and randomly permute the wavenumber dimension data of the residual spectrum to generate simulated residuals;

[0028] The simulated residuals were superimposed onto the averaged true pesticide spectrum to generate an enhanced mixed spectrum.

[0029] Optionally, the calculation expression of the enhanced mixed spectrum is:

[0030] ;

[0031] Where, is the Raman shift residual value; is the concentration correlation coefficient; This is the real pesticide spectrum; is the background spectrum.

[0032] Optionally, a channel attention submodule, a spatial attention submodule and a cross-fusion submodule are introduced into the recognition model; the channel attention submodule is used to enhance the weight of the wavelength channel corresponding to the pesticide characteristic peak; the spatial attention submodule is used to focus on the local area of ​​the pesticide characteristic peak and suppress background interference; the cross-fusion module is used to use a dual-attention cross-gating mechanism to fuse the output features of the channel attention submodule and the output features of the spatial attention submodule.

[0033] A pesticide residue detection system based on surface-enhanced Raman spectroscopy, comprising:

[0034] The test solution preparation module is used to extract the agricultural product samples to be tested using an extraction reagent and prepare the test solution;

[0035] A spectrum acquisition module is used to acquire the Raman spectrum of the solution to be tested to obtain the spectrum to be tested;

[0036] The recognition module is used to pre-process the spectrum to be tested, input the pre-processed spectrum to the pre-trained recognition model, and simultaneously output the pesticide type identification result and the semi-quantitative analysis result of the residue level;

[0037] Among them, the recognition module includes a model training submodule, which is composed of a sample preparation unit, a spectral library construction unit, a spectral decomposition unit, a training set construction unit and a model construction and training unit;

[0038] A sample preparation unit is used to prepare test data samples, including pure pesticide samples, blank samples and mixed samples;

[0039] A spectral library construction unit is used to collect Raman spectra of test data samples, label the Raman spectra, and construct a multidimensional spectral library;

[0040] The spectrum decomposition unit is used to preprocess the Raman spectra in the multidimensional spectrum library, input the preprocessed Raman spectra into the spectrum decomposition model, and output the real pesticide spectrum;

[0041] The training set construction unit is used to calculate the residual spectrum between the measured Raman spectrum of the mixed sample and the real pesticide spectrum, randomly reorganize the wavenumber points of the residual spectrum to generate multiple sets of simulated residuals; superimpose the simulated residuals on the real pesticide spectrum to construct an enhanced mixed spectrum; and construct a training data set based on the enhanced mixed spectrum and the multidimensional spectral library;

[0042] The model building and training unit is used to build an initial recognition model that integrates channel attention and spatial attention, and iteratively train the initial recognition model through the training data set to obtain the final recognition model.

[0043] From the above technical solutions, it can be seen that the present invention provides a method and system for detecting pesticide residues based on surface-enhanced Raman spectroscopy, which has the following beneficial effects compared with the existing technology:

[0044] 1. Through the two-way collaborative optimization of channel and spatial attention, the spectral characteristic peaks are precisely enhanced; at the same time, the physical-guided feature enhancement strategy gives the characteristic peak area 2.5 times the weight in the channel dimension and focuses on the characteristic peak in the spatial dimension. The gating mechanism enables the channel weight and spatial mask to form a feedback loop, breaking through the limitations of traditional serial and parallel attention structures, effectively solving the difficulties in resolving overlapping peaks and matrix interference, and improving the measured performance.

[0045] 2. By fusing mixed spectra, pure pesticide features, and background features, a physically guided multi-source feature fusion framework is constructed. By adaptively optimizing the fusion weights of each feature through learnable parameters, background subtraction and target signal enhancement are achieved in the feature space, improving the robustness of the recognition model to complex background interference and enhancing the recognizability of key features.

[0046] 3. In the dual-task collaborative architecture, the qualitative branch leverages concentration characteristics to enhance weak signal recognition and improve the detection rate of low-concentration samples. The semi-quantitative branch dynamically adjusts the concentration judgment threshold based on species information, forming a "species-concentration" bidirectional guidance loop, improving the generalization ability and discrimination accuracy of the recognition model in complex scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0048] Figure 1 A schematic flow chart of the method provided by the present invention;

[0049] Figure 2 A flow chart of the training set construction method provided by the present invention;

[0050] Figure 3 A schematic diagram of the structure of the neural network in the spectral decomposition model provided by the present invention;

[0051] Figure 4 This is a schematic diagram of the data enhancement effect provided by the present invention;

[0052] Figure 5 A schematic diagram of the recognition model architecture provided by the present invention;

[0053] Figure 6 Schematic diagram of the dual attention cross-gating fusion principle provided by the present invention. DETAILED DESCRIPTION

[0054] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0055] The present invention discloses a method for detecting pesticide residues based on surface enhanced Raman spectroscopy. Figure 1 and Figure 2 As shown, the specific steps are:

[0056] Step 1: extracting the agricultural product sample to be tested with an extraction reagent and preparing a test solution;

[0057] Step 2: collecting the Raman spectrum of the solution to be tested to obtain a spectrum to be tested;

[0058] Step 3: Preprocess the spectrum to be tested and input the preprocessed spectrum to the pre-trained recognition model to simultaneously output the pesticide type identification result and the residue level semi-quantitative analysis result;

[0059] Among them, the steps for constructing the training data set of the recognition model are:

[0060] Step 31: Prepare test data samples, including pure pesticide samples, blank samples, and mixed samples;

[0061] Step 32: Collect Raman spectra of test data samples, label the Raman spectra, and construct a multidimensional spectrum library;

[0062] Step 33: pre-process the Raman spectra in the multidimensional spectral library, input the pre-processed Raman spectra into the spectral decomposition model, and output the real pesticide spectra;

[0063] Step 34: Calculate the residual spectrum between the measured Raman spectrum of the mixed sample and the real pesticide spectrum, randomly reorganize the wavenumber points of the residual spectrum to generate multiple sets of simulated residuals; superimpose the simulated residuals on the real pesticide spectrum to construct an enhanced mixed spectrum; and construct a training data set based on the enhanced mixed spectrum and the multidimensional spectral library.

[0064] In one embodiment, the steps of obtaining the test solution are:

[0065] Extracting the agricultural product sample to be tested using an extraction reagent to obtain an extraction solution;

[0066] The leaching extract is mixed with the substrate to produce the test solution.

[0067] In one embodiment, preparing a test data sample includes:

[0068] A variety of common pesticides used on fruits and vegetables were collected as pure pesticide samples; blank samples were prepared based on the extraction reagent; and mixed samples were prepared using the extraction reagent as the solvent and the pesticide as the solute.

[0069] In one embodiment, the steps for constructing a multidimensional spectral library are as follows: performing conventional Raman spectral acquisition on pure pesticide samples to obtain pure pesticide spectra; performing surface-enhanced Raman spectral acquisition on blank samples and mixed samples to obtain background spectra and mixed spectra; annotating the pure pesticide spectra, mixed spectra, and background spectra with type labels and concentration numerical labels, and dividing them into training sets, validation sets, and test sets in proportion to form a multidimensional spectral library.

[0070] Furthermore, the multidimensional spectral library includes:

[0071] The pure pesticide spectral library is constructed based on pure pesticide spectra and is used to study the inherent characteristics of pesticides, the effect of concentration on spectral signals, and the enhancement characteristics of dual substrates. The pure pesticide spectra are obtained based on Raman spectra of various common pesticides, which obtain the original characteristic fingerprints without background interference, with a wavelength range of 200-3200 cm -1 , laser power 50-200 mW;

[0072] The background spectrum library is used to simulate the interference of reagent peaks on pesticide characteristic peaks in actual detection. In this embodiment, the background spectrum collection steps are as follows: 5 sets of repeated measurements are performed on a blank sample (an extraction reagent with the optimal pH corresponding to the target pesticide (i.e., the target pH extraction reagent) mixed with a nano-gold / silver substrate) on a double substrate, and 20 sets of data are collected; the target pH extraction reagent and background spectra are recorded for subtracting background interference during spectral decomposition;

[0073] The mixed spectrum library is calibrated to obtain the initial values ​​of the real pesticide spectrum during spectral decomposition. In this embodiment, the steps for collecting the calibrated mixed spectrum are as follows: preparing a high-concentration pesticide-target pH extraction reagent (acetonitrile + pH buffer compatible with the target pesticide) solution (in this embodiment, a 1000 ppm pesticide-acetonitrile solution is used), mixing it with the nano-gold / silver substrate at a fixed volume ratio, and collecting SERS spectra under the dual substrate;

[0074] The mixed spectrum library is used to simulate complex interference scenarios and train the recognition model's anti-interference ability to extract pesticide features from mixed spectra. In this embodiment, the mixed spectrum acquisition steps are as follows: preparing a mixed solution of the target pH extraction reagent and different low-concentration pesticides (0.1-1000 ppm pesticide-target pH extraction reagent is used in this embodiment), mixing it with the nanogold / silver substrate at a fixed volume ratio, performing 10 sets of repeated measurements on the double substrate, collecting SERS spectra, and simultaneously recording the target pH extraction reagent-background spectrum, covering the semi-quantitative range (not detected, not exceeding the standard, exceeding the standard, and seriously exceeding the standard).

[0075] In one embodiment, the preprocessing includes smoothing, baseline correction, standard normal variate transformation, and area normalization.

[0076] Furthermore, Savitzky-Golay filtering was used to smooth spectral noise and retain characteristic peak shapes; the fluorescence background was fitted by least squares baseline correction to subtract baseline drift interference; the standard normal variate transformation (SNV) was used to eliminate optical pathlength and scattering differences; and area normalization was performed to unify the signal intensity scale of different samples.

[0077] In one embodiment, the spectral decomposition model is constructed based on a combination of physical linear decomposition and a neural network, wherein the physical linear decomposition expression is:

[0078] ;

[0079] Where, is the concentration correlation coefficient ( , represents the proportion of pesticide signal in the mixed spectrum); This is the real pesticide spectrum; is the background spectrum (target pesticide pH extraction reagent + SERS substrate, recording the Raman signals of buffer salt and acetonitrile); is random noise.

[0080] High concentration subtraction: using 1000 ppm high concentration spectrum Background subtracted spectrum Obtaining real pesticide spectra Initial value of:

[0081] ;

[0082] Neural network optimization: input mixed spectrum, pH value (normalized) and background spectrum , output optimized and The loss function is MSE (spectral fitting) + L1 regularization (to prevent overfitting) + pH penalty. The pH closed-loop control specifically involves detecting the pH value of the target pH extraction reagent, matching it to the training pH range, determining the difference between the current pH value and the training pH range, and constructing the pH correlation of the difference.

[0083] In one embodiment, the neural network comprises:

[0084] The input layer is used to receive the mixed spectrum and the extraction reagent, and extract and analyze the pesticide type and concentration based on the mixed spectrum, and extract the pH value of the extraction reagent based on the extraction reagent;

[0085] The hidden layer is used to fuse the spectral features of the mixed spectrum, the type of pesticide, the pesticide concentration, and the pH value of the extraction reagent through a nonlinear activation function to learn the relationship between the mixed spectrum and the pesticide concentration;

[0086] The output layer is used to output the real pesticide spectrum and the relative concentration ratio of the pesticide in the mixed sample.

[0087] Furthermore, the neural network adopts a fully connected neural network, such as Figure 3 Shown, including:

[0088] The input layer receives the mixed spectrum and extraction reagent and analyzes key information: first, the pesticide type is input in the form of thermal encoding to provide a category prior for subsequent decomposition; the pesticide concentration is input as a normalized value to clarify its contribution weight in the mixed spectrum; the pH value of the extraction reagent is used as the core parameter for molecular state and background correction; the mixed spectrum is input as a vector containing many wavenumber points as the original basis for spectral decomposition;

[0089] The hidden layer uses neurons to perform nonlinear transformations on the input mixed spectrum, pesticide type, pesticide concentration, and pH value, extracting spectral features such as specific wavenumber characteristic peaks. It also deeply integrates different types of information to learn the complex relationships between pesticide type, pesticide concentration, pH value, and the mixed spectrum. It also introduces nonlinearity using activation functions such as ReLU and Sigmoid to accurately capture complex nonlinear relationships such as pesticide concentration and the spectral intensity of the mixed spectrum.

[0090] The output layer outputs the final results of the mixed spectrum decomposition. First, it outputs the real pesticide spectrum after removing the background and interference factors, intuitively presenting the real Raman spectrum characteristics of specific pesticides at the corresponding concentration, helping to identify the type of pesticide and determine the concentration; second, it outputs a numerical value reflecting the relative concentration ratio of the pesticide in the mixed sample. Combined with the real pesticide spectrum, it can be further converted into the actual concentration of the pesticide.

[0091] In one embodiment, the steps of acquiring the enhanced mixed spectrum are:

[0092] Divide the mixed spectra into multiple groups based on the consistency of pesticide type, pesticide concentration and pH value of the extraction reagent (pesticides of the same type, concentration and pH value are grouped together), so that the signal intensity, background distribution and pesticide molecular state of the mixed spectra in the same group meet the preset similarity conditions;

[0093] Decompose the mixed spectra of the same group, extract the true pesticide spectrum of each mixed spectrum, and calculate the average true pesticide spectrum;

[0094] Calculate the residual spectrum between each mixed spectrum in the same group and the average real pesticide spectrum, and randomly permute the wavenumber dimension data of the residual spectrum to generate simulated residuals;

[0095] The simulated residuals were superimposed on the average true pesticide spectrum to generate an enhanced mixed spectrum; the data volume was expanded to 10 times the original size.

[0096] Furthermore, based on the optimal pH extraction reagent corresponding to the target pesticide, the residual between the measured spectrum and the predicted spectrum is calculated:

[0097] ;

[0098] The expression of enhanced mixed spectrum is:

[0099] ;

[0100] Where, Raman shift residual value. Generate ≥5000 enhanced spectra for a single low-concentration sample.

[0101] Furthermore, the enhanced mixed spectrum is generated by using multidimensional residual perturbation, and the generated enhanced mixed spectrum is as follows: Figure 4 As shown, specifically:

[0102] Multidimensional residual perturbation: Within the same group, the residual values ​​at different Raman shifts are randomly replaced to ensure that the background signal of the enhanced mixed spectrum (such as buffer salt peak and acetonitrile peak) is consistent with the background spectrum of the target pH extraction reagent;

[0103] Frequency domain perturbation: Randomly replace the residual values ​​at different Raman shifts to generate ;

[0104] Concentration disturbance: Press Zoom ,in is the concentration sensitivity factor of the p-pH of the pesticide type, simulating the effect of pH on the adsorption efficiency of pesticides in actual detection and simulating concentration fluctuations;

[0105] PH disturbance (simulated field error): For each target pesticide, generate a virtual PH value within the range of PH ± 0.5 (covering the PH deviation allowed by the preset rules) and calculate The linear interpolation perturbation is used to enhance the robustness of the spectral decomposition model to the pH fluctuation of the extract.

[0106] In one embodiment, a channel attention submodule, a spatial attention submodule and a cross-fusion submodule are introduced into the recognition model; the channel attention submodule is used to enhance the weight of the wavelength channel corresponding to the pesticide characteristic peak; the spatial attention submodule is used to focus on the local area of ​​the pesticide characteristic peak and suppress background interference; the cross-fusion module is used to use a dual-attention cross-gating mechanism to fuse the output features of the channel attention submodule and the output features of the spatial attention submodule.

[0107] Further, such as Figure 5As shown in the figure, after receiving the preprocessed enhanced mixed spectrum, the recognition model extracts local features through convolutional layers and ReLU activation functions. Channel attention is used to enhance the wavelength channel weights corresponding to the pesticide characteristic peaks, while spatial attention is used to focus on the area surrounding the characteristic peaks and suppress background interference. Max pooling and average pooling are then used to compress the data dimension, and after global pooling, the model is divided into two output branches. The classification branch outputs the probability distribution of pesticide types through a fully connected layer combined with a Softmax function. The semi-quantitative branch outputs the probability distribution of pesticide residue levels through a fully connected layer combined with a Softmax function: not detected, within the standard, exceeded the standard, and severely exceeded the standard. During training, a joint loss function of focal loss and dynamically weighted cross entropy loss is used, combined with the Adam optimizer and Dropout regularization, to achieve simultaneous detection of pesticide type discrimination and semi-quantitative analysis of residue levels.

[0108] The qualitative branch uses concentration features as a guide to enhance weak signal detection, while the semi-quantitative branch uses species features as a reference to adaptively adjust the concentration threshold. After layer-normalization, these interactive features are fed into two task heads: the qualitative head outputs pesticide species probabilities (including a "no pesticide" category), while the semi-quantitative head outputs residue level probabilities (not detected / not exceeded / exceeded / severely exceeded).

[0109] Furthermore, the recognition model data structure consists of:

[0110] The receiving module receives the mixed spectrum after preprocessing (denoising, baseline correction, SNV normalization, and area normalization) to prepare for feature extraction, and also receives the corresponding pure pesticide spectrum and the background spectrum of the extraction reagent;

[0111] The local features of the input spectrum (covering the width of typical pesticide characteristic peaks) are extracted through a 1D convolution layer + ReLU activation function. The data dimension is reduced by downsampling with a step size of 2 to generate 64 basic spectral feature representations. Among them, the convolution kernel parameters in this embodiment are a kernel size of 15, a step size of 2, a padding of 7 (to maintain dimensional alignment), and the number of filters is 64.

[0112] The extracted features are input into the dual attention cross gating module for feature fusion. The dual attention cross gating module is as follows Figure 5 As shown in the figure, it includes a channel attention submodule and a spatial attention submodule. The channel attention submodule includes global average pooling, two layers of 1×1 convolution and Sigmoid function, which is used to mark the characteristic peak position based on the pure pesticide spectral library, giving a 2.5-fold weight to the characteristic peak area and a 0.5-fold weight to the interference area; the spatial attention submodule includes a 3×1 convolution (channel compression is 1) and a Sigmoid function, which is used to focus on the characteristic peak ±20 cm -1 Key areas, suppressing background broad peak interference.

[0113] Assume the input feature tensor is: ,in, is the batch size, is the number of channels, is the length;

[0114] Channel attention can be expressed as:

[0115] ;

[0116] Where, is the global channel average feature; is the global average pooling operation; is the Sigmoid activation function; is the weight of the extended convolution layer; is the ReLU activation function; is the compressed convolution layer weight ( is the compression ratio).

[0117] Spatial attention can be expressed as:

[0118] ;

[0119] Where, It is a 1-dimensional convolution operation (the number of channels is compressed to 1); is the Sigmoid activation function; The convolution kernel size is 3.

[0120] Dual attention cross-gating mechanism Figure 6 Shown, including:

[0121] The adjustment of channel attention to spatial attention can be expressed as: ;

[0122] The adjustment of spatial attention to channel attention can be expressed as: ;

[0123] Where, ; is the mean of spatial attention; is the length;

[0124] Feature enhancement output: ;

[0125] Where, is the final spatial attention map; is element-wise multiplication; is the sigmoid transform of the channel weight; is the final channel attention weight; Residual connection design to preserve original features.

[0126] First-level pooling layer: After the first feature extraction stage, a maximum pooling layer is set, using a 1D maximum pooling operation with a kernel size of 3 and a stride of 2. This pooling layer uses local maximum sampling to effectively reduce computational complexity while retaining key information of feature peaks.

[0127] Second-level pooling layer: A global average pooling layer is set after the multi-feature fusion module. This layer adopts a parameter-free global average pooling strategy to compress all spatial position information of each feature channel into a single-value representation.

[0128] The multi-feature fusion module receives three inputs: the mixed spectral features extracted by convolution, the aligned pure pesticide features, and the background features. It implements physically guided fusion calculations through learnable parameters (g, h, w, o):

[0129] Final fusion feature = g × mixed spectrum feature + h × pure pesticide feature + w × (mixed spectrum feature - o × background feature)

[0130] Among them, g is used to adjust the weight of mixed spectral features, h is used to enhance the characteristic signal of pesticides, and w and o work together to complete background subtraction.

[0131] Cross-Attention Interaction Module:

[0132] Given a qualitative branch eigenvector and semiquantitative branch eigenvectors ,in, is the batch size; is the feature dimension; first perform linear transformation to generate the query vector ( ), key vector ( ), value vector ( );

[0133] Qualitative branching transformation:

[0134] ;

[0135] Where, is the query vector of the qualitative branch; is the bond vector of the qualitative branch; is the value vector of the qualitative branch; 、 、 Both are learnable weight matrices of qualitative branches.

[0136] Semi-quantitative branching transformation:

[0137] ;

[0138] Where, is the query vector for semi-quantitative branching; is the bond vector of semiquantitative branching; is the value vector of the semi-quantitative branch; 、 、 Both are learnable weight matrices of semi-quantitative branches.

[0139] The attention mechanism from the qualitative branch to the semi-quantitative branch is (category information guides concentration prediction):

[0140] ;

[0141] The attention mechanism from the semi-quantitative branch to the qualitative branch is (concentration feature enhances signal recognition):

[0142] ;

[0143] Where, is the row normalized exponential function, is the scaling factor; T is the transpose.

[0144] Qualitative branch update:

[0145] ;

[0146] Semi-quantitative branch update:

[0147] ;

[0148] Where, is the updated qualitative branch feature vector; It is a layer-one operation; is the updated semi-quantitative branch feature vector;

[0149] Layer normalization calculation:

[0150] ;

[0151] Where, For input data, is the characteristic mean, is the characteristic variance, e is the minimum value to prevent division by zero, and are the learnable scaling and offset parameters, is element-wise multiplication.

[0152] Output Module:

[0153] The pesticide qualitative branch output module includes: Dropout (0.2), fully connected layer (128→N+1), Softmax activation, and outputs an N+1-dimensional probability vector (N pesticides + "no pesticide" category).

[0154] The pesticide semi-quantitative branch output module includes: Dropout (0.1), fully connected layer (128→4), Softmax activation, and outputs a 4-dimensional probability vector (not detected / not exceeded / exceeded / severely exceeded)

[0155] Loss function:

[0156] The qualitative task loss adopts the improved focal loss (Focal Loss), which is expressed as:

[0157] ;

[0158] Where, is the sample size; is the number of category labels; is the category weight coefficient, ={1.0, k=0 (no pesticide); 1.2 (low-risk pesticide); 1.5 (medium-risk pesticide); 2.0 (high-risk pesticide)}; For the samples belong to the category The predicted probability of It is a focusing parameter, with a default value of 2.0, which is used to reduce the loss contribution of easy-to-classify samples; For the The true label of each sample (range 0 to N, 0 represents "no pesticide"); is the indicator function, when 1 if yes, 0 otherwise.

[0159] The semi-quantitative task loss uses dynamic weighted cross-entropy loss (Weighted Cross-Entropy Loss), which is expressed as:

[0160] ;

[0161] Where, Concentration level The weight coefficient of =[1.0, =0 (not detected); 1.2, =1 (not exceeding the standard); 3.0, =2 (exceeds the standard); 4.0, =3 (severely exceeded)]; No. The actual concentration level of each sample; For the Samples belong to the concentration level The predicted probability of .

[0162] Total loss function:

[0163] ;

[0164] Where, and are loss weight coefficients, , ; Used to balance the importance of two tasks.

[0165] On the other hand, this embodiment also discloses a pesticide residue detection system based on surface-enhanced Raman spectroscopy, comprising:

[0166] The test solution preparation module is used to extract the agricultural product samples to be tested using an extraction reagent and prepare the test solution;

[0167] A spectrum acquisition module is used to acquire the Raman spectrum of the solution to be tested to obtain the spectrum to be tested;

[0168] The recognition module is used to pre-process the spectrum to be tested, input the pre-processed spectrum to the pre-trained recognition model, and simultaneously output the pesticide type identification result and the semi-quantitative analysis result of the residue level;

[0169] Among them, the recognition module includes a model training submodule, which is composed of a sample preparation unit, a spectral library construction unit, a spectral decomposition unit, a training set construction unit and a model construction and training unit;

[0170] A sample preparation unit is used to prepare test data samples, including pure pesticide samples, blank samples and mixed samples;

[0171] A spectral library construction unit is used to collect Raman spectra of test data samples, label the Raman spectra, and construct a multidimensional spectral library;

[0172] The spectrum decomposition unit is used to preprocess the Raman spectra in the multidimensional spectrum library, input the preprocessed Raman spectra into the spectrum decomposition model, and output the real pesticide spectrum;

[0173] The training set construction unit is used to calculate the residual spectrum between the measured Raman spectrum of the mixed sample and the real pesticide spectrum, randomly reorganize the wavenumber points of the residual spectrum to generate multiple sets of simulated residuals; superimpose the simulated residuals on the real pesticide spectrum to construct an enhanced mixed spectrum; and construct a training data set based on the enhanced mixed spectrum and the multidimensional spectral library;

[0174] The model building and training unit is used to build an initial recognition model that integrates channel attention and spatial attention, and iteratively train the initial recognition model through the training data set to obtain the final recognition model.

[0175] The spectral library construction unit includes a spectral acquisition device, specifically a portable Raman spectrometer equipped with 785nm excitation, a nano-gold / silver SERS enhanced substrate, and a pre-treatment device (ultrasonic extraction, centrifugal separation) for the target pH extraction reagent.

[0176] In one embodiment, a result display module is also included for real-time visualization of pesticide types, residue levels, and safety threshold comparisons, automatic generation of test reports with spectral traceability, and support for local / cloud storage; wherein, the residue levels are based on the standard limits and method detection limits in the preset standard library.

[0177] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.

[0178] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for detecting pesticide residues based on surface-enhanced Raman spectroscopy, characterized in that: The specific steps are: The agricultural product sample to be tested is extracted with an extraction reagent and prepared into a solution to be tested; Collecting the Raman spectrum of the solution to be tested to obtain a spectrum to be tested; The spectrum to be tested is preprocessed and input into the pre-trained recognition model, which simultaneously outputs the pesticide type identification result and the semi-quantitative analysis result of the residue level; Among them, the steps for constructing the training data set of the recognition model are: Prepare test data samples, including pure pesticide samples, blank samples and mixed samples; Collect Raman spectra of test data samples, label the Raman spectra, and build a multidimensional spectral library; The steps for constructing a multidimensional spectral library are as follows: conventional Raman spectra of pure pesticide samples are collected to obtain pure pesticide spectra; surface-enhanced Raman spectra of blank samples and mixed samples are collected to obtain background spectra and mixed spectra; pure pesticide spectra, mixed spectra, and background spectra are annotated with type labels and concentration numerical labels, and then divided into training sets, validation sets, and test sets in proportion to form a multidimensional spectral library; Preprocess the Raman spectra in the multidimensional spectral library, input the preprocessed Raman spectra into the spectral decomposition model, and output the real pesticide spectra; Calculate the residual spectrum between the measured Raman spectrum of the mixed sample and the real pesticide spectrum, randomly reorganize the wavenumber points of the residual spectrum to generate multiple sets of simulated residuals; superimpose the simulated residuals on the real pesticide spectrum to construct an enhanced mixed spectrum; and construct a training dataset based on the enhanced mixed spectrum and the multidimensional spectral library. The calculation expression of the enhanced mixed spectrum is: Where, is the Raman shift residual value; a(c, PH) is the concentration correlation coefficient; I T(PH) is the real pesticide spectrum; I B(PH) is the background spectrum.

2. The method for detecting pesticide residues based on surface enhanced Raman spectroscopy according to claim 1, wherein: The steps for obtaining the test solution are: Extracting the agricultural product sample to be tested using an extraction reagent to obtain an extraction solution; The leaching extract is mixed with the substrate to produce the test solution.

3. The method for detecting pesticide residues based on surface enhanced Raman spectroscopy according to claim 1, wherein: Preprocessing included smoothing, baseline correction, standard normal variate transformation and area normalization.

4. The method for detecting pesticide residues based on surface enhanced Raman spectroscopy according to claim 1, wherein: The spectral decomposition model is based on physical linear decomposition and neural network construction, where the neural network includes: The input layer is used to receive the mixed spectrum and the extraction reagent, and extract and analyze the pesticide type and concentration based on the mixed spectrum, and extract the pH value of the extraction reagent based on the extraction reagent; The hidden layer is used to fuse the spectral features of the mixed spectrum, the type of pesticide, the pesticide concentration, and the pH value of the extraction reagent through a nonlinear activation function to learn the relationship between the mixed spectrum and the pesticide concentration; The output layer is used to output the real pesticide spectrum and the relative concentration ratio of the pesticide in the mixed sample.

5. The method for detecting pesticide residues based on surface enhanced Raman spectroscopy according to claim 4, characterized in that: The steps for obtaining the enhanced mixed spectrum are: The mixed spectra are divided into multiple groups according to the consistency of pesticide type, pesticide concentration and pH value of the extraction reagent, so that the signal intensity, background distribution and pesticide molecular state of the mixed spectra in the same group meet the preset similarity conditions; Decompose the mixed spectra of the same group, extract the true pesticide spectrum of each mixed spectrum, and calculate the average true pesticide spectrum; Calculate the residual spectrum between each mixed spectrum in the same group and the average real pesticide spectrum, and randomly permute the wavenumber dimension data of the residual spectrum to generate simulated residuals; The simulated residuals were superimposed onto the averaged true pesticide spectrum to generate an enhanced mixed spectrum.

6. The method for detecting pesticide residues based on surface enhanced Raman spectroscopy according to claim 1, wherein: The recognition model introduces a channel attention submodule, a spatial attention submodule, and a cross-fusion submodule; the channel attention submodule is used to enhance the weight of the wavelength channel corresponding to the pesticide characteristic peak; the spatial attention submodule is used to focus on the local area of ​​the pesticide characteristic peak and suppress background interference; The cross fusion module is used to fuse the output features of the channel attention submodule and the output features of the spatial attention submodule using a dual attention cross gating mechanism.

7. A pesticide residue detection system based on surface enhanced Raman spectroscopy, characterized in that: include: The test solution preparation module is used to extract the agricultural product samples to be tested using an extraction reagent and prepare the test solution; A spectrum acquisition module is used to acquire the Raman spectrum of the solution to be tested to obtain the spectrum to be tested; The recognition module is used to pre-process the spectrum to be tested, input the pre-processed spectrum to the pre-trained recognition model, and simultaneously output the pesticide type identification result and the semi-quantitative analysis result of the residue level; Among them, the recognition module includes a model training submodule, which is composed of a sample preparation unit, a spectral library construction unit, a spectral decomposition unit, a training set construction unit and a model construction and training unit; A sample preparation unit is used to prepare test data samples, including pure pesticide samples, blank samples and mixed samples; A spectral library construction unit is used to collect Raman spectra of test data samples, label the Raman spectra, and construct a multidimensional spectral library; The steps for constructing a multidimensional spectral library are as follows: conventional Raman spectra of pure pesticide samples are collected to obtain pure pesticide spectra; surface-enhanced Raman spectra of blank samples and mixed samples are collected to obtain background spectra and mixed spectra; pure pesticide spectra, mixed spectra, and background spectra are annotated with type labels and concentration numerical labels, and then divided into training sets, validation sets, and test sets in proportion to form a multidimensional spectral library; The spectrum decomposition unit is used to preprocess the Raman spectra in the multidimensional spectrum library, input the preprocessed Raman spectra into the spectrum decomposition model, and output the real pesticide spectrum; The training set construction unit is used to calculate the residual spectrum between the measured Raman spectrum of the mixed sample and the real pesticide spectrum, randomly reorganize the wavenumber points of the residual spectrum to generate multiple sets of simulated residuals; superimpose the simulated residuals on the real pesticide spectrum to construct an enhanced mixed spectrum; and construct a training data set based on the enhanced mixed spectrum and the multidimensional spectral library; The calculation expression of the enhanced mixed spectrum is: Where, is the Raman shift residual value; a(c, PH) is the concentration correlation coefficient; I T(PH) is the real pesticide spectrum; I B(PH) is the background spectrum; The model building and training unit is used to build an initial recognition model that integrates channel attention and spatial attention, and iteratively train the initial recognition model through the training data set to obtain the final recognition model.

Citation Information

Patent Citations

  • Substance identification method based on residual analysis under Raman spectrum

    CN113252641A

  • Raman spectrum denoising method based on adaptive sparse decomposition

    CN116380869A