Method and device for detecting narcotics and metabolites thereof in hair based on Raman spectrum

By processing and analyzing hair samples, a spectral data matrix and response variable matrix are generated, which solves the problem of light and temperature affecting the detection results, and realizes the accuracy and reliability of Raman spectral detection.

CN120490043APending Publication Date: 2025-08-15HARBIN UNIV OF COMMERCE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510621705.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

In Raman spectroscopy, differences in light and temperature will affect signal intensity and quality, resulting in inconsistent accuracy of drug detection results.

Method used

By collecting hair samples, generating spectral data matrix and response variable matrix, analyzing the relationship matrix and weight vector, generating confidence vectors and replication matrix, outputting confidence indexes, and comparing them to determine the effectiveness of detection concentrations.

Benefits of technology

The accuracy of Raman spectroscopy detection is improved to ensure the reliability and consistency of the detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120490043A_ABST
    Figure CN120490043A_ABST
Patent Text Reader

Abstract

The invention provides a method and a device for detecting narcotics and metabolites thereof in hair based on Raman spectrum, and relates to the technical field of narcotics detection.According to the method, a hair sample is collected, a sample with a known narcotics concentration value is modulated, spectral data is collected through a Raman spectrometer, and a spectral data matrix and a response variable matrix are recorded; generating a relation matrix reflecting the relevance between the spectral data matrix and the response variable matrix, generating a confidence vector reflecting the direction relation between the response variable matrix Y and the spectral data matrix X to the maximum extent by analyzing the relevance between the weight vector and the spectral data matrix, generating a reflection matrix after reflection, and outputting a confidence index. And comparing the confidence index with a confidence threshold, and outputting whether the Raman spectrometer detection concentration is effective or not in the current environment.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application with application number 202411628831.3, filing date November 14, 2024, and the invention name at the time of application was “A method and device for detecting drugs and their metabolites in hair”. Technical Field

[0002] The present invention relates to the technical field of drug detection, and in particular to a method and device for detecting drugs and their metabolites in hair based on Raman spectroscopy. Background Art

[0003] The drug 2C-B is a synthetic hallucinogen that belongs to the phenylethylamine class of compounds. 2C-B produces hallucinogenic effects and a few physical effects, and usually appears in the form of tablets or capsules, and is sometimes used in powder form. 2C-B can cause changes in perception, visual and auditory hallucinations, enhanced color and shape perception, etc. Users may experience amplified emotions, including pleasure, excitement, or anxiety, as well as accelerated heartbeat, sweating, mild nausea, etc. At the same time, the intensity and nature of the effects of 2C-B are closely related to the dose. Higher doses may lead to more intense hallucinations and physical and mental reactions.

[0004] Raman spectrometers are often used to assist in the detection of the drug 2C-B. Raman spectroscopy is based on the phenomenon of Raman scattering. When laser light strikes a sample, most photons undergo Rayleigh scattering, but a small fraction undergoes energy changes due to interactions with the vibrational or rotational energy levels of the molecules. This is Raman scattering. By measuring the frequency shift of the Raman scattered light, information about the molecular vibrations can be obtained, allowing chemical composition to be identified. During detection, differences in light intensity and temperature can affect signal strength and quality, resulting in inconsistent test results at different temperatures and light intensities, affecting accuracy.

[0005] The above information disclosed in this Background section is only for enhancement of understanding of the background of the present disclosure and therefore it may contain information that does not form the prior art that is already known to a person of ordinary skill in the art. Summary of the Invention

[0006] The object of the present invention is to provide a method and device for detecting drugs and their metabolites in hair based on Raman spectroscopy, so as to solve the problems raised in the above background technology.

[0007] To achieve the above object, the present invention provides the following technical solutions:

[0008] A method for detecting drugs and their metabolites in hair based on Raman spectroscopy, comprising the following steps:

[0009] Step 1: Collecting sample hair and processing the sample hair;

[0010] Step 2: Collect spectral data using a Raman spectrometer and generate a spectral data matrix X and a response variable matrix Y;

[0011] Step 3: Perform correlation analysis on the spectral data matrix X and the response variable matrix Y to generate a relationship matrix C, which is used to reflect the correlation between the spectral data matrix X and the response variable matrix Y;

[0012] Step 4: Analyze the relationship matrix C to generate a weight vector V, which is used to reflect the weight coefficient of the detection sample concentration at the corresponding wavelength;

[0013] Step 5: Perform correlation analysis on the weight vector V and the spectral data matrix X to generate a confidence vector. The confidence vector is used to maximize the directional relationship between the response variable matrix Y and the spectral data matrix X.

[0014] Step 6: Perform correlation analysis on the confidence vector with the response variable matrix Y and the spectral data matrix X, respectively, to generate the response variable projection vector Q and the spectral data variable projection vector P. Furthermore, correlation analysis is performed on the response variable projection vector Q, the spectral data variable projection vector P, and the weight vector V to generate a reflection matrix B. The reflection matrix B is used to map the spectral data matrix X back to the response variable matrix Y.

[0015] Step 7: Perform correlation analysis on the reflection matrix B, the spectral data matrix X, and the response variable matrix Y to generate a confidence index ZZ. The confidence index ZZ is used to reflect the confidence level of the accuracy of the detection concentration. Set a confidence threshold, compare the confidence index ZZ with the confidence threshold, and output whether the detection concentration is valid.

[0016] Furthermore, in S1, the sample hair is rinsed with deionized water to remove surface dirt, the hair sample is placed in an ultrasonic cleaner with a frequency set to 40 kHz and a cleaning time of ten minutes to remove residual detergent, the hair sample is dried at 60 degrees Celsius for one hour, and frozen in liquid nitrogen for five minutes. The sample hair is ground using a freeze grinder, and different doses of 2CB drugs are added to each sample hair, the known concentration values are recorded, and the detection concentration values of each hair sample are detected using a Raman spectrometer.

[0017] Furthermore, the spectral data matrix X is a matrix with m rows and n columns, where m is the number of samples and n is the number of spectral wavelengths. Each item in the spectral data matrix X corresponds to the detected concentration value of the sample under different spectral wavelengths. The response variable matrix Y is a matrix with m rows and 1 column, where each item is the known concentration value of the corresponding sample.

[0018] Furthermore, correlation analysis is performed on the spectral data matrix X and the response variable matrix Y to generate the relationship matrix C, based on the following formula:

[0019] C=X T Y

[0020] Among them, X T is the transpose of the spectral data matrix X, and the relationship matrix C is used to reflect the correlation between the spectral data matrix X and the response variable matrix Y.

[0021] Furthermore, correlation analysis is performed on the relationship matrix C to generate eigenvalues based on the following formula:

[0022] det(C-εI)=0

[0023] Where I is the unit matrix, ε is the eigenvalue, and the maximum value ε among the eigenvalues is max Substitute into the formula (C-ε max I) V = 0, output V, where V is a weight vector, each of which is a weight coefficient of the detection sample concentration at the corresponding wavelength;

[0024] The correlation analysis between the weight vector V and the spectral data matrix X is performed to generate the confidence vector t, based on the formula:

[0025] t=XV

[0026] Among them, the confidence vector is used to maximize the directional relationship between the response variable matrix Y and the spectral data matrix X;

[0027] Perform correlation analysis on the confidence vector t and the response variable matrix Y to generate the response variable projection vector Q. The formula is:

[0028]

[0029] The response variable projection vector Q is used to reflect the projection of the known concentration value in the direction of the confidence vector t;

[0030] Perform correlation analysis on the confidence vector t and the spectral data matrix X to generate the spectral data variable projection vector P. The formula is as follows:

[0031]

[0032] The spectral data variable projection vector P is used to reflect the projection of the known concentration value in the direction of the confidence vector t.

[0033] Furthermore, correlation analysis is performed on the spectral data variable projection vector P, the response variable projection vector Q, and the weight vector V to generate the reflection matrix B. The formula is:

[0034] B=(P T V) -1 IQ T

[0035] The back-mapping matrix B is used to map the spectral data matrix X back to the response variable matrix Y.

[0036] Furthermore, the correlation analysis is performed on the reflection matrix B and the spectral data matrix X to generate the prediction matrix The formula is:

[0037]

[0038] For the prediction matrix Perform correlation analysis with the response variable matrix Y to generate the confidence index ZZ, based on the formula:

[0039]

[0040] in, in is the average value of known concentrations, and the confidence index ZZ is used to reflect the confidence level of the accuracy of the detected concentration.

[0041] Furthermore, the confidence threshold θ is 0.67, and the confidence index ZZ is compared with the confidence threshold θ. When ZZ≥θ, it indicates that the detected concentration can be used as a valid value, and when ZZ<θ, it indicates that the detected concentration cannot be used as a valid value.

[0042] The present invention also provides a device for detecting drugs and their metabolites in hair, which is used to perform a method for detecting drugs and their metabolites in hair, comprising:

[0043] A sample collection module is used to collect sample hair and process the sample hair;

[0044] A detection module is used to collect spectral data through a Raman spectrometer and generate a spectral data matrix X and a response variable matrix Y;

[0045] Relationship matrix analysis module, used to perform correlation analysis on the spectral data matrix X and the response variable matrix Y to generate the relationship matrix C;

[0046] The weight analysis module is used to analyze the relationship matrix C and generate the weight vector V;

[0047] Confidence analysis module, used to perform correlation analysis on the weight vector V and the spectral data matrix X to generate a confidence vector;

[0048] The echo module is used to perform correlation analysis on the confidence vector with the response variable matrix Y and the spectral data matrix X, respectively, to generate the response variable projection vector Q and the spectral data variable projection vector P, and to perform correlation analysis on the response variable projection vector Q, the spectral data variable projection vector P, and the weight vector V to generate the echo matrix B;

[0049] The comprehensive analysis module is used to perform correlation analysis on the reflection matrix B, the spectral data matrix X, and the response variable matrix Y, and generate a confidence index ZZ. The confidence index ZZ is used to reflect the confidence level of the accuracy of the detection concentration, set a confidence threshold, compare the confidence index ZZ with the confidence threshold, and output whether the detection concentration is valid.

[0050] Compared with the prior art, the present invention has the following beneficial effects:

[0051] The present invention collects hair samples and modulates samples with known drug concentration values. Spectral data is collected through a Raman spectrometer, and the spectral data matrix and the response variable matrix are entered. The data are analyzed to generate a relationship matrix reflecting the correlation between the spectral data matrix and the response variable matrix. The weight vector reflecting the weight coefficient of the detection sample concentration at the corresponding wavelength is further processed to generate a confidence vector that maximizes the directional relationship between the response variable matrix Y and the spectral data matrix X by analyzing the correlation between the weight vector and the spectral data matrix. After reflection, a reflection matrix is generated and a confidence index is output. The confidence index is compared with a confidence threshold to output whether the concentration detected by the Raman spectrometer is valid under the current environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 Schematic diagram of the overall method flow of the present invention;

[0053] Figure 2 Schematic diagram of the system flow of the present invention. DETAILED DESCRIPTION

[0054] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to specific embodiments.

[0055] It should be noted that, unless otherwise defined, the technical or scientific terms used in the present invention should have the usual meanings understood by people with ordinary skills in the field to which the present invention belongs. The "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative position relationships. When the absolute position of the object being described changes, the relative position relationship may also change accordingly.

[0056] Example:

[0057] See also Figure 1 , the present invention provides a technical solution:

[0058] A method for detecting drugs and their metabolites in hair. When detecting the drug 2C-B, a Raman spectrometer is often used for auxiliary detection. Raman spectroscopy technology is based on the Raman scattering phenomenon, that is, when a laser is irradiated on a sample, most photons will undergo Rayleigh scattering, but a small part will change energy due to interaction with the vibration or rotation energy level of the molecules. This is Raman scattering. By measuring the frequency shift of Raman scattered light, information about molecular vibrations can be obtained, thereby identifying chemical components. During detection, due to differences in light and temperature, the signal intensity and quality will be affected, resulting in inconsistent detection results at different temperatures and different light intensities, affecting the accuracy of the detection results. Therefore, the present invention performs analysis and detection before each detection and outputs an execution index reflecting the accuracy of the detection. The specific steps include:

[0059] Step 1: Collecting sample hair and processing the sample hair;

[0060] Rinse the sample hair with deionized water to remove surface dirt, place the hair sample in an ultrasonic cleaner, set the frequency to 40kHz, and clean for ten minutes to remove residual detergent. Dry the hair at 60 degrees Celsius for one hour, freeze it in liquid nitrogen for five minutes, grind the sample hair with a freezer grinder, and add different doses of 2CB drugs to each sample hair, record the known concentration values, and detect the detection concentration values of each hair sample using a Raman spectrometer.

[0061] Step 2: Collect spectral data using a Raman spectrometer and generate a spectral data matrix X and a response variable matrix Y;

[0062] The spectral data matrix X is a matrix with m rows and n columns, where m is the number of samples and n is the number of spectral wavelengths. Each item in the spectral data matrix X corresponds to the detected concentration value of the sample under different spectral wavelengths. The response variable matrix Y is a matrix with m rows and 1 column, where each item is the known concentration value of the corresponding sample.

[0063] Step 3: Perform correlation analysis on the spectral data matrix X and the response variable matrix Y to generate a relationship matrix C, which is used to reflect the correlation between the spectral data matrix X and the response variable matrix Y;

[0064] Perform correlation analysis on the spectral data matrix X and the response variable matrix Y to generate the relationship matrix C based on the following formula:

[0065] C=X T Y

[0066] Among them, X T is the transpose of the spectral data matrix X, and the relationship matrix C is used to reflect the correlation between the spectral data matrix X and the response variable matrix Y.

[0067] Step 4: Analyze the relationship matrix C to generate a weight vector V, which is used to reflect the weight coefficient of the detection sample concentration at the corresponding wavelength;

[0068] Perform correlation analysis on the relationship matrix C to generate eigenvalues based on the following formula:

[0069] det(C-εI)=0

[0070] Where I is the unit matrix, ε is the eigenvalue, and the maximum value ε among the eigenvalues is max Substitute into the formula (C-ε max I) V = 0, output V, where V is a weight vector, each of which is a weight coefficient of the detection sample concentration at the corresponding wavelength;

[0071] Step 5: Perform correlation analysis on the weight vector V and the spectral data matrix X to generate a confidence vector. The confidence vector is used to maximize the directional relationship between the response variable matrix Y and the spectral data matrix X.

[0072] The correlation analysis between the weight vector V and the spectral data matrix X is performed to generate the confidence vector t, based on the formula:

[0073] t=XV

[0074] Among them, the confidence vector is used to maximize the directional relationship between the response variable matrix Y and the spectral data matrix X;

[0075] Step 6: Perform correlation analysis on the confidence vector with the response variable matrix Y and the spectral data matrix X, respectively, to generate the response variable projection vector Q and the spectral data variable projection vector P. Furthermore, correlation analysis is performed on the response variable projection vector Q, the spectral data variable projection vector P, and the weight vector V to generate a reflection matrix B. The reflection matrix B is used to map the spectral data matrix X back to the response variable matrix Y.

[0076] Perform correlation analysis on the confidence vector t and the response variable matrix Y to generate the response variable projection vector Q. The formula is:

[0077]

[0078] The response variable projection vector Q is used to reflect the projection of the known concentration value in the direction of the confidence vector t;

[0079] Perform correlation analysis on the confidence vector t and the spectral data matrix X to generate the spectral data variable projection vector P. The formula is as follows:

[0080]

[0081] The spectral data variable projection vector P is used to reflect the projection of the known concentration value in the direction of the confidence vector t.

[0082] Perform correlation analysis on the spectral data variable projection vector P, the response variable projection vector Q, and the weight vector V to generate the reflection matrix B. The formula is:

[0083] B=(P T V) -1 IQ T

[0084] The back-mapping matrix B is used to map the spectral data matrix X back to the response variable matrix Y.

[0085] Step 7: Perform correlation analysis on the reflection matrix B, the spectral data matrix X, and the response variable matrix Y to generate a confidence index ZZ. The confidence index ZZ is used to reflect the confidence level of the accuracy of the detection concentration. Set a confidence threshold, compare the confidence index ZZ with the confidence threshold, and output whether the detection concentration is valid.

[0086] Perform correlation analysis on the reflection matrix B and the spectral data matrix X to generate the prediction matrix The formula is:

[0087]

[0088] For the prediction matrix Perform correlation analysis with the response variable matrix Y to generate the confidence index ZZ, based on the formula:

[0089]

[0090] in, in is the average value of known concentrations, and the confidence index ZZ is used to reflect the confidence level of the accuracy of the detected concentration.

[0091] The confidence threshold θ is 0.67. The confidence index ZZ is compared with the confidence threshold θ. When ZZ ≥ θ, it means that the detected concentration can be used as a valid value. When ZZ < θ, it means that the detected concentration cannot be used as a valid value.

[0092] Reference Figure 2 The present invention also provides a device for detecting drugs and their metabolites in hair, which is used to perform a method for detecting drugs and their metabolites in hair, including:

[0093] A sample collection module is used to collect sample hair and process the sample hair;

[0094] A detection module is used to collect spectral data through a Raman spectrometer and generate a spectral data matrix X and a response variable matrix Y;

[0095] Relationship matrix analysis module, used to perform correlation analysis on the spectral data matrix X and the response variable matrix Y to generate the relationship matrix C;

[0096] The weight analysis module is used to analyze the relationship matrix C and generate the weight vector V;

[0097] Confidence analysis module, used to perform correlation analysis on the weight vector V and the spectral data matrix X to generate a confidence vector;

[0098] The echo module is used to perform correlation analysis on the confidence vector with the response variable matrix Y and the spectral data matrix X, respectively, to generate the response variable projection vector Q and the spectral data variable projection vector P, and to perform correlation analysis on the response variable projection vector Q, the spectral data variable projection vector P, and the weight vector V to generate the echo matrix B;

[0099] The comprehensive analysis module is used to perform correlation analysis on the reflection matrix B, the spectral data matrix X, and the response variable matrix Y, and generate a confidence index ZZ. The confidence index ZZ is used to reflect the confidence level of the accuracy of the detection concentration, set a confidence threshold, compare the confidence index ZZ with the confidence threshold, and output whether the detection concentration is valid.

[0100] The above formulas are all dimensionless and numerical calculations. The formulas are obtained by collecting a large amount of data and performing software simulation to obtain the most recent real situation. The preset parameters in the formulas are set by technicians in this field according to actual conditions.

[0101] The above embodiments can be implemented in whole or in part by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed by hardware or software depends on the specific application and design constraints of the technical solution.

[0102] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, and may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment as needed.

[0103] The above is only a specific implementation method of the present application, but the scope of protection of the present application is not limited thereto. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed in this application, which should be covered by the scope of protection of the present application.

Claims

1. A method for detecting drugs and their metabolites in hair based on Raman spectroscopy, characterized in that: The specific steps include: S1. Collecting sample hair and processing the sample hair; S2. Collect spectral data through a Raman spectrometer and generate a spectral data matrix X and a response variable matrix Y; S3, performing correlation analysis on the spectral data matrix X and the response variable matrix Y to generate a relationship matrix C, wherein the relationship matrix C is used to reflect the correlation between the spectral data matrix X and the response variable matrix Y; S4. Analyze the relationship matrix C to generate a weight vector V, where the weight vector is used to reflect the weight coefficient of the concentration of the detection sample at the corresponding wavelength; S5. Performing a correlation analysis on the weight vector V and the spectral data matrix X to generate a confidence vector, where the confidence vector is used to maximize the directional relationship between the response variable matrix Y and the spectral data matrix X; S6. Perform correlation analysis on the confidence vector with the response variable matrix Y and the spectral data matrix X, respectively, to generate a response variable projection vector Q and a spectral data variable projection vector P. Furthermore, perform correlation analysis on the response variable projection vector Q, the spectral data variable projection vector P, and the weight vector V to generate a reflection matrix B. The reflection matrix B is used to map the spectral data matrix X back to the response variable matrix Y. S7, performing a correlation analysis on the reflection matrix B, the spectral data matrix X, and the response variable matrix Y to generate a confidence index ZZ, where the confidence index ZZ is used to reflect the confidence level of the accuracy of the detected concentration, setting a confidence threshold, comparing the confidence index ZZ with the confidence threshold, and outputting whether the detected concentration is valid; In S1, the hair samples are rinsed with deionized water to remove surface dirt, the hair samples are cleaned in an ultrasonic cleaner to remove residual detergent, dried at 60 degrees Celsius for one hour, frozen in liquid nitrogen, and ground using a cryo-grinder. Different doses of the 2CB drug are added to each hair sample, the known concentration values are recorded, and the concentration values of each hair sample are measured using a Raman spectrometer; The spectral data matrix X is a matrix with m rows and n columns, where m is the number of samples and n is the number of spectral wavelengths. Each item in the spectral data matrix X corresponds to the concentration value of the sample under different spectral wavelengths. The response variable matrix Y is a matrix with m rows and 1 column, where each item is the known concentration value of the corresponding sample. Perform correlation analysis on the spectral data matrix X and the response variable matrix Y to generate the relationship matrix C based on the following formula: C=X T Y Among them, X T is the transpose of the spectral data matrix X, and the relationship matrix C is used to reflect the correlation between the spectral data matrix X and the response variable matrix Y; The confidence threshold θ is 0.

67. The confidence index ZZ is compared with the confidence threshold θ. When ZZ ≥ θ, it means that the detected concentration can be used as a valid value. When ZZ < θ, it means that the detected concentration cannot be used as a valid value.

2. The method for detecting drugs and their metabolites in hair based on Raman spectroscopy according to claim 1, characterized in that: Perform correlation analysis on the relationship matrix C to generate eigenvalues based on the following formula: det(C-εI)=0 Where I is the unit matrix, ε is the eigenvalue, and the maximum value ε among the eigenvalues is max Substitute into the formula (C-ε max I) V = 0, output V, where V is a weight vector, each of which is a weight coefficient of the detection sample concentration at the corresponding wavelength; The correlation analysis between the weight vector V and the spectral data matrix X is performed to generate the confidence vector t, based on the formula: t=XV Among them, the confidence vector is used to maximize the directional relationship between the response variable matrix Y and the spectral data matrix X; Perform correlation analysis on the confidence vector t and the response variable matrix Y to generate the response variable projection vector Q. The formula is: The response variable projection vector Q is used to reflect the projection of the known concentration value in the direction of the confidence vector t; Perform correlation analysis on the confidence vector t and the spectral data matrix X to generate the spectral data variable projection vector P. The formula is as follows: The spectral data variable projection vector P is used to reflect the projection of the known concentration value in the direction of the confidence vector t.

3. The method for detecting drugs and their metabolites in hair based on Raman spectroscopy according to claim 2, characterized in that: Perform correlation analysis on the spectral data variable projection vector P, the response variable projection vector Q, and the weight vector V to generate the reflection matrix B. The formula is: B=(P T V) -1 IQ T The back-mapping matrix B is used to map the spectral data matrix X back to the response variable matrix Y.

4. The method for detecting drugs and their metabolites in hair based on Raman spectroscopy according to claim 3, characterized in that: Perform correlation analysis on the reflection matrix B and the spectral data matrix X to generate the prediction matrix The formula is: For the prediction matrix Perform correlation analysis with the response variable matrix Y to generate the confidence index ZZ, based on the formula: in, in is the average value of known concentrations, and the confidence index ZZ is used to reflect the confidence level of the accuracy of the detected concentration.

5. A device for detecting drugs and their metabolites in hair based on Raman spectroscopy, used to perform the method for detecting drugs and their metabolites in hair based on Raman spectroscopy according to claim 1, characterized in that: include: A sample collection module is used to collect sample hair and process the sample hair; A detection module is used to collect spectral data through a Raman spectrometer and generate a spectral data matrix X and a response variable matrix Y; Relationship matrix analysis module, used to perform correlation analysis on the spectral data matrix X and the response variable matrix Y to generate the relationship matrix C; The weight analysis module is used to analyze the relationship matrix C and generate the weight vector V; Confidence analysis module, used to perform correlation analysis on the weight vector V and the spectral data matrix X to generate a confidence vector; The echo module is used to perform correlation analysis on the confidence vector with the response variable matrix Y and the spectral data matrix X, respectively, to generate the response variable projection vector Q and the spectral data variable projection vector P, and to perform correlation analysis on the response variable projection vector Q, the spectral data variable projection vector P, and the weight vector V to generate the echo matrix B; The comprehensive analysis module is used to perform correlation analysis on the reflection matrix B, the spectral data matrix X, and the response variable matrix Y, and generate a confidence index ZZ. The confidence index ZZ is used to reflect the confidence level of the accuracy of the detection concentration, set a confidence threshold, compare the confidence index ZZ with the confidence threshold, and output whether the detection concentration is valid.

6. Use of the device for detecting drugs and their metabolites in hair based on Raman spectroscopy according to claim 5 in drug detection.