Fast detection of heavy metals is important to ensure the quality and safety of herbal medicines. In this study, laser-induced breakdown spectroscopy (LIBS) was applied to detect the heavy metal content (Cd, Cu, and Pb) in Fritillaria thunbergii. Quantitative prediction models were established using a back-propagation neural network (BPNN) optimized using the particle swarm optimization (PSO) algorithm and sparrow search algorithm (SSA), called PSO-BP and SSA-BP, respectively. The results revealed that the BPNN models optimized by PSO and SSA had better accuracy than the BPNN model without optimization. The performance evaluation metrics of the PSO-BP and SSA-BP models were similar. However, the SSA-BP model had two advantages: it was faster and had higher prediction accuracy at low concentrations. For the three heavy metals Cd, Cu and Pb, the prediction correlation coefficient (Rp2) values for the SSA-BP model were 0.972, 0.991 and 0.956; the prediction root mean square error (RMSEP) values were 5.553, 7.810 and 12.906 mg/kg; and the prediction relative percent deviation (RPD) values were 6.04, 10.34 and 4.94, respectively. Therefore, LIBS could be considered a constructive tool for the quantification of Cd, Cu and Pb contents in Fritillaria thunbergii.
Visible near-infrared (Vis-NIR) spectroscopy is widely used for rapid soil element detection, but calibration models are often limited by instrument-specific constraints, including varying laboratory conditions and sensor configurations. To address this, we propose a novel calibration transfer method that eliminates the conventional requirement of designating ‘master’ and ‘slave’ devices. Instead, spectral data from two spectrometers are fused to create a master spectrum, while independent spectral data serve as slave spectra. We developed an ensemble stacking model, incorporating partial least squares regression (PLSR), support vector regression (SVR), and ridge regression (Ridge) in the first layer, with BoostForest (BF) as the second layer, trained on the fused master spectrum. This model was further integrated with three calibration transfer methods: direct standardization (DS), piecewise direct standardization (PDS), and spectral space transfer (SST), to enable seamless application across slave spectra. Applied to soil total nitrogen (TN) detection, the method achieved an R2P of 0.842, RMSEP of 0.017, and RPD of 2.544 on the first slave spectrometer, and an R2P of 0.830, RMSEP of 0.018, and RPD of 2.452 on the second. These results demonstrate the method’s ability to simplify calibration processes while enhancing cross-instrument prediction accuracy, supporting robust and generalizable cross-instrument applications.