A layered nonlinear error compensation inversion method and device for in-situ detection of living blue crabs by laser-induced breakdown spectroscopy
Patent Information
- Application Number
- CN202611473714.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-21
- Publication Date
- 2026-10-30
AI Technical Summary
不同来源的误差混合后,容易造成最终预测偏差
[0026]本发明的有益效果在于:通过建立谱-壳标定模型和考虑样本辅助特征的壳-肉关联模型形成基础反演路径,使活体青蟹外壳原位激光诱导击穿光谱能够用于目标可食组织重金属含量预测;通过按青蟹个体或养殖批次进行分组交叉验证生成交叉验证外初步预测值,降低训练信息泄漏和前级模型过拟合对残差标签的影响;通过以外壳重金属含量参考值作为中间基准将总残差分解为谱-壳误差传播分量和壳-肉基质映射误差分量,并采用不同输入特征分别进行非线性误差补偿,使不同检测及反演阶段形成的预测偏差能够得到针对性修正;通过引入光谱质量特征和综合光谱质量得分对误差补偿值进行置信度调节,并对异常光谱触发重新采集或复核,降低低质量光谱条件下无约束补偿造成的预测偏差,从而提高活体青蟹目标可食组织重金属含量原位反演的准确性、稳定性和泛化能力。
Smart Images

Figure CN123012731A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of aquatic product safety testing technology, specifically to a layered nonlinear error compensation inversion method and device for in-situ detection of laser-induced breakdown spectroscopy in live mud crabs. Background Technology
[0002] As an important aquatic product, the heavy metal content in the edible tissues of mud crabs, such as muscle tissue and hepatopancreas tissue, directly affects the quality and safety of aquatic products. Current methods for heavy metal detection in mud crabs typically employ laboratory methods such as atomic absorption spectrometry and inductively coupled plasma mass spectrometry. While these methods offer high accuracy, they generally require pretreatment of the mud crabs, including shelling, meat extraction, drying, digestion, and volume adjustment. This process is time-consuming, destructive to samples, complex, and difficult to meet the needs of rapid on-site screening.
[0003] Laser-induced breakdown spectroscopy (LIBS) is a rapid elemental detection technique that uses a pulsed laser focused onto the sample surface to ablate localized material and generate plasma. The emission spectra produced during plasma cooling are then collected, and qualitative or quantitative analysis of elements is achieved based on their characteristic spectral lines. This technique features high detection speed, minimal sample pretreatment, and the ability to simultaneously detect multiple elements, making it suitable for rapid detection of heavy metals in aquatic products.
[0004] However, for biological samples like mud crabs, which have hard shells and edible internal tissues, directly testing the target edible tissues such as muscle tissue and hepatopancreas tissue usually requires shelling or meat removal, making it difficult to maintain the live state and commercial integrity of the mud crab. If in-situ spectral detection is performed directly using the mud crab shell, the spectral response obtained from the shell and the heavy metal content calculated from the shell spectrum cannot be directly equated to the heavy metal content in the target edible tissue due to matrix differences between the shell tissue and muscle tissue and hepatopancreas tissue in terms of mineralization degree, tissue composition, water content, and heavy metal enrichment characteristics.
[0005] In addition, in-situ LIBS detection of live mud crab shells is easily affected by factors such as shell curvature, surface condition, degree of mineralization, detection point location, laser pulse energy fluctuations, and plasma formation state. The in-situ spectral quality of the same mud crab sample or different mud crab samples may differ, thus affecting the prediction results of heavy metal content based on in-situ spectroscopy.
[0006] When using spectral information to progressively invert the heavy metal content of the shell tissue and the target edible tissue, errors generated at different processing stages may propagate along the model. Specifically, the in-situ spectral acquisition status and the calibration deviation between the spectrum and the shell heavy metal content will affect the predicted shell heavy metal content; individual differences and matrix differences between the shell tissue and the target edible tissue will further affect the mapping result from shell heavy metal content to the target edible tissue heavy metal content. The mixing of errors from different sources can easily lead to final prediction bias.
[0007] Meanwhile, if the prediction residuals are generated directly using samples that have already participated in the training of the previous model during the model training process, the resulting residuals may not fully reflect the actual prediction bias of the model when facing samples that have not participated in the training. Furthermore, if the in-situ spectral quality is poor or significantly deviates from the distribution of the modeling data, and the same amplitude is still used for prediction correction according to the normal spectrum, it may also cause instability in the compensation results.
[0008] Therefore, existing in-situ spectroscopic detection of live mud crabs still suffers from problems when evaluating the heavy metal content of target edible tissues based on shell detection results. These problems include the mixing of errors at different detection and inversion stages, the influence of individual samples and tissue matrix differences on prediction, insufficient representativeness of residuals during the training stage, and insufficient prediction stability under different spectral quality conditions. Summary of the Invention
[0009] To address the technical problems mentioned in the background art, this invention provides a layered nonlinear error compensation inversion method for in-situ detection of laser-induced breakdown spectroscopy in live mud crabs, comprising: S1. Obtain in-situ laser-induced breakdown spectral data of the shell of the training mud crab sample, reference values of heavy metal content in the shell, reference values of heavy metal content in the target edible tissue, and auxiliary features of the sample. Preprocess and extract features from the in-situ laser-induced breakdown spectral data of the shell to obtain in-situ spectral features. Determine the spectral quality features characterizing the spectral acquisition state based on the multi-pulse spectrum at the same detection point. S2. Based on the in-situ spectral characteristics and the reference value of heavy metal content in the shell, establish a spectrum-shell calibration model. Based on the reference value of heavy metal content in the shell, the reference value of heavy metal content in the target edible tissue, and the sample auxiliary characteristics, establish a shell-meat correlation model. Cascade the spectrum-shell calibration model and the shell-meat correlation model to form a basic inversion path. S3. The training mud crab samples are grouped and cross-validated according to individual mud crabs or breeding batches. The cross-validated predicted values of heavy metal content in the outer shell and the preliminary predicted values of cross-validation in the mud crab samples in the current reserved subset are obtained using the spectrum-shell calibration model and the shell-meat association model that were not trained using the current reserved subset. The total residual label is constructed based on the difference between the reference value of heavy metal content in the target edible tissue and the preliminary predicted value of cross-validation. S4. Using the reference value of the heavy metal content in the outer shell as an intermediate benchmark between the spectrum-shell calibration model and the shell-meat correlation model, the total residual label is decomposed into a spectrum-shell error propagation component and a shell-meat matrix mapping error component. A spectrum-shell error compensation sub-model is established using the in-situ spectral features and the spectral quality features as inputs and the spectrum-shell error propagation component as a supervision label. A shell-meat matrix compensation sub-model is established using the cross-validated predicted values of the heavy metal content in the outer shell, the sample auxiliary features, and the spectral quality features as inputs and the shell-meat matrix mapping error component as a supervision label. S5. Obtain the in-situ laser-induced breakdown spectral data and sample auxiliary features of the shell of the live mud crab to be tested. Preprocess and extract features from the in-situ laser-induced breakdown spectral data of the shell of the live mud crab to be tested to obtain the in-situ spectral features and spectral quality features of the live mud crab to be tested. Calculate the comprehensive spectral quality score of the live mud crab to be tested based on the spectral quality features. Obtain the preliminary predicted value of the heavy metal content of the target edible tissue through the basic inversion path. Obtain the spectral-shell error compensation value and the shell-meat matrix compensation value through the spectral-shell error compensation sub-model and the shell-meat matrix compensation sub-model, respectively. Add the spectral-shell error compensation value and the shell-meat matrix compensation value to form the total error compensation value. Adjust the confidence level of the total error compensation value according to the spectral quality of the live mud crab to be tested. Fuse the adjusted total error compensation value with the preliminary predicted value of the heavy metal content of the target edible tissue to obtain the final predicted value of the heavy metal content of the target edible tissue.
[0010] The above technical solution first utilizes a spectral-shell calibration model and a shell-meat correlation model to form a basic inversion path from in-situ spectral features to shell heavy metal content, and then from shell heavy metal content to the target edible tissue heavy metal content. This allows in-situ LIBS detection information from live mud crab shells to be used for indirect inversion of target edible tissue heavy metal content. Furthermore, cross-validation is performed by grouping individual mud crabs or farming batches, so that the residuals of the training samples are generated from the basic inversion model established without using the corresponding reserved samples, reducing the impact of overfitting of the preceding model and leakage of training information on the residual labels. The shell heavy metal content is used as a reference... The value serves as an intermediate benchmark in the basic inversion path. The total residual is divided into the spectral-shell error propagation component and the shell-meat matrix mapping error component. Compensation sub-models are established according to different error sources to enable the compensation process to perform nonlinear corrections for in-situ spectral and spectral-shell calibration errors and shell-meat matrix mapping errors, respectively. At the same time, the confidence level of the total error compensation value is adjusted in combination with spectral quality to reduce the impact of overcompensation under low-quality or abnormal spectral conditions. This improves the accuracy, stability, and adaptability of the heavy metal content inversion results of the target edible tissue of live mud crabs to different sample states and spectral acquisition states.
[0011] Further, in step S1, the in-situ laser-induced breakdown spectral data of the outer shell are preprocessed, features are extracted, and spectral quality characteristics are determined, including: Multiple laser pulse excitations were performed at the same detection point in the shell region near the crab claw joint, and the plasma emission spectra generated by each laser pulse excitation were collected. The plasma emission spectrum is denoised, baseline corrected and normalized. One or more of the following parameters are extracted: peak intensity, peak area, peak height ratio, peak area ratio, half width at half maximum (WHM) of the target heavy metal element, adjacent continuous background intensity, intensity ratio of the target heavy metal element spectral line to the matrix element spectral line, and latent variables obtained by principal component analysis or partial least squares analysis, to obtain candidate in-situ spectral features. The candidate in-situ spectral features are screened to obtain the in-situ spectral features; The spectral quality characteristics are obtained by determining one or more of the following: signal-to-noise ratio, relative standard deviation of repeated acquisition, baseline drift, saturation pixel ratio, target feature peak integrity, spectral similarity, and laser pulse energy fluctuation. Each spectral quality index in the spectral quality features is converted into a normalized quality index that is positively correlated with the spectral quality level. The comprehensive spectral quality score of the i-th training crab sample is then calculated based on the normalized quality index, expressed as: ; in, Indicates the first The overall spectral quality score of a training blue crab sample. Indicates the first The first training sample of blue crabs Normalized quality indicators Indicates the first [unit] determined using the training set or validation set. Item quality weight, This indicates the number of spectral quality indicators involved in the calculation.
[0012] Through the above technical solutions, multi-pulse spectroscopy is used to form in-situ spectral features and simultaneously generate quality information characterizing the current spectral acquisition state. This enables subsequent error compensation to not only utilize the elemental content information in the spectrum, but also to identify changes in the acquisition state caused by factors such as signal-to-noise ratio, repeatability, baseline drift, and saturation.
[0013] Furthermore, the screening of candidate in-situ spectral features includes: The saturation and missing states of the original spectral variables corresponding to each candidate in-situ spectral feature are obtained, and the repeated acquisition variation coefficient of each candidate in-situ spectral feature is obtained. Candidate in-situ spectral features whose corresponding original spectral variables are saturated, missing, or whose coefficient of variation exceeds a preset threshold due to repeated sampling are removed to obtain the in-situ spectral features to be evaluated. The in-situ spectral features to be evaluated are evaluated based on the characteristic spectral response of the target heavy metal element, the stability of the spectral intensity, the correlation between the in-situ spectral features to be evaluated and the corresponding reference value of the heavy metal content in the shell, and the collinearity among the in-situ spectral features to be evaluated. The in-situ spectral features are obtained by selecting spectral features from the in-situ spectral features to be evaluated based on the evaluation results, using at least one of correlation coefficient, mutual information, minimum redundancy maximum correlation, partial least squares variable projection importance, or recursive feature elimination, to establish the spectral-shell calibration model.
[0014] By using the above technical solutions, saturated, missing, or poorly repeatable spectral variables are removed before model building. Further screening is then conducted by combining the target element response, stability, correlation, and collinearity. This helps to reduce the interference of invalid or unstable variables on spectral-shell calibration and error compensation modeling.
[0015] Furthermore, in step S2, the cascading of the spectral-shell calibration model and the shell-meat correlation model to form the basic inversion path includes: Using the in-situ spectral characteristics of the training mud crab samples as input and the reference value of the shell heavy metal content of the same training mud crab sample as the supervisory output, the spectrum-shell calibration model is established by partial least squares regression. Obtain reference values for heavy metal content in the shell, reference values for heavy metal content in the target edible tissue, and sample auxiliary features of the same training mud crab sample. Based on the reference values for heavy metal content in the shell, reference values for heavy metal content in the target edible tissue, and sample auxiliary features, establish a conditional mapping relationship between the heavy metal content in the shell and the heavy metal content in the target edible tissue to obtain the shell-meat association model. The in-situ spectral features are input into the spectrum-shell calibration model to obtain the predicted value of heavy metal content in the shell. The predicted value of heavy metal content in the shell and the sample auxiliary features are input into the shell-meat association model to obtain the preliminary predicted value of heavy metal content in the target edible tissue.
[0016] The target heavy metal elements include one or more of Pb, Cd, Hg, As, and Cr; the target edible tissue includes mud crab muscle tissue, hepatopancreas tissue, or whole edible tissue obtained by mass-weighting mud crab muscle tissue and hepatopancreas tissue; the sample auxiliary characteristics include one or more of the following: mud crab body weight, carapace width, sex, growth stage, farming batch, moisture content, claw weight, edible tissue yield, and spectral acquisition environment parameters.
[0017] By using the above technical solutions, sample auxiliary features are used as shell-meat correlation conditions, so that the mapping of heavy metal content in the shell to heavy metal content in the target edible tissue is not limited to a single fixed conversion relationship, but can take into account the differences in conditions such as individual size, growth stage, tissue state and breeding batch of mud crab.
[0018] Further, in step S3, the training mud crab samples are grouped for cross-validation according to individual mud crabs or farming batches, including: The training samples of mud crabs are divided into K non-overlapping subsets according to the individual mud crab or the farming batch. One subset is selected as the current set aside subset, and the remaining K-1 subsets are selected as the current training subsets. In each round of cross-validation, the spectral preprocessing parameters, feature selection parameters, and feature transformation parameters are determined using only the current training subset, and the spectral-shell calibration model and shell-meat association model are trained. The spectral preprocessing parameters, feature selection parameters, and feature transformation parameters determined based on the current training subset are then applied to the current reserved subset. Using the spectral-shell calibration model and shell-meat association model trained without using the current reserved subset, predictions are made for the training mud crab samples in the current reserved subset, yielding the cross-validated predicted value of heavy metal content in the outer shell and the preliminary cross-validation predicted value for the i-th training mud crab sample: ; in, Indicates the first Preliminary predictions based on cross-validation of a training sample of blue crabs. and These respectively indicate that the first [number] was not used. Spectral-shell calibration model and shell-meat association model trained on a subset Indicates the first In-situ spectral characteristics of a training sample of blue crabs Indicates the first Auxiliary features of a training sample of blue crabs; The first step is to construct the difference between the reference value of heavy metal content in the target edible tissue and the preliminary predicted value outside the cross-validation. The total residual label of each training crab sample is represented as: ; in, Indicates the first The total residual label of each training crab sample Indicates the first The target edible tissue heavy metal content reference value for a training sample of mud crab, where K is an integer greater than 1.
[0019] The above technical solutions enable the initial prediction results of each training crab sample to be generated by the base inversion model that was not trained using the reserved subset. Furthermore, the parameters for spectral preprocessing, feature selection, and feature transformation are determined only by the current training subset. This helps to reduce the small residual caused by the leakage of training information and makes the total residual label closer to the actual prediction deviation of the model when facing unknown samples.
[0020] Further, in step S4, using the reference value of heavy metal content in the shell as an intermediate benchmark between the spectrum-shell calibration model and the shell-meat correlation model, and decomposing the total residual label into a spectrum-shell error propagation component and a shell-meat matrix mapping error component, specifically includes: Get the Reference values for heavy metal content in the shell of a training mud crab sample, predicted values for heavy metal content in the shell after cross-validation, reference values for heavy metal content in the target edible tissue, and auxiliary features of the sample; The spectrum-shell error propagation component is determined based on the reference value of the outer shell heavy metal content, the cross-validated predicted value of the outer shell heavy metal content, and the sample auxiliary features, and is expressed as follows: ; Based on the reference values for heavy metal content in the target edible tissue, the reference values for heavy metal content in the shell, and auxiliary features of the sample, the shell-meat matrix mapping error component is determined and expressed as follows: ; The relationship between the total residual label, the spectral-shell error propagation component, and the shell-meat matrix mapping error component is expressed as follows: ; in, Indicates the first Spectral-shell error propagation components of a training mud crab sample Indicates the first Shell-meat matrix mapping error components of a training mud crab sample Indicates the first Reference values for heavy metal content in the shells of a training sample of blue crabs. Indicates the first Cross-validation of predicted heavy metal content in the outer shell of a training sample of blue crabs. Indicates that the first [number] was not used. The shell-meat association model is trained on a subset of training crab samples.
[0021] By using the above technical solutions, while keeping the sample auxiliary features of the same mud crab sample unchanged, the difference in the prediction of the target edible tissue generated by replacing the cross-validation shell prediction value with the reference value of shell heavy metal content is used as the spectrum-shell error propagation component, and the edible tissue prediction deviation that still exists after using the shell reference value and sample auxiliary features is used as the shell-meat matrix mapping error component, thereby distinguishing the errors formed at different stages.
[0022] Further, in step S4, the establishment of a spectral-shell error compensation sub-model using in-situ spectral features and spectral quality features as inputs and the spectral-shell error propagation component as a supervision label, and the establishment of a shell-meat matrix compensation sub-model using cross-validated predicted values of heavy metal content in the outer shell, sample auxiliary features, and spectral quality features as inputs and the shell-meat matrix mapping error component as a supervision label, specifically include: The first The in-situ spectral features and spectral quality features of a training mud crab sample constitute the spectral-shell input features. The spectral-shell error propagation component As a supervisory label corresponding to the spectral-shell input features; The first The cross-validation of predicted heavy metal content in the outer shell of a training crab sample, along with sample auxiliary features and spectral quality features, constitutes the shell-meat input features. The shell-meat matrix mapping error component As a supervisory label corresponding to the shell-meat input features; The sample weights are determined based on the reference detection reliability, comprehensive spectral quality score, and sample representativeness of each training crab sample, and the sample weights are limited between a preset lower weight limit and a preset upper weight limit. Training crab samples with unstable reference detection, severely saturated in-situ spectra, or spectral quality exceeding the effective range of the model determined based on the spectral quality distribution of effective training samples are judged as invalid samples, and the invalid samples are removed or re-collected. A nonlinear mapping relationship between the spectral-shell input features and the spectral-shell error propagation components is established using one of the following: gradient boosting decision tree, XGBoost, support vector regression, random forest regression, or multilayer perceptron. This yields a spectral-shell error compensation sub-model, and the spectral-shell error compensation value output by the sub-model is expressed as follows: ; in, Indicates the first Spectral-shell error compensation values for a training sample of blue crabs. The spectrum-shell error compensation sub-model is represented. Indicates by the first The spectral-shell input features consist of in-situ spectral features and spectral quality features of a training mud crab sample; A nonlinear mapping relationship between the shell-meat input features and the shell-meat matrix mapping error components is established using one of the following: gradient boosting decision tree, XGBoost, support vector regression, random forest regression, or multilayer perceptron. This results in a shell-meat matrix compensation sub-model, whose output shell-meat matrix compensation value is expressed as follows: ; in, Indicates the first Shell-meat matrix compensation values for a training sample of blue crabs. This represents the shell-meat matrix compensator sub-model. Indicates by the first The shell-meat input features consist of cross-validation predictions of heavy metal content in the outer shell of a training mud crab sample, sample auxiliary features, and spectral quality features. When the spectral-shell error compensation sub-model uses XGBoost, the training objective is to minimize the sum of the weighted Huber loss and regularization term between the spectral-shell error propagation component and the spectral-shell error compensation value. The training objective function of the spectral-shell error compensation sub-model is expressed as: ; in, The training objective function of the spectral-shell error compensation sub-model is given by: This indicates the number of training crab samples. Indicates the first The sample weights of each training crab sample. This represents the Huber loss function. Indicates the first The spectral-shell error propagation components of the training blue crab samples This represents the regularization term used to limit the complexity of the spectrum-shell error compensation submodel; When the shell-meat matrix compensation sub-model uses XGBoost, the training objective is to minimize the sum of the weighted Huber loss and regularization term between the shell-meat matrix mapping error components and the shell-meat matrix compensation value. The training objective function of the shell-meat matrix compensation sub-model is expressed as: ; in, Let represent the training objective function of the shell-meat matrix compensator submodel. Indicates the first The shell-meat matrix mapping error components of the training mud crab samples This represents the regularization term used to limit the complexity of the shell-meat matrix compensator submodel; For the XGBoost spectral-shell error compensation sub-model or shell-meat matrix compensation sub-model, the negative gradient of the current residual loss is fitted sequentially, and the th... The update method of the wheel model is represented as follows: ; in, Indicates the first The updated model output, Indicates the first The updated model output, This represents the input features of the current error compensation sub-model. Indicates the first Each regression tree outputs a predicted value for the input features. The learning rate is represented by the number of regression trees, the maximum tree depth, the learning rate, and the regularization parameter are determined through the validation set, and the training is terminated using an early stopping rule to obtain the spectrum-shell error compensation sub-model and the shell-meat matrix compensation sub-model.
[0023] Further, in step S5, the step of adjusting the confidence level of the total error compensation value based on the spectral quality of the live mud crab to be detected, and then fusing the adjusted total error compensation value with the preliminary predicted value of the heavy metal content of the target edible tissue to obtain the final predicted value of the heavy metal content of the target edible tissue, specifically includes: The in-situ spectral characteristics and spectral quality characteristics of the live mud crab to be detected are input into the spectral-shell error compensation sub-model to obtain the spectral-shell error compensation value; The predicted heavy metal content of the shell of the live mud crab to be tested, the sample auxiliary features, and the spectral quality features are input into the shell-meat matrix compensation sub-model to obtain the shell-meat matrix compensation value. The total error compensation value is obtained by adding the spectrum-shell error compensation value to the shell-meat matrix compensation value. The confidence adjustment coefficient is determined based on the comprehensive spectral quality score of the live mud crab to be tested. The total error compensation value is then truncated and adjusted for confidence. The processed total error compensation value is then fused with the preliminary predicted value of the heavy metal content in the target edible tissue to obtain the final predicted value of the heavy metal content in the target edible tissue, expressed as follows: ; in, This represents the final predicted value of heavy metal content in the target edible tissue. This indicates the preliminary predicted value of heavy metal content in the target edible tissue. Indicates the overall spectral quality score The determined confidence level adjustment coefficient, This represents the total error compensation value. and These represent the lower and upper limits of compensation determined based on the residual distribution of the training set or the validation set, respectively. This represents the truncation function; When the spectral quality of the live mud crab to be tested exceeds the effective range of the model, the in-situ laser-induced breakdown spectral data of the shell is triggered for re-acquisition or verification.
[0024] According to another aspect of the present invention, a hierarchical nonlinear error compensation inversion device for in-situ detection of laser-induced breakdown spectroscopy in live mud crabs is provided, comprising: The sample adaptive clamping module is used to fix the live mud crab to be tested and adjust the posture of the live mud crab to be tested to expose the area of the crab claw joint adjacent to the shell of the live mud crab to be tested. The machine vision positioning module is used to acquire images of the live mud crab to be detected, identify the shell area adjacent to the crab claw joint, and output the coordinates of the detection point located in the shell area adjacent to the crab claw joint. The transmission control module is used to adjust the relative position between the live crab to be detected and the laser focusing position according to the coordinates of the detection point, so that the detection point is aligned with the laser focusing position; The LIBS spectral excitation acquisition module is used to perform multiple laser pulse excitations at the detection point and acquire in-situ laser-induced breakdown spectral data generated by each laser pulse excitation. The sample parameter acquisition module is used to acquire auxiliary features of the live mud crab to be detected. The data processing terminal is communicatively connected to the machine vision positioning module, transmission control module, LIBS spectral excitation acquisition module, and sample parameter acquisition module. The data processing terminal stores a spectrum-shell calibration model, a shell-meat correlation model, a spectrum-shell error compensation sub-model, and a shell-meat matrix compensation sub-model. It is used to preprocess and extract features from the in-situ laser-induced breakdown spectral data to obtain in-situ spectral features and spectral quality features. The in-situ spectral features are input into the spectrum-shell calibration model to obtain a predicted value for the shell heavy metal content. The predicted shell heavy metal content and sample auxiliary features are then input into the shell-meat correlation model to obtain the target edible group. The preliminary prediction of heavy metal content in the target edible tissue is obtained by inputting the in-situ spectral features and spectral quality features into the spectral-shell error compensation sub-model. The predicted heavy metal content in the shell, sample auxiliary features, and spectral quality features are then input into the shell-meat matrix compensation sub-model to obtain the shell-meat matrix compensation value. The spectral-shell error compensation value and the shell-meat matrix compensation value are added to form a total error compensation value. The confidence level of the total error compensation value is adjusted based on the spectral quality of the live mud crab to be tested. The adjusted total error compensation value is then fused with the preliminary prediction of heavy metal content in the target edible tissue to obtain the final predicted heavy metal content in the target edible tissue.
[0025] Furthermore, the sample adaptive clamping module, machine vision positioning module, transmission control module, and LIBS spectral excitation acquisition module specifically include: The LIBS spectral excitation acquisition module includes a pulsed laser, an optical focusing system, a detector, a spectrometer, and a digital delay generator. The digital delay generator is used to control the timing synchronization between the pulsed laser and the spectrometer. The machine vision positioning module includes a camera, a ring-shaped supplementary light source, and an image processor. The image processor is used to process the live mud crab images to be detected captured by the camera, identify the area of the shell adjacent to the crab claw joint, and output the coordinates of the detection point. The transmission control module includes a programmable logic controller and an XYZ positioning platform. The programmable logic controller is used to receive the coordinates of the detection point and control the movement of the XYZ positioning platform according to the coordinates of the detection point so that the detection point is aligned with the laser focusing position. The sample adaptive clamping module includes a support base, a support structure, a bearing platform, a clamping assembly, and a driving mechanism. The support base is used to install and support the bearing platform and the clamping assembly. The support structure is used to support the support base and cooperates with the driving mechanism to adjust the position or orientation of the bearing platform or the clamping assembly, so that the area of the crab claw joint near the shell of live mud crabs of different sizes is exposed to the laser incident path.
[0026] The beneficial effects of this invention are as follows: By establishing a spectrum-shell calibration model and a shell-meat correlation model that considers sample auxiliary features to form a basic inversion path, the in-situ laser-induced breakdown spectrum of the shell of live mud crabs can be used to predict the heavy metal content of the target edible tissue; by grouping and cross-validating by individual mud crabs or farming batches to generate preliminary prediction values outside cross-validation, the impact of training information leakage and overfitting of the previous model on the residual label is reduced; by using the reference value of heavy metal content in the shell as an intermediate benchmark, the total residual is decomposed into spectrum-shell error propagation components and shell-meat matrix mapping error components, and nonlinear error compensation is performed using different input features, so that the prediction deviations formed in different detection and inversion stages can be specifically corrected; by introducing spectral quality features and comprehensive spectral quality scores to adjust the confidence of the error compensation value, and triggering re-acquisition or verification of abnormal spectra, the prediction deviation caused by unconstrained compensation under low-quality spectral conditions is reduced, thereby improving the accuracy, stability and generalization ability of in-situ inversion of heavy metal content in the target edible tissue of live mud crabs. Attached Figure Description
[0027] The accompanying drawings are included to provide a further understanding of the embodiments and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments and, together with the description, serve to explain the principles of the invention. Other embodiments and many anticipated advantages of the embodiments will be readily recognized as they become better understood through reference to the following detailed description. Elements in the drawings are not necessarily to scale. The same reference numerals refer to corresponding similar parts.
[0028] Figure 1 This is a flowchart illustrating a hierarchical nonlinear error compensation inversion method for in-situ detection of laser-induced breakdown spectroscopy in live mud crabs according to an embodiment of the present invention. Figure 2 This is a schematic diagram of a sub-process of step S1 according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the in-situ spectral feature screening process according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the basic inversion path construction process in step S2 according to an embodiment of the present invention; Figure 5 This is a schematic diagram of the fitting of the shell-meat Pb content correlation model according to an embodiment of the present invention; Figure 6 This is a schematic diagram of the process for constructing the preliminary predicted value and total residual label in step S3 of the present invention. Figure 7 This is a schematic diagram of the hierarchical error decomposition and error compensation sub-model construction process in step S4 according to an embodiment of the present invention; Figure 8 This is a schematic diagram of the layering error compensation inversion process for the live mud crab to be detected in step S5 according to an embodiment of the present invention. Figure 9 This is a structural block diagram of a hierarchical nonlinear error compensation inversion device according to an embodiment of the present invention; Figure 10 This is a schematic diagram of the sample adaptive clamping module according to an embodiment of the present invention; Figure 11 This is a schematic diagram of a machine vision positioning and transmission control structure according to an embodiment of the present invention; Figure 12 This is a schematic diagram of the structure of the LIBS spectral excitation and acquisition module according to an embodiment of the present invention; Figure 13 This is a schematic diagram of the overall structure of the hierarchical nonlinear error compensation inversion device according to an embodiment of the present invention.
[0029] Reference numerals: 1. Live mud crab to be tested; 2. LIBS spectral excitation and acquisition module; 3. Machine vision positioning module; 4. Sample adaptive clamping module; 5. Transmission control module; 6. Data processing terminal; 21. Pulsed laser; 22. Optical focusing system; 23. Detector; 24. Spectrometer; 25. Digital delay generator; 31. Camera; 32. Ring supplementary light source; 33. Image processor; 41. Support base; 42. Support structure; 43. Bearing platform; 44. Clamping assembly; 45. Drive mechanism; 51. Programmable logic controller; 52. XYZ positioning platform. Detailed Implementation
[0030] The present invention will now be described in further detail with reference to specific embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0031] In the description of this invention, it should be noted that the terms "upper", "lower", "front", "rear", "left", "right", "inner", "outer", "horizontal", "vertical", etc., indicating the orientation or positional relationship are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device, module or component referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this invention.
[0032] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "fixing," "setting," "communication connection," etc., should be interpreted broadly. For example, they can refer to fixed connections or detachable connections; mechanical connections, electrical connections, or signal connections; direct connections or indirect connections via intermediate components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0033] This invention provides a hierarchical nonlinear error compensation inversion method for in-situ detection of laser-induced breakdown spectroscopy in live mud crabs. This method is applicable to predicting the heavy metal content in target edible tissues based on in-situ laser-induced breakdown spectroscopy data of the mud crab shell in a live state. The target edible tissues include mud crab muscle tissue, hepatopancreas tissue, or whole edible tissue obtained by mass-weighting mud crab muscle tissue and hepatopancreas tissue; the target heavy metal elements include one or more of Pb, Cd, Hg, As, and Cr.
[0034] refer to Figure 1 , Figure 1 A schematic flowchart of a hierarchical nonlinear error compensation inversion method for in-situ detection of laser-induced breakdown spectroscopy in live mud crabs, according to an embodiment of the present invention, is shown. Figure 1As shown, the hierarchical nonlinear error compensation inversion method for in-situ detection of laser-induced breakdown spectra of live mud crabs provided in this embodiment of the invention includes the following steps: S1. Obtain in-situ laser-induced breakdown spectral data of the shell of the training mud crab sample, reference values of heavy metal content in the shell, reference values of heavy metal content in the target edible tissue, and sample auxiliary features. Preprocess and extract features from the in-situ laser-induced breakdown spectral data of the shell to obtain in-situ spectral features, and determine the spectral quality features characterizing the spectral acquisition state based on the multi-pulse spectrum at the same detection point.
[0035] refer to Figure 2 , Figure 2 A schematic diagram of a sub-process of step S1 in an embodiment of the present invention is shown. For example... Figure 2 As shown, step S1 specifically includes the following steps: S11. Obtain training crab samples and obtain sample auxiliary features of the training crab samples.
[0036] During the model building phase, training samples of mud crabs can be collected from multiple typical mud crab farming bases, pond farming areas, tidal flat farming areas, estuary farming areas, and aquatic product wholesale markets with clear source information. The sampling areas cover different heavy metal exposure levels, including background level areas, low exposure areas, and high exposure areas, to improve the representativeness of the heavy metal content distribution in the training samples.
[0037] When sampling, the origin, farming method, sampling time, size, body weight, sex, and growth stage of the training mud crab samples should be recorded. For samples from aquatic product wholesale markets, their batch, origin, or circulation information can also be recorded to improve the representativeness and traceability of the training samples.
[0038] The sample size is determined based on the modeling accuracy and group coverage requirements. Since this invention requires establishing a spectrum-shell calibration model between in-situ spectra and shell heavy metal content, a shell-meat correlation model between shell heavy metal content and target edible tissue heavy metal content, and a subsequent error compensation sub-model, the training samples of mud crabs preferably cover different growth stages, different sizes, different origins, and different heavy metal exposure levels.
[0039] In one specific implementation, provided that the number of samples in each major group is not less than 20 to 30, the total sample size is not less than 100, preferably 150 to 300. The training crab samples can be divided into training set, validation set and test set according to the proportions of 70%, 20% and 10%, and K-fold grouping cross-validation is performed on the corresponding training crab samples according to step S3 during the model training process.
[0040] The sample auxiliary features include one or more of the following: body weight of mud crab, carapace width, sex, growth stage, breeding batch, moisture content, claw weight, edible tissue yield, and spectral acquisition environment parameters, which are used to provide conditional information related to the individual state, tissue state, individual size, and spectral acquisition environment of mud crab.
[0041] Among them, the The edible tissue yield of a training sample of mud crabs can be determined by the following formula: ; in, Indicates the first Edible tissue yield of a training sample of mud crabs; Indicates from the first Quality of target edible tissues isolated from a training sample of blue crabs; Indicates the first The whole crab weight of each training mud crab sample before edible tissue separation. All weights were determined using the same mass standard, with fresh weight being preferred.
[0042] When the target edible tissue includes muscle tissue and hepatopancreatic tissue, the edible tissue yield is expressed as: ; in, Indicates the first Muscle tissue quality of a training sample of blue crabs; Indicates the first The quality of hepatopancreatic tissue from a training sample of blue crabs.
[0043] No. The water content of each training sample of mud crabs is determined according to the following formula: in, Indicates the first Moisture content of the training mud crab samples; Indicates the fresh weight of the corresponding tissue before drying; This indicates the dry weight of the corresponding tissue after drying to constant weight.
[0044] Edible tissue yield and moisture content during the training phase can be obtained by dissecting, weighing, and drying the training mud crab samples. Since the training mud crab samples are used for model building, maintaining the commercial integrity of the corresponding mud crab samples is not required during the training phase.
[0045] The growth stage can be converted into numerical features that the model can recognize by using one-hot encoding, ordinal encoding, or preset numerical encoding.
[0046] It should be noted that the sample auxiliary features are not used to characterize the target heavy metal content alone, nor are there any pre-defined fixed linear, monotonic, or direct conversion relationships between the sample auxiliary features and the target heavy metal content. Instead, they serve as conditional information describing the individual state, tissue state, and size state of the mud crab, and are used to assist the shell-meat association model and the subsequent shell-meat matrix compensation sub-model in identifying the prediction differences under different sample states.
[0047] S12. Determine the detection point in the shell region near the claw joint of the training mud crab sample, and collect the in-situ laser-induced breakdown spectrum data of the shell at the detection point.
[0048] Specifically, the sample adaptive clamping module 4 is used to fix the training crab sample and adjust its posture so that the shell region near the claw joint is exposed. The shell region near the claw joint can be the shell region near the thin membrane at the claw joint or the shell region near the soft tissue at the claw joint.
[0049] When the area near the crab claw joint is selected as the in-situ detection area, this area can form a relatively stable shell detection window through clamping and positioning, which is conducive to maintaining the stability of the laser focusing position and reducing spectral fluctuations caused by uneven shell thickness, surface curvature and strong mineralization structure. At the same time, this area is adjacent to the edible muscle tissue inside the crab claw, which is convenient for establishing the correlation between the shell tissue and the target edible tissue.
[0050] Furthermore, images of the blue crab can be acquired through the machine vision positioning module 3, and the trained object detection model can be used to identify the shell region near the crab's claw joints. In one specific embodiment, the object detection model adopts the YOLOv5 deep learning model.
[0051] Based on the identified crab claw joint contour and the shell area adjacent to the crab claw joint, the detection points are avoided in the joint gaps, attachment areas, and areas with curvature greater than the preset curvature threshold, and the detection points are determined from the remaining shell area.
[0052] The spatial pixel coordinates of the detection points are calculated based on the recognition results. The detection point coordinates can be directly obtained from the spatial pixel coordinates, or they can be obtained from the mechanical coordinates or control coordinates through camera calibration and platform coordinate transformation.
[0053] The transmission control module 5 controls the movement of the XYZ positioning platform 52 according to the coordinates of the detection point, so as to adjust the relative position between the crab sample and the laser focusing position, and align the detection point with the laser focusing position.
[0054] The LIBS spectral excitation and acquisition module 2 focuses a pulsed laser onto the detection point, which excites the shell material at the detection point and forms plasma. The emission spectrum generated by the plasma is then acquired.
[0055] To reduce random errors caused by laser energy fluctuations and sample surface conditions, N laser pulse excitations were performed at the same detection point in the region near the crab claw joint and shell. The plasma emission spectra generated by each laser pulse excitation were collected, where N is an integer greater than 1.
[0056] In one specific implementation, the average spectral data can be calculated based on N plasma emission spectra, and the average spectral data can be used for subsequent content-related feature extraction; at the same time, the single spectrum corresponding to each laser pulse can be retained to determine spectral quality indicators such as the relative standard deviation of repeated acquisitions and spectral similarity.
[0057] S13. Preprocess and extract features from the in-situ laser-induced breakdown spectral data of the outer shell.
[0058] Specifically, the acquired plasma emission spectra are subjected to denoising, baseline correction, and standardization. The standardization process can be performed using standard normal variable (SNV) standardization.
[0059] Furthermore, one or more of the following parameters are extracted from the preprocessed spectrum: peak intensity, peak area, peak height ratio, peak area ratio, half width at half maximum (WHM), adjacent continuous background intensity, intensity ratio of the target heavy metal element spectral line to the matrix element spectral line, and latent variables obtained through principal component analysis or partial least squares analysis, to form candidate in-situ spectral features.
[0060] The target heavy metal elements include one or more of Pb, Cd, Hg, As, and Cr; the matrix elements may include one or more of Ca, Mg, Na, and K. These matrix elements are related to the mineralization state of the outer shell and can be used to characterize the influence of differences in the outer shell matrix on the LIBS spectral response.
[0061] Further, refer to Figure 3 , Figure 3 A schematic diagram of the in-situ spectral feature screening process according to an embodiment of the present invention is shown. Figure 3 As shown, the screening of candidate in-situ spectral features specifically includes: S131. Obtain the saturation and missing states of the original spectral variables corresponding to each candidate in-situ spectral feature, and obtain the repeated acquisition variation coefficient of each candidate in-situ spectral feature. S132. Remove candidate in-situ spectral features whose corresponding original spectral variables are saturated, missing, or whose coefficient of variation exceeds a preset threshold due to repeated acquisitions, and obtain the in-situ spectral features to be evaluated. S133. Evaluate the in-situ spectral characteristics to be evaluated based on the characteristic spectral response of the target heavy metal element, the stability of the spectral intensity, the correlation between the in-situ spectral characteristics to be evaluated and the corresponding reference value of the heavy metal content in the shell, and the collinearity among the in-situ spectral characteristics to be evaluated. S134. Using at least one of correlation coefficient, mutual information, minimum redundancy maximum correlation, partial least squares variable projection importance, or recursive feature elimination, select spectral features for model building from the in-situ spectral features to be evaluated based on the evaluation results, and obtain the in-situ spectral features.
[0062] It should be noted that during cross-validation, the parameters related to feature selection are determined only using the current training subset. The current reserved subset is not involved in determining the feature selection parameters, so as to avoid the reserved sample information from participating in model training.
[0063] S14. Determine the spectral quality characteristics.
[0064] The spectral quality characteristics include one or more of the following: signal-to-noise ratio, relative standard deviation of repeated acquisitions, baseline drift, saturation pixel ratio, target feature peak integrity, spectral similarity, and laser pulse energy fluctuation.
[0065] For the target element , No. The signal-to-noise ratio of a training blue crab sample can be expressed as: ; in, Represents the target element The characteristic emission peak intensity; Represents the target element The average intensity of the background band with no characteristic peaks near the characteristic emission peak; The standard deviation of the spectral intensity of the background band is represented.
[0066] The relative standard deviation of repeated acquisitions can be determined by the ratio of the standard deviation to the average value of the target characteristic peak intensity acquired multiple times at the same detection point.
[0067] The baseline drift can be determined by the root mean square deviation of the fitted baseline relative to the zero baseline.
[0068] Spectral similarity can be determined by the cosine similarity between a single spectrum and the mid-spectrum of multiple acquisitions of the same sample.
[0069] S15. Determine the comprehensive spectral quality score based on the spectral quality characteristics.
[0070] Each spectral quality index is converted into a normalized quality index that is positively correlated with the spectral quality level, and the 1st... The overall spectral quality score of the training blue crab samples: ; in, Indicates the first The overall spectral quality score of a training blue crab sample. Indicates the first The first training sample of blue crabs Normalized quality indicators Indicates the first [unit] determined using the training set or validation set. Item quality weight, This indicates the number of spectral quality indicators involved in the calculation.
[0071] The spectral quality index can be used in subsequent error compensation in at least one of the following ways: as a direct input feature of the error compensation sub-model; as a basis for determining the weights of training samples; as a basis for adjusting the confidence level of the error compensation value; or as a criterion for determining the validity of the spectrum.
[0072] S16. Obtain reference values for heavy metal content in the shell and heavy metal content in the target edible tissue.
[0073] For the same training mud crab sample that has completed in-situ LIBS spectral acquisition, its shell tissue was separated, and after drying, digestion and volume adjustment, the content of target heavy metal elements was determined by inductively coupled plasma mass spectrometry (ICP-MS) to obtain reference values for the heavy metal content of the shell.
[0074] Furthermore, the target edible tissue was isolated from the same training mud crab sample, and after drying, digestion and volume adjustment, the content of the corresponding target heavy metal elements was determined by ICP-MS to obtain reference values for the heavy metal content of the target edible tissue.
[0075] When the target edible tissues are muscle tissue and hepatopancreatic tissue, reference values for the heavy metal content of the target edible tissues can be generated for muscle tissue and hepatopancreatic tissue respectively.
[0076] When the target edible tissue is the total edible tissue obtained by weighting muscle tissue and hepatopancreatic tissue according to mass, its reference or predicted value can be expressed as: ; in, Indicates the total heavy metal content of edible tissue; and These represent the heavy metal content in muscle tissue and hepatopancreatic tissue, respectively. and These represent the mass of muscle tissue and hepatopancreatic tissue, respectively.
[0077] S2. Establish a spectrum-shell calibration model based on in-situ spectral characteristics and reference values of heavy metal content in the shell. Establish a shell-meat correlation model based on reference values of heavy metal content in the shell, reference values of heavy metal content in the target edible tissue, and auxiliary features of the sample. Cascade the spectrum-shell calibration model and the shell-meat correlation model to form a basic inversion path.
[0078] refer to Figure 4 , Figure 4 A schematic diagram of the basic inversion path construction process in step S2 of an embodiment of the present invention is shown. Figure 4 As shown, step S2 specifically includes the following steps: S21. Establish the spectrum-shell calibration model.
[0079] For the A training sample of mud crabs was used to create spectrum-shell calibration data by combining its in-situ spectral characteristics with reference values for heavy metal content in the shell. ; in, Indicates the first In-situ spectral feature matrix of a training blue crab sample This represents the reference value for the heavy metal content in the shell of the i-th training crab sample.
[0080] The spectral-shell calibration model F is a regression model, whose input is in-situ spectral characteristics and whose output is the predicted value of heavy metal content in the shell. ; in, This indicates the predicted heavy metal content in the outer shell. This represents the in-situ spectral characteristic matrix.
[0081] In one specific implementation, the spectral-shell calibration model adopts a partial least squares regression model, expressed as: ; in, Represents the regression coefficient matrix. This represents the intercept term.
[0082] When multiple heavy metal elements are detected simultaneously, the predicted heavy metal content in the shell is a multi-dimensional vector: ; in, , , , , They represent the shell structure respectively , , , and The predicted content value.
[0083] During model training, the training objective is to minimize the mean square error between the predicted heavy metal content in the shell and the reference value of heavy metal content in the shell measured by ICP-MS. ; in, This indicates the number of training crab samples.
[0084] After training, the spectrum-shell calibration model is used to convert the in-situ spectral characteristics of the live mud crabs to be tested into predicted values of heavy metal content in the shell.
[0085] S22. Establish a shell-meat association model.
[0086] The reference values of heavy metal content in the shell, the reference values of heavy metal content in the target edible tissue, and the sample auxiliary features of the same training mud crab sample are obtained. Based on the reference values of heavy metal content in the shell, the reference values of heavy metal content in the target edible tissue, and the sample auxiliary features, a conditional mapping relationship between the heavy metal content in the shell and the heavy metal content in the target edible tissue is established, and the shell-meat association model G is obtained.
[0087] The shell-meat association model can be represented as: ; in, Indicates the heavy metal content of the outer shell. Indicates auxiliary features of the sample. This indicates the preliminary predicted value of heavy metal content in the target edible tissue.
[0088] During the training phase: ; In the forecasting phase: ; Among them, the sample auxiliary features are used as conditional variables to reflect the differences in the shell-meat relationship under different growth stages, sample sizes and tissue conditions.
[0089] In some specific implementations, the shell-meat association can be modeled using a biological allocation coefficient model, a linear mapping model, or a power-law nonlinear mapping model, depending on the specific sample conditions or sample groupings.
[0090] When using the biopartition coefficient model, the biopartition coefficient K is used to characterize the heavy metal distribution ratio between the shell tissue and the target edible tissue: ; For unknown samples: ; The biological allocation coefficient K can be obtained from the statistics of the training mud crab samples: ; Robust statistical methods such as median and grouped mean can also be used to obtain the value. For different target heavy metal elements, different growth stages, or different sizes of mud crabs, the corresponding bioassortment coefficient K can be calculated separately.
[0091] When using a linear mapping model: ; After training, for unknown samples: ; in, and This represents the calibration parameters obtained by fitting the training samples.
[0092] When using a power-law nonlinear mapping model: ; After taking the logarithm, it becomes: ; Fitting and Then, for unknown samples: ; The specific mapping forms described above are used to illustrate the implementation of the shell-meat association model, and do not limit the shell-meat association model to only using the above forms.
[0093] refer to Figure 5 , Figure 5 This diagram illustrates a fitting schematic of the shell-meat Pb content correlation model according to a specific embodiment of the present invention. Under preset sample conditions, taking Pb as an example, a shell-meat correlation model is established based on the reference values of Pb content in the shell of training mud crab samples and the corresponding reference values of Pb content in the target edible tissue. Each data point in the diagram represents the pairing relationship between the shell Pb content and the target edible tissue Pb content of the corresponding training mud crab sample. The fitting curve is used to characterize the correlation between the shell Pb content and the target edible tissue Pb content under the aforementioned sample conditions. For other target heavy metal elements such as Cd, Hg, As, and Cr, corresponding shell-meat correlation models can be established in the same manner.
[0094] S23. Cascade the spectrum-shell calibration model and the shell-meat correlation model to form the basic inversion path.
[0095] Input the in-situ spectral feature X into the spectral-shell calibration model F: ; Then, the predicted heavy metal content of the shell and the corresponding auxiliary features of the samples are input into the shell-meat association model G: ; This forms a basic inversion path from in-situ spectral characteristics to the heavy metal content of the shell, and then from the heavy metal content of the shell combined with sample conditions to the preliminary predicted value of the heavy metal content of the target edible tissue.
[0096] S3. Group the training mud crab samples according to individual mud crabs or breeding batches to perform cross-validation, obtain preliminary predicted values outside cross-validation, and construct the total residual label based on the difference between the reference value of heavy metal content in the target edible tissue and the preliminary predicted value outside cross-validation.
[0097] refer to Figure 6 , Figure 6 This diagram illustrates the process of constructing preliminary predicted values and total residual labels outside of cross-validation in step S3 of an embodiment of the present invention. Figure 6 As shown, step S3 specifically includes the following steps: S31. Divide the training mud crab samples into K non-overlapping subsets according to the individual mud crab or the breeding batch.
[0098] Each time, one subset is selected as the current reserved subset, and the remaining K-1 subsets are selected as the current training subsets.
[0099] S32. Build the basic inversion model for the current round using the current training subset.
[0100] In each round of cross-validation, only the current training subset is used to determine the spectral preprocessing parameters, feature selection parameters, and feature transformation parameters, and to train the spectral-shell calibration model and the shell-meat association model.
[0101] The spectral preprocessing parameters, feature selection parameters, and feature transformation parameters determined based on the current training subset will be applied to the current reserved subset.
[0102] This avoids the information in the current reserved subset from being used to determine the corresponding preprocessing parameters, feature selection parameters, or model parameters.
[0103] S33. Obtain the cross-validation out-of-prediction results of the current reserved subset.
[0104] For those belonging to the first The first set of reserved subsets The cross-validation predicted values of heavy metal content in the outer shell of a training mud crab sample are expressed as follows: ; in, Indicates that the first [number] was not used. A spectral-shell calibration model trained on a subset of data.
[0105] Furthermore, the predicted heavy metal content of the outer shell and the corresponding sample auxiliary features were input into the cross-validation method without using the first... Shell-meat association model trained on a subset: ; in, Indicates the first Preliminary predictions based on cross-validation of a training sample of blue crabs. Indicates that the first [number] was not used. A shell-meat association model trained on a subset of data.
[0106] After repeating K times, each training crab sample obtains an initial cross-validation prediction value obtained from data trained without using its own reserved subset.
[0107] S34. Construct total residual labels.
[0108] According to the The total residual label is constructed by comparing the reference values of heavy metal content in the edible tissue of a training mud crab sample with the preliminary predicted values outside cross-validation. ; in, Indicates the first The total residual label of each training crab sample Indicates the first Reference values for heavy metal content in the edible tissue of a training sample of blue crab.
[0109] Using cross-validation to construct the total residual label can reduce information leakage caused by the same sample participating in both the training of the preceding model and the generation of residual labels, as well as the underestimation of the residuals of the training samples.
[0110] Furthermore, standardization can be performed before using continuous input variables in subsequent error compensation models: ; in, Indicates the first The first training sample of blue crabs One standardized feature; Indicates the first before standardization One feature; and They represent the first and second digits calculated based on the training set, respectively. The mean and standard deviation of each feature. The model validation and liveness prediction phases use the values determined during the training phase. and Perform the same standardization process.
[0111] S4. Using the reference value of heavy metal content in the shell as an intermediate benchmark between the spectrum-shell calibration model and the shell-meat correlation model, the total residual label is decomposed into the spectrum-shell error propagation component and the shell-meat matrix mapping error component, and the spectrum-shell error compensation sub-model and the shell-meat matrix compensation sub-model are established respectively.
[0112] refer to Figure 7 , Figure 7 This diagram illustrates the process of constructing the hierarchical error decomposition and error compensation sub-model in step S4 of an embodiment of the present invention. Figure 7 As shown, step S4 specifically includes the following steps: S41. Decompose the total residual label into the spectrum-shell error propagation component and the shell-meat matrix mapping error component.
[0113] For the i-th training blue crab sample belonging to the k-th reserved subset, the spectrum-shell error propagation component is determined based on its reference value of shell heavy metal content, cross-validation predicted value of shell heavy metal content, and sample auxiliary features: ; in, The error is used to characterize the prediction bias of heavy metal content in the shell caused by in-situ spectral acquisition error and spectral-shell calibration error, and is then propagated to the target edible tissue prediction domain by the shell-meat correlation model.
[0114] Furthermore, the shell-meat matrix mapping error components are determined based on the reference values for heavy metal content in the target edible tissue, the reference values for heavy metal content in the shell, and auxiliary features of the sample: ; in, This is used to characterize the matrix differences between the shell tissue and the target edible tissue, as well as the residual prediction error caused by the underfitting of the shell-meat association model, given that reference values for heavy metal content in the shell and corresponding sample conditions have already been used.
[0115] The total residual label and the two error components satisfy the following: ; Therefore, by using the reference value of heavy metal content in the outer shell as an intermediate benchmark, the total error that was originally mixed in the prediction results of the target edible tissue can be decomposed into different error generation stages.
[0116] S42. Establish a spectrum-shell error compensation sub-model.
[0117] The first The in-situ spectral features and spectral quality features of a training mud crab sample constitute the spectral-shell input features: ; Spectrum-shell error propagation components As corresponding supervisory labels, a nonlinear mapping relationship is established between spectral-shell input features and spectral-shell error propagation components: ; in, This represents the spectral-shell error compensation value output by the spectral-shell error compensation sub-model. The spectrum-shell error compensation sub-model is represented.
[0118] Since the spectral-shell error mainly occurs during in-situ spectral acquisition and in-situ spectral to shell content calibration stages, the specific spectral response state is described by in-situ spectral characteristics, and the current spectral acquisition quality is described by spectral quality characteristics.
[0119] S43. Establish a shell-meat matrix compensator model.
[0120] The first The cross-validation predictions of heavy metal content in the outer shell of a training crab sample, along with sample auxiliary features and spectral quality features, constitute the shell-meat input features: ; shell-meat matrix mapping error components As corresponding supervisory labels, a nonlinear mapping relationship is established between shell-meat input features and shell-meat matrix mapping error components: ; in, This represents the shell-meat matrix compensation value output by the shell-meat matrix compensation sub-model. This represents the shell-meat matrix compensator model.
[0121] The sample auxiliary features, such as body weight, carapace width, sex, growth stage, breeding batch, moisture content, claw weight, and edible tissue yield of mud crabs, provide information on the status, individual size, and tissue condition of mud crab samples from different dimensions.
[0122] It should be noted that the relationship between different sample auxiliary features and their corresponding prediction biases is not exclusive or one-to-one. For example, sample size parameters can reflect individual size and tissue development status, and may also be related to the shell spectral acquisition status; water content can reflect differences in in-situ spectral response, and may also reflect differences in sample tissue status.
[0123] Correspondingly, the bias generated by the two-level prediction of the spectrum-shell calibration model and the shell-meat correlation model is not characterized by a single sample auxiliary feature, but is a comprehensive prediction bias formed under the corresponding sample state, tissue state, size state and spectral acquisition state.
[0124] S44. Determine sample weights based on the detection status of the training crab samples and handle invalid samples.
[0125] The sample weights are determined based on the reference detection reliability, comprehensive spectral quality score, and sample representativeness of each training mud crab sample. The sample weights are limited to a preset lower weight limit and a preset upper weight limit.
[0126] For training crab samples with unstable reference detection, severely saturated in-situ spectra, or spectral quality exceeding the effective range of the model determined by the spectral quality distribution of effective training samples, instead of simply reducing their weights to force compensation modeling, the corresponding training crab samples are judged as invalid samples and removed or re-collected.
[0127] S45, Training Spectrum-Shell Error Compensation Sub-model and Shell-Meat Matrix Compensation Sub-model.
[0128] The spectrum-shell error compensation sub-model and the shell-meat matrix compensation sub-model can be one of gradient boosting decision trees, XGBoost, support vector regression, random forest regression, or multilayer perceptron.
[0129] In one specific implementation, XGBoost is used to establish two error compensation sub-models respectively.
[0130] The spectral-shell error compensation sub-model aims to minimize the sum of the weighted Huber loss and regularization term between the spectral-shell error propagation components and the spectral-shell error compensation value. ; in, The training objective function of the spectral-shell error compensation sub-model is given by: This indicates the number of training crab samples. Indicates the first The sample weights of each training crab sample. This represents the Huber loss function. Indicates the first The spectral-shell error propagation components of the training blue crab samples This represents the regularization term used to limit the complexity of the spectrum-shell error compensation sub-model.
[0131] The training objective function of the shell-meat matrix compensator sub-model is expressed as: ; in, Let represent the training objective function of the shell-meat matrix compensator submodel. Indicates the first The shell-meat matrix mapping error components of the training mud crab samples This represents the regularization term used to limit the complexity of the shell-meat matrix compensator submodel.
[0132] For the XGBoost spectral-shell error compensation sub-model or shell-meat matrix compensation sub-model, the model sequentially fits the negative gradient of the current residual loss, and so on. The update method of the wheel model is represented as follows: ; in, Indicates the first The updated model output, Indicates the first The updated model output, This represents the input features of the current error compensation sub-model. Indicates the first Each regression tree outputs a predicted value for the input features. The learning rate is represented by the number of regression trees, the maximum tree depth, the learning rate, and the regularization parameter are determined through the validation set, and the training is terminated using an early stopping rule to obtain the spectrum-shell error compensation sub-model and the shell-meat matrix compensation sub-model.
[0133] As another model implementation, the spectral-shell error compensation sub-model and the shell-meat matrix compensation sub-model can also employ gradient boosting regression trees. For any error compensation sub-model, its output can be expressed as: ; in, Indicates the current error compensation type; when the current error compensation type is spectral-shell error compensation, The corresponding supervision label is When the current error compensation type is shell-meat matrix compensation, The corresponding supervision label is , Indicates the number of regression trees. Let t be the t-th regression tree. This represents the learning rate.
[0134] Its training objective function can include the squared error between the predicted residual and the supervised residual, as well as a regression tree complexity regularization term: ; in, Indicates the number of training samples; Let represent the regularization term for the complexity of the t-th regression tree.
[0135] The regularization term can be expressed as: ; in, This represents the number of leaf nodes in the t-th regression tree; This represents the output weight of the j-th leaf node in the t-th regression tree; and This represents the regularization coefficient. The regularization term limits model complexity to reduce the risk of overfitting.
[0136] In addition to the models described above, in other specific implementations, the error compensation model may also employ a random forest regression model, a support vector regression model, a kernel ridge regression model, an artificial neural network model, or a combination of the above models. It still uses the corresponding input features as input, the corresponding error components as supervision labels, and the training objective is to reduce the difference between the error compensation value and the corresponding error components.
[0137] S46. Evaluate the error compensation model.
[0138] Root mean square error (RMSE), mean absolute error (MAE), and coefficient of determination can be used. The prediction results of heavy metal content in target edible tissues after error compensation were evaluated.
[0139] The root mean square error is expressed as: ; The mean absolute error is expressed as: ; The coefficient of determination is expressed as: ; in, This represents the average value of the reference values for heavy metal content in the target edible tissue.
[0140] The model parameters can be optimized to minimize the root mean square error between the corrected predicted heavy metal content of the target edible tissue and the reference value, and the model performance can be evaluated by combining the mean absolute error and the coefficient of determination.
[0141] S47. Perform optional analysis on the remaining cumulative error.
[0142] It should be noted that the cumulative error formed by the two-level predictions of the spectrum-shell calibration model and the shell-meat correlation model is not necessarily independent of the spectrum-shell error propagation component and the shell-meat matrix mapping error component.
[0143] To avoid repeatedly compensating for the same error, after obtaining the error compensation prediction values corresponding to the training samples using cross-validation in both the spectral-shell error compensation sub-model and the shell-meat matrix compensation sub-model, the residuals can be constructed: ; in, The spectral-shell error compensation sub-model represents the first... Cross-validation outer spectrum-shell error compensation values generated from training mud crab samples. This represents the cross-validation shell-meat matrix compensation value formed by the shell-meat matrix compensator sub-model.
[0144] The cumulative error compensation sub-model is trained only when the verification results show that the remaining residuals still have a learnable pattern; when the remaining residuals do not have a stable learnable pattern, no additional compensation sub-model is built, thereby avoiding redundant compensation.
[0145] In an implementation where a cumulative error compensation sub-model is further established, the cumulative error compensation value output by the cumulative error compensation sub-model is added to the spectrum-shell error compensation value and the shell-meat matrix compensation value to form the total error compensation value under the corresponding implementation; in the absence of establishing the cumulative error compensation sub-model, the total error compensation value is formed by adding the spectrum-shell error compensation value and the shell-meat matrix compensation value.
[0146] S5. Obtain in-situ laser-induced breakdown spectral data of the shell of the live mud crab to be tested and sample auxiliary features. Obtain the final predicted value of heavy metal content in the target edible tissue through the basic inversion path and two error compensation sub-models.
[0147] refer to Figure 8 , Figure 8 This diagram illustrates the inversion process for layering error compensation in step S5 of an embodiment of the present invention. Figure 8 As shown, step S5 specifically includes the following steps: S51. Fix the live mud crab to be tested and determine the in-situ LIBS detection point.
[0148] The live mud crab 1 to be tested is fixed by the sample adaptive clamping module 4, and the posture of the live mud crab to be tested is adjusted so that the area of the crab claw joint near the shell is exposed.
[0149] The machine vision positioning module 3 acquires images of the live blue crab 1 to be detected, identifies the area of the shell near the crab claw joint, and determines the coordinates of the detection point therein.
[0150] The transmission control module 5 adjusts the relative position between the live crab to be detected 1 and the laser focusing position according to the coordinates of the detection point, so that the detection point is aligned with the laser focusing position.
[0151] S52. Obtain the in-situ spectral characteristics, spectral quality characteristics, and sample auxiliary characteristics of the live mud crabs to be tested.
[0152] Multiple laser pulse excitations were performed at the detection point, and the plasma emission spectra generated by each laser pulse excitation were collected.
[0153] According to the corresponding spectral preprocessing rules and feature extraction rules in the model training stage, the in-situ laser-induced breakdown spectral data of the live mud crabs to be detected are processed to obtain the in-situ spectral features X and spectral quality features Q, and the comprehensive spectral quality score q is calculated based on the spectral quality features.
[0154] Obtain auxiliary features A from the live mud crab sample to be tested.
[0155] In the live prediction stage, sample information that can be directly obtained in the live state, such as growth stage, crab claw weight, whole crab weight, carapace width, and carapace length, is preferred.
[0156] When the edible tissue yield or moisture content is required in the live animal prediction stage, the corresponding estimated value can be obtained based on the pre-established non-destructive estimation model.
[0157] The edible tissue yield estimation model can use one or more of the following as inputs: whole crab weight, carapace width, carapace length, body height, sex, and growth stage; the moisture content estimation model can use one or more of the following as inputs: near-infrared spectral characteristics, ambient humidity, sample surface optical characteristics, and growth stage.
[0158] The training and liveness prediction phases use the same definitions, dimensions, and acquisition methods for auxiliary features of the samples; or the model training phase uses lossless estimates obtained in the same way as the liveness prediction phase, in order to reduce the distribution deviation caused by the different feature acquisition methods between the training and actual liveness prediction phases.
[0159] S53. Obtain preliminary predicted values of heavy metal content in target edible tissues through basic inversion path.
[0160] First, the in-situ spectral characteristics of the live mud crab to be tested are input into the spectrum-shell calibration model to obtain the predicted value of heavy metal content in the shell of the live mud crab to be tested.
[0161] The predicted heavy metal content of the shell and the auxiliary features of the sample are then input into the shell-meat association model to obtain the preliminary predicted heavy metal content of the target edible tissue.
[0162] S54. Obtain the spectrum-shell error compensation value and the shell-meat matrix compensation value respectively.
[0163] The in-situ spectral features and spectral quality features of the live mud crab to be tested are combined into spectral-shell input features and input into the spectral-shell error compensation sub-model to obtain the spectral-shell error compensation value.
[0164] The predicted heavy metal content of the shell of the live mud crab to be tested, the sample auxiliary features, and the spectral quality features are combined to form the shell-meat input features, which are then input into the shell-meat matrix compensation sub-model to obtain the shell-meat matrix compensation value.
[0165] S55. The two error compensation values are added together to form the total error compensation value. When the preliminary prediction value is lower than the corresponding reference value, the corresponding training residual is positive and the model learns positive error compensation. When the preliminary prediction value is higher than the corresponding reference value, the corresponding training residual is negative and the model learns negative error compensation. Thus, the preliminary prediction result can be corrected according to different deviation directions.
[0166] In the embodiment of further establishing the cumulative error compensation sub-model in step S47, the cumulative error compensation value output by the cumulative error compensation sub-model is also added to the total error compensation value.
[0167] S56. Adjust the confidence level of the total error compensation value based on the spectral quality of the live mud crab to be tested.
[0168] Based on the comprehensive spectral quality score of the live mud crabs to be tested Determine the confidence level adjustment coefficient The lower limit of compensation is determined based on the residual distribution of the training set or the validation set. and compensation cap .
[0169] The final predicted values for heavy metal content in the target edible tissue are expressed as follows: ; in, This represents the final predicted value of heavy metal content in the target edible tissue. This indicates the preliminary predicted value of heavy metal content in the target edible tissue. Indicates the overall spectral quality score The determined confidence level adjustment coefficient, This represents the total error compensation value, i.e. , and These represent the lower and upper limits of compensation determined based on the residual distribution of the training set or the validation set, respectively. This represents the truncation function.
[0170] The maximum value calculation is used to ensure that the final predicted value of heavy metal content in the target edible tissue is not less than zero.
[0171] When the spectral quality of the live mud crab to be tested is within the effective range of the model, corresponding error compensation is performed according to the verification results; when the spectral quality is close to the boundary of the effective range of the model, the error compensation amplitude is reduced and a low confidence mark can be output; when the spectral quality exceeds the effective range of the model, no unconstrained forced compensation is performed on the abnormal spectrum, but the in-situ laser-induced breakdown spectral data of the shell is triggered for re-acquisition or manual verification.
[0172] When reacquiring in-situ spectral data, at least one of the following can be readjusted: laser pulse energy, spectral acquisition delay time, number of laser pulses, detection point position, and posture of the live mud crab to be detected.
[0173] When detecting multiple target heavy metal elements simultaneously, a spectrum-shell calibration model, a shell-meat correlation model, and a corresponding error compensation sub-model can be established for each target heavy metal element. Alternatively, the residuals corresponding to different target heavy metal elements can be combined into a multi-output residual vector for joint modeling.
[0174] The multi-element error vector can be represented as: ; The final prediction result corresponds to a multi-element heavy metal content prediction vector, and non-negative constraints are applied to the prediction results corresponding to each target element.
[0175] When the target edible tissues are muscle tissue and hepatopancreas tissue, shell-meat correlation models and corresponding error compensation models can be established for different target edible tissues. When the target edible tissue is the whole edible tissue obtained by weighting muscle tissue and hepatopancreas tissue according to quality, the reference value and predicted value of the whole edible tissue are determined according to the aforementioned quality weighting method.
[0176] Furthermore, the present invention also provides a layered nonlinear error compensation inversion device for in-situ detection of laser-induced breakdown spectroscopy in live mud crabs.
[0177] refer to Figure 9 , Figure 9 The connection relationships of some modules in the hierarchical nonlinear error compensation inversion device according to an embodiment of the present invention are shown. For example... Figure 9 As shown, the live mud crab to be tested 1 is fixed in the sample adaptive clamping module 4. The LIBS spectral excitation acquisition module 2, the machine vision positioning module 3, and the transmission control module 5 are configured in conjunction with the sample adaptive clamping module 4. The data processing terminal 6 is communicatively connected to the corresponding modules. The hierarchical nonlinear error compensation inversion device also includes a sample parameter acquisition module, used to obtain the sample auxiliary features of the live mud crab to be tested.
[0178] The sample adaptive clamping module 4 is used to fix the live mud crab 1 to be tested and adjust the posture of the live mud crab 1 to be tested in order to expose the area of the crab claw joint adjacent to the shell of the live mud crab 1.
[0179] refer to Figure 10 , Figure 10 A schematic diagram of the sample adaptive clamping module 4 according to an embodiment of the present invention is shown. Figure 10 As shown, the sample adaptive clamping module 4 includes a support base 41, a support structure 42, a bearing platform 43, a clamping assembly 44, and a drive mechanism 45.
[0180] The support base 41 is used to install and support the carrier platform 43 and the clamping assembly 44; the support structure 42 is used to support the support base 41 and cooperate with the drive mechanism 45 to adjust the position or posture of the carrier platform 43 or the clamping assembly 44; the carrier platform 43 is used to carry the live mud crab 1 to be tested; the clamping assembly 44 is used to limit and fix the live mud crab 1 to be tested; the drive mechanism 45 is used to adjust the position or posture of the carrier platform 43 or the clamping assembly 44 to adapt to live mud crabs of different sizes and to expose the area of the crab claw joint near the shell to the laser incident path.
[0181] The sample adaptive clamping module 4 can adapt to the size differences of different sizes of mud crabs and reduce the impact of changes in the posture of live mud crabs, shell bending or displacement of the detection point position on in-situ spectral acquisition.
[0182] refer to Figure 11 , Figure 11 A schematic diagram of the machine vision positioning and transmission control structure according to an embodiment of the present invention is shown. Figure 11 As shown, the machine vision positioning module 3 includes a camera 31, a ring-shaped supplementary light source 32, and an image processor 33, while the transmission control module 5 includes a programmable logic controller 51 and an XYZ positioning platform 52.
[0183] The ring-shaped supplementary light source 32 is used to provide illumination for the machine vision acquisition process; the camera 31 is used to acquire images of the live blue crab 1 to be detected; the image processor 33 is used to process the images acquired by the camera 31, identify the area of the shell adjacent to the crab claw joint, and output the coordinates of the detection point located in the area of the shell adjacent to the crab claw joint.
[0184] The programmable logic controller 51 is used to receive the coordinates of the detection point or the corresponding control command, and control the movement of the XYZ positioning platform 52 according to the coordinates of the detection point. The XYZ positioning platform 52 is used to adjust the relative position between the live crab to be detected 1 and the laser focusing position, so that the detection point is aligned with the laser focusing position.
[0185] refer to Figure 12 , Figure 12 A schematic diagram of the LIBS spectral excitation and acquisition module according to an embodiment of the present invention is shown. Figure 12 As shown, the LIBS spectral excitation acquisition module 2 includes a pulsed laser 21, an optical focusing system 22, a detector 23, a spectrometer 24, and a digital delay generator 25.
[0186] The digital delay generator 25 is used to control the timing synchronization between the pulsed laser 21 and the spectrometer 24; the pulsed laser 21 is used to generate laser pulses; the optical focusing system 22 is used to focus the laser beam on the detection point of the live blue crab 1 to be detected, and to collect the plasma radiation light formed at the detection point; the detector 23 is used to receive the plasma emission light; the spectrometer 24 is used to split the plasma emission light and record the spectral intensity corresponding to different wavelengths; the data processing terminal 6 is used to collect and process spectral data.
[0187] The sample parameter acquisition module is used to obtain auxiliary features of the live mud crabs to be tested.
[0188] The data processing terminal 6 is connected to the machine vision positioning module 3, the transmission control module 5, the LIBS spectral excitation acquisition module 2, and the sample parameter acquisition module.
[0189] The data processing terminal 6 stores a spectrum-shell calibration model, a shell-meat correlation model, a spectrum-shell error compensation sub-model, and a shell-meat matrix compensation sub-model. It is used to perform preprocessing and feature extraction of in-situ laser-induced breakdown spectral data of the shell, obtaining in-situ spectral features and spectral quality features. The spectrum-shell calibration model is called to obtain a predicted value of heavy metal content in the shell. The shell-meat correlation model is called to obtain a preliminary predicted value of heavy metal content in the target edible tissue. The spectrum-shell error compensation sub-model is called to obtain a spectrum-shell error compensation value. The shell-meat matrix compensation sub-model is called to obtain a shell-meat matrix compensation value. The two error compensation values are added to form a total error compensation value, and the confidence level of the total error compensation value is adjusted according to the spectral quality to obtain the final predicted value of heavy metal content in the target edible tissue.
[0190] refer to Figure 13 , Figure 13 A schematic diagram of the overall structure of the hierarchical nonlinear error compensation inversion device according to an embodiment of the present invention is shown. Figure 13 As shown, the sample adaptive clamping module 4 is mounted on the moving structure corresponding to the XYZ positioning platform 52. The pulsed laser 21 is positioned towards the detection position corresponding to the sample adaptive clamping module 4. The detector 23 is used to receive the plasma emission light generated at the detection point. The spectrometer 24 is used to split the plasma emission light and record the spectral intensity corresponding to different wavelengths. The camera 31 is positioned towards the sample adaptive clamping module 4 to acquire an image of the live blue crab to be detected. The XYZ positioning platform 52 is used to adjust the relative position between the sample adaptive clamping module 4 and the laser focusing position corresponding to the pulsed laser 21.
[0191] In the actual live detection process, the sample adaptive clamping module 4 first fixes the live mud crab 1 to be detected and exposes the area of the shell near the crab claw joint; the machine vision positioning module 3 acquires the image of the live mud crab 1 to be detected and determines the detection point; the transmission control module 5 controls the movement of the XYZ positioning platform 52 according to the coordinates of the detection point, so that the detection point is aligned with the laser focusing position; the LIBS spectral excitation acquisition module 2 performs multiple laser pulse excitations at the detection point and acquires in-situ laser-induced breakdown spectral data; the sample parameter acquisition module acquires the corresponding sample auxiliary features; the data processing terminal 6 sequentially completes the acquisition of in-situ spectral features and spectral quality features, basic inversion, stratification error compensation, and spectral quality confidence adjustment to obtain the final predicted value of the heavy metal content of the target edible tissue of the live mud crab 1 to be detected.
[0192] The above method enables the inversion of heavy metal content in target edible tissue from in-situ laser-induced breakdown spectral data of live mud crab shells, and provides compensation for different errors generated in the spectrum-shell stage and the shell-meat stage.
Claims
1. A hierarchical nonlinear error compensation inversion method for in-situ detection of laser-induced breakdown spectroscopy in live mud crabs, characterized in that, include: S1. Obtain in-situ laser-induced breakdown spectral data of the shell of the training mud crab sample, reference values of heavy metal content in the shell, reference values of heavy metal content in the target edible tissue, and auxiliary features of the sample. Preprocess and extract features from the in-situ laser-induced breakdown spectral data of the shell to obtain in-situ spectral features. Determine the spectral quality features characterizing the spectral acquisition state based on the multi-pulse spectrum at the same detection point. S2. Based on the in-situ spectral characteristics and the reference value of heavy metal content in the shell, establish a spectrum-shell calibration model. Based on the reference value of heavy metal content in the shell, the reference value of heavy metal content in the target edible tissue, and the sample auxiliary characteristics, establish a shell-meat correlation model. Cascade the spectrum-shell calibration model and the shell-meat correlation model to form a basic inversion path. S3. The training mud crab samples are grouped and cross-validated according to individual mud crabs or breeding batches. The cross-validated predicted values of heavy metal content in the outer shell and the preliminary predicted values of cross-validation in the mud crab samples in the current reserved subset are obtained using the spectrum-shell calibration model and the shell-meat association model that were not trained using the current reserved subset. The total residual label is constructed based on the difference between the reference value of heavy metal content in the target edible tissue and the preliminary predicted value of cross-validation. S4. Using the reference value of the heavy metal content in the shell as an intermediate benchmark between the spectrum-shell calibration model and the shell-meat correlation model, the total residual label is decomposed into the spectrum-shell error propagation component and the shell-meat matrix mapping error component. A spectral-shell error compensation sub-model is established using the in-situ spectral features and the spectral quality features as inputs and the spectral-shell error propagation component as a supervision label. A shell-meat matrix compensation sub-model is established using the cross-validated predicted values of heavy metal content in the outer shell, the sample auxiliary features, and the spectral quality features as inputs and the shell-meat matrix mapping error component as a supervision label. S5. Obtain the in-situ laser-induced breakdown spectral data and sample auxiliary features of the shell of the live mud crab to be tested. Perform preprocessing and feature extraction on the in-situ laser-induced breakdown spectral data of the shell of the live mud crab to be tested to obtain the in-situ spectral features and spectral quality features of the live mud crab to be tested. Calculate the comprehensive spectral quality score of the live mud crab to be tested based on the spectral quality features. The preliminary predicted value of heavy metal content in the target edible tissue is obtained through the basic inversion path. The spectral-shell error compensation value and the shell-meat matrix compensation value are obtained through the spectral-shell error compensation sub-model and the shell-meat matrix compensation sub-model, respectively. The spectral-shell error compensation value and the shell-meat matrix compensation value are added to form the total error compensation value. The confidence level of the total error compensation value is adjusted according to the spectral quality of the live mud crab to be detected. The adjusted total error compensation value is then fused with the preliminary predicted value of heavy metal content in the target edible tissue to obtain the final predicted value of heavy metal content in the target edible tissue.
2. The method according to claim 1, characterized in that, In step S1, the preprocessing and feature extraction of the in-situ laser-induced breakdown spectral data of the outer shell to obtain in-situ spectral features, and the determination of spectral quality features characterizing the spectral acquisition state based on the multi-pulse spectrum at the same detection point, specifically includes: Multiple laser pulse excitations were performed at the same detection point in the shell region near the crab claw joint, and the plasma emission spectra generated by each laser pulse excitation were collected. The plasma emission spectrum is denoised, baseline corrected and normalized. One or more of the following parameters are extracted: peak intensity, peak area, peak height ratio, peak area ratio, half width at half maximum (WHM) of the target heavy metal element, adjacent continuous background intensity, intensity ratio of the target heavy metal element spectral line to the matrix element spectral line, and latent variables obtained by principal component analysis or partial least squares analysis, to obtain candidate in-situ spectral features. The candidate in-situ spectral features are screened to obtain the in-situ spectral features; The spectral quality characteristics are obtained by determining one or more of the following: signal-to-noise ratio, relative standard deviation of repeated acquisition, baseline drift, saturation pixel ratio, target feature peak integrity, spectral similarity, and laser pulse energy fluctuation. Each spectral quality index in the spectral quality characteristics is converted into a normalized quality index that is positively correlated with the spectral quality level, and the first value is calculated based on the normalized quality index. The comprehensive spectral quality score of each training crab sample is expressed as: ; in, Indicates the first The overall spectral quality score of a training blue crab sample. Indicates the first The first training sample of blue crabs Normalized quality indicators Indicates the first [unit] determined using the training set or validation set. Item quality weight, This indicates the number of spectral quality indicators involved in the calculation.
3. The method according to claim 2, characterized in that, The process of filtering the candidate in-situ spectral features to obtain the in-situ spectral features specifically includes: The saturation and missing states of the original spectral variables corresponding to each candidate in-situ spectral feature are obtained, and the repeated acquisition variation coefficient of each candidate in-situ spectral feature is obtained. Candidate in-situ spectral features whose corresponding original spectral variables are saturated, missing, or whose coefficient of variation exceeds a preset threshold due to repeated sampling are removed to obtain the in-situ spectral features to be evaluated. The in-situ spectral features to be evaluated are evaluated based on the characteristic spectral response of the target heavy metal element, the stability of the spectral intensity, the correlation between the in-situ spectral features to be evaluated and the corresponding reference value of the heavy metal content in the shell, and the collinearity among the in-situ spectral features to be evaluated. The in-situ spectral features are obtained by selecting spectral features from the in-situ spectral features to be evaluated based on the evaluation results, using at least one of correlation coefficient, mutual information, minimum redundancy maximum correlation, partial least squares variable projection importance, or recursive feature elimination, to establish the spectral-shell calibration model.
4. The method according to claim 3, characterized in that, In step S2, the establishment of a spectrum-shell calibration model based on the in-situ spectral features and the reference value of heavy metal content in the shell, the establishment of a shell-meat correlation model based on the reference value of heavy metal content in the shell, the reference value of heavy metal content in the target edible tissue, and the sample auxiliary features, and the cascading of the spectrum-shell calibration model and the shell-meat correlation model to form a basic inversion path, specifically includes: Using the in-situ spectral characteristics of the training mud crab samples as input and the reference value of the shell heavy metal content of the same training mud crab sample as the supervisory output, the spectrum-shell calibration model is established by partial least squares regression. Obtain reference values for heavy metal content in the shell, reference values for heavy metal content in the target edible tissue, and sample auxiliary features of the same training mud crab sample. Based on the reference values for heavy metal content in the shell, reference values for heavy metal content in the target edible tissue, and sample auxiliary features, establish a conditional mapping relationship between the heavy metal content in the shell and the heavy metal content in the target edible tissue to obtain the shell-meat association model. The in-situ spectral features are input into the spectrum-shell calibration model to obtain the predicted value of heavy metal content in the shell. The predicted value of heavy metal content in the shell and the sample auxiliary features are input into the shell-meat association model to obtain the preliminary predicted value of heavy metal content in the target edible tissue. The target heavy metal element includes one or more of Pb, Cd, Hg, As, and Cr; the target edible tissue includes mud crab muscle tissue, hepatopancreas tissue, or whole edible tissue obtained by mass-weighting mud crab muscle tissue and hepatopancreas tissue; the sample auxiliary characteristics include one or more of the following: mud crab body weight, carapace width, sex, growth stage, farming batch, moisture content, claw weight, edible tissue yield, and spectral acquisition environment parameters.
5. The method according to claim 4, characterized in that, In step S3, the step of grouping and cross-validating the training mud crab samples according to individual mud crabs or farming batches to obtain preliminary predicted values outside the cross-validation and constructing total residual labels specifically includes: The training samples of mud crabs are divided into K non-overlapping subsets according to the individual mud crab or the farming batch. One subset is selected as the current set aside subset, and the remaining K-1 subsets are selected as the current training subsets. In each round of cross-validation, the spectral preprocessing parameters, feature selection parameters, and feature transformation parameters are determined using only the current training subset, and the spectral-shell calibration model and shell-meat association model are trained. The spectral preprocessing parameters, feature selection parameters, and feature transformation parameters determined based on the current training subset are then applied to the current reserved subset. Using the spectral-shell calibration model and shell-meat association model that were not trained using the current reserved subset, predictions are made on the training mud crab samples in the current reserved subset to obtain the first... The cross-validation predicted values and preliminary cross-validation predicted values of heavy metal content in the outer shell of a training mud crab sample are given below: ; in, Indicates the first Preliminary predictions based on cross-validation of a training sample of blue crabs. and These respectively indicate that the first [number] was not used. Spectral-shell calibration model and shell-meat association model trained on a subset Indicates the first In-situ spectral characteristics of a training sample of blue crabs Indicates the first Auxiliary features of a training sample of blue crabs; The first step is to construct the difference between the reference value of heavy metal content in the target edible tissue and the preliminary predicted value outside the cross-validation. The total residual label of each training crab sample is represented as: ; in, Indicates the first The total residual label of each training crab sample Indicates the first The target edible tissue heavy metal content reference value for a training sample of mud crab, where K is an integer greater than 1.
6. The method according to claim 5, characterized in that, In step S4, using the reference value of the heavy metal content in the outer shell as an intermediate benchmark between the spectrum-shell calibration model and the shell-meat correlation model, and decomposing the total residual label into a spectrum-shell error propagation component and a shell-meat matrix mapping error component, specifically includes: Get the Reference values for heavy metal content in the shell of a training mud crab sample, predicted values for heavy metal content in the shell after cross-validation, reference values for heavy metal content in the target edible tissue, and auxiliary features of the sample; The spectrum-shell error propagation component is determined based on the reference value of the outer shell heavy metal content, the cross-validated predicted value of the outer shell heavy metal content, and the sample auxiliary features, and is expressed as follows: ; Based on the reference values for heavy metal content in the target edible tissue, the reference values for heavy metal content in the shell, and auxiliary features of the sample, the shell-meat matrix mapping error component is determined and expressed as follows: ; The relationship between the total residual label, the spectral-shell error propagation component, and the shell-meat matrix mapping error component is expressed as follows: ; in, Indicates the first Spectral-shell error propagation components of a training mud crab sample Indicates the first Shell-meat matrix mapping error components of a training mud crab sample Indicates the first Reference values for heavy metal content in the shells of a training sample of blue crabs. Indicates the first Cross-validation of predicted heavy metal content in the outer shell of a training sample of blue crabs. Indicates that the first [number] was not used. The shell-meat association model is trained on a subset of training crab samples.
7. The method according to claim 6, characterized in that, In step S4, the step of establishing a spectral-shell error compensation sub-model using the in-situ spectral features and the spectral quality features as inputs and the spectral-shell error propagation component as a supervision label, and establishing a shell-meat matrix compensation sub-model using the cross-validated predicted heavy metal content of the outer shell, the sample auxiliary features, and the spectral quality features as inputs and the shell-meat matrix mapping error component as a supervision label, specifically includes: The first The in-situ spectral features and spectral quality features of a training mud crab sample constitute the spectral-shell input features. The spectral-shell error propagation component As a supervisory label corresponding to the spectral-shell input features; The first The cross-validation of predicted heavy metal content in the outer shell of a training crab sample, along with sample auxiliary features and spectral quality features, constitutes the shell-meat input features. The shell-meat matrix mapping error component As a supervisory label corresponding to the shell-meat input features; The sample weights are determined based on the reference detection reliability, comprehensive spectral quality score, and sample representativeness of each training crab sample, and the sample weights are limited between a preset lower weight limit and a preset upper weight limit. Training crab samples with unstable reference detection, severely saturated in-situ spectra, or spectral quality exceeding the effective range of the model determined based on the spectral quality distribution of effective training samples are judged as invalid samples, and the invalid samples are removed or re-collected. A nonlinear mapping relationship between the spectral-shell input features and the spectral-shell error propagation components is established using one of the following: gradient boosting decision tree, XGBoost, support vector regression, random forest regression, or multilayer perceptron. This yields a spectral-shell error compensation sub-model, and the spectral-shell error compensation value output by the sub-model is expressed as follows: ; in, Indicates the first Spectral-shell error compensation values for a training sample of blue crabs. The spectrum-shell error compensation sub-model is represented. Indicates by the first The spectral-shell input features consist of in-situ spectral features and spectral quality features of a training mud crab sample; A nonlinear mapping relationship between the shell-meat input features and the shell-meat matrix mapping error components is established using one of the following: gradient boosting decision tree, XGBoost, support vector regression, random forest regression, or multilayer perceptron. This results in a shell-meat matrix compensation sub-model, whose output shell-meat matrix compensation value is expressed as follows: ; in, Indicates the first Shell-meat matrix compensation values for a training sample of blue crabs. This represents the shell-meat matrix compensator sub-model. Indicates by the first The shell-meat input features consist of cross-validation predictions of heavy metal content in the outer shell of a training mud crab sample, sample auxiliary features, and spectral quality features. When the spectral-shell error compensation sub-model uses XGBoost, the training objective is to minimize the sum of the weighted Huber loss and regularization term between the spectral-shell error propagation component and the spectral-shell error compensation value. The training objective function of the spectral-shell error compensation sub-model is expressed as: ; in, The training objective function of the spectral-shell error compensation sub-model is given by: This indicates the number of training crab samples. Indicates the first The sample weights of each training crab sample. This represents the Huber loss function. Indicates the first The spectral-shell error propagation components of the training blue crab samples This represents the regularization term used to limit the complexity of the spectrum-shell error compensation submodel; When the shell-meat matrix compensation sub-model uses XGBoost, the training objective is to minimize the sum of the weighted Huber loss and regularization term between the shell-meat matrix mapping error components and the shell-meat matrix compensation value. The training objective function of the shell-meat matrix compensation sub-model is expressed as: ; in, Let represent the training objective function of the shell-meat matrix compensator submodel. Indicates the first The shell-meat matrix mapping error components of the training mud crab samples This represents the regularization term used to limit the complexity of the shell-meat matrix compensator submodel; For the XGBoost spectral-shell error compensation sub-model or shell-meat matrix compensation sub-model, the negative gradient of the current residual loss is fitted sequentially, and the th... The update method of the wheel model is represented as follows: ; in, Indicates the first The updated model output, Indicates the first The updated model output, This represents the input features of the current error compensation sub-model. Indicates the first Each regression tree outputs a predicted value for the input features. The learning rate is represented by the number of regression trees, the maximum tree depth, the learning rate, and the regularization parameter are determined through the validation set, and the training is terminated using an early stopping rule to obtain the spectrum-shell error compensation sub-model and the shell-meat matrix compensation sub-model.
8. The method according to claim 7, characterized in that, In step S5, the confidence level of the total error compensation value is adjusted based on the spectral quality of the live mud crab to be detected, and the adjusted total error compensation value is fused with the preliminary predicted value of the heavy metal content of the target edible tissue to obtain the final predicted value of the heavy metal content of the target edible tissue. This specifically includes: The in-situ spectral characteristics and spectral quality characteristics of the live mud crab to be detected are input into the spectral-shell error compensation sub-model to obtain the spectral-shell error compensation value; The predicted heavy metal content of the shell of the live mud crab to be tested, the sample auxiliary features, and the spectral quality features are input into the shell-meat matrix compensation sub-model to obtain the shell-meat matrix compensation value. The total error compensation value is obtained by adding the spectrum-shell error compensation value to the shell-meat matrix compensation value. The confidence adjustment coefficient is determined based on the comprehensive spectral quality score of the live mud crab to be tested. The total error compensation value is then truncated and adjusted for confidence. The processed total error compensation value is then fused with the preliminary predicted value of the heavy metal content in the target edible tissue to obtain the final predicted value of the heavy metal content in the target edible tissue, expressed as follows: ; in, This represents the final predicted value of heavy metal content in the target edible tissue. This indicates the preliminary predicted value of heavy metal content in the target edible tissue. Indicates the overall spectral quality score The determined confidence level adjustment coefficient, This represents the total error compensation value. and These represent the lower and upper limits of compensation determined based on the residual distribution of the training set or the validation set, respectively. This represents the truncation function; When the spectral quality of the live mud crab to be tested exceeds the effective range of the model, the in-situ laser-induced breakdown spectral data of the shell is triggered for re-acquisition or verification.
9. A layered nonlinear error compensation inversion device for in-situ detection of laser-induced breakdown spectroscopy in live mud crabs, characterized in that, include: The sample adaptive clamping module is used to fix the live mud crab to be tested and adjust the posture of the live mud crab to be tested to expose the area of the crab claw joint adjacent to the shell of the live mud crab to be tested. The machine vision positioning module is used to acquire images of the live mud crab to be detected, identify the shell area adjacent to the crab claw joint, and output the coordinates of the detection point located in the shell area adjacent to the crab claw joint. The transmission control module is used to adjust the relative position between the live crab to be detected and the laser focusing position according to the coordinates of the detection point, so that the detection point is aligned with the laser focusing position; The LIBS spectral excitation acquisition module is used to perform multiple laser pulse excitations at the detection point and acquire in-situ laser-induced breakdown spectral data generated by each laser pulse excitation. The sample parameter acquisition module is used to acquire auxiliary features of the live mud crab to be detected. The data processing terminal is communicatively connected to the machine vision positioning module, transmission control module, LIBS spectral excitation acquisition module, and sample parameter acquisition module, respectively. The data processing terminal stores the spectrum-shell calibration model, the shell-meat correlation model, the spectrum-shell error compensation sub-model, and the shell-meat matrix compensation sub-model, and is used to preprocess and extract features from the in-situ laser-induced breakdown spectral data to obtain in-situ spectral features and spectral quality features. The in-situ spectral features are input into the spectrum-shell calibration model to obtain the predicted value of heavy metal content in the shell. The predicted value of heavy metal content in the shell and the sample auxiliary features are then input into the shell-meat association model to obtain the preliminary predicted value of heavy metal content in the target edible tissue. The in-situ spectral features and spectral quality features are input into the spectral-shell error compensation sub-model to obtain the spectral-shell error compensation value. The predicted value of heavy metal content in the shell, sample auxiliary features, and spectral quality features are input into the shell-meat matrix compensation sub-model to obtain the shell-meat matrix compensation value. The spectral-shell error compensation value and the shell-meat matrix compensation value are added to form the total error compensation value. The confidence level of the total error compensation value is adjusted according to the spectral quality of the live mud crab to be detected. The adjusted total error compensation value is then fused with the preliminary predicted value of heavy metal content in the target edible tissue to obtain the final predicted value of heavy metal content in the target edible tissue.
10. The hierarchical nonlinear error compensation inversion device according to claim 9, characterized in that, The sample adaptive clamping module, machine vision positioning module, transmission control module, and LIBS spectral excitation acquisition module specifically include: The LIBS spectral excitation acquisition module includes a pulsed laser, an optical focusing system, a detector, a spectrometer, and a digital delay generator. The digital delay generator is used to control the timing synchronization between the pulsed laser and the spectrometer. The machine vision positioning module includes a camera, a ring-shaped supplementary light source, and an image processor. The image processor is used to process the live mud crab images to be detected captured by the camera, identify the area of the shell adjacent to the crab claw joint, and output the coordinates of the detection point. The transmission control module includes a programmable logic controller and an XYZ positioning platform. The programmable logic controller is used to receive the coordinates of the detection point and control the movement of the XYZ positioning platform according to the coordinates of the detection point so that the detection point is aligned with the laser focusing position. The sample adaptive clamping module includes a support base, a support structure, a bearing platform, a clamping assembly, and a driving mechanism. The support base is used to install and support the bearing platform and the clamping assembly. The support structure is used to support the support base and cooperates with the driving mechanism to adjust the position or orientation of the bearing platform or the clamping assembly, so that the area of the crab claw joint near the shell of live mud crabs of different sizes is exposed to the laser incident path.