Drug terahertz absorption spectrum data generation method based on conditional diffusion
Through the terahertz spectral grayscale map generation model based on conditional diffusion, the problem of insufficient generation quality of terahertz spectral data in drug detection is solved, high-quality terahertz absorption spectral data generation is achieved, and the performance of the classification model is improved.
Patent Information
- Application Number
- CN202411817928.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-11
AI Technical Summary
The prior art has limitations in drug testing, especially in fast non-destructive testing. The quality of terahertz spectral data generation is insufficient, which affects the performance of the classification model.
A terahertz spectral grayscale map generation model based on conditional diffusion is used to generate grayscale maps to be selected for target drugs through the noise prediction module and the denoising operation module, and high-quality terahertz absorption spectral data are generated through feature similarity screening.
It improves the generation quality of terahertz spectral data in drug categories, enhances the diversity and coverage of data, and improves the performance and generalization capabilities of classification models.
Smart Images

Figure CN119811540A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method for generating terahertz absorption spectrum data, in particular to a method for generating terahertz absorption spectrum data of pharmaceutical products based on conditional diffusion. Background Art
[0002] At present, the detection methods for drug testing may include: chemical method, spectroscopy, ion mobility spectrometry, chromatography, mass spectrometry and chromatography-mass spectrometry, etc. These methods have their own advantages, but also have certain limitations, such as:
[0003] Chemical detection methods are low in cost, but it is not easy to detect drugs with low content and similar chemical structure, and the impurities they contain will affect the accuracy of the test results. They are mostly used in laboratories and cannot achieve rapid detection. X-rays have strong penetrating power and can see the shape of internal items such as packages, but drugs can only be seen in external shape under X-rays and cannot be qualitatively analyzed. In addition, X-rays have certain radiation hazards to the human body. Ion mobility spectrometry is highly sensitive to trace substances and can detect whether there are drug residues in the human body by detecting human hair, blood or urine. However, ion mobility spectrometry has low resolution and poor quantification, and can only be detected within a lower concentration range. It cannot be used for actual detection at customs ports. Chromatography and mass spectrometry are highly sensitive, but the operation is complex and costly, and are not suitable for on-site detection of drugs.
[0004] With the development of terahertz technology, terahertz waves have been widely used in the field of material detection and have achieved remarkable results. Terahertz waves usually refer to electromagnetic waves with a frequency of 0.1-10THz, a wavelength range of 30μm-3000μm, and a frequency between infrared waves and microwaves. Compared with waves in other frequency bands, terahertz waves have the characteristics of coherence, high penetration, low energy, fingerprint spectrum, strong water absorption, etc. Terahertz time-domain spectroscopy (THZ-TDS) is a common method for obtaining high signal-to-noise ratio spectral data in the terahertz frequency range.
[0005] The frequency band of terahertz waves covers the vibrational energy levels and rotational energy levels of many macromolecules. It is highly sensitive to intermolecular vibrations, especially to small differences in collective vibration modes and spatial structures. Therefore, terahertz spectroscopy can be used to distinguish substances with similar chemical compositions. Specifically, the transient, coherent and broadband characteristics of terahertz spectroscopy can be used to quickly and effectively obtain the internal molecular structure of the drug being tested and the complex interactions between molecules. At the same time, the single photon energy of terahertz waves is also low, which is harmless to the human body and will not cause electrolysis and separation of the substance being tested.
[0006] From the above description, it can be seen that compared with other spectra, terahertz waves are more suitable for rapid non-destructive testing of drugs. The frequency of terahertz wave irradiation is constantly changing, and for different drugs, drug molecules will absorb the energy of terahertz light waves of different frequencies, and produce a transition from the ground state to the excited state of the molecule at the molecular vibration or rotation energy level. The photon energy at different frequencies is absorbed, resulting in the absorption information at this frequency being higher than at other frequencies, generating a characteristic absorption peak. This characteristic absorption peak forms the fingerprint of the terahertz absorption spectrum, which can help identify different substances and facilitate subsequent identification work.
[0007] When building a classification model, sufficient data is the key to ensuring the robustness and reliability of the model performance. Large-scale data sets provide a rich source of information for the classification model, allowing the classification model to more carefully capture the subtle and recognizable feature differences between different categories. These differences are often the key to distinguishing between categories and achieving accurate classification. In addition, by increasing the diversity and coverage of data, the classification model can learn and optimize in a wider data space, thereby effectively reducing the adverse effects of noise on model performance and improving its generalization ability in complex environments.
[0008] In practical applications, the collection of terahertz spectral data requires precise calibration and adjustment of the equipment to ensure the accuracy and stability of the measurement. In addition, the laboratory environment must be strictly controlled, including precise adjustment of parameters such as light, temperature, and humidity to ensure the consistency and repeatability of the data collection process. Even for the samples to be tested, the placement, angle, and surface features must be kept consistent. Therefore, it is time-consuming and laborious to accurately and comprehensively collect a large amount of terahertz spectral data. The terahertz non-destructive testing of drugs based on classification models usually faces problems such as small amount of collected spectral data and imbalance of samples of different categories. This will restrict the performance of the classification model, and it is necessary to find a method suitable for terahertz spectral data enhancement.
[0009] At present, the methods for terahertz spectral data enhancement mainly include non-deep learning (Non-DL) methods. Non-deep learning methods introduce diversity to terahertz spectral data through a series of intuitive and easy-to-implement technical means, such as simply adding noise (such as Gaussian noise, salt and pepper noise, etc.) to simulate random errors in actual measurements; such as random offset and transformation, by randomly translating, scaling or rotating the spectral data, simulating the data deviations that may occur under different experimental conditions, while keeping the basic form of the spectrum unchanged. This method can effectively increase the spatial diversity of the data and enable the model to learn to recognize and ignore non-critical position changes; such as spectral resampling, adjusting the sampling density or sampling range of data points without changing the overall shape of the spectrum; such as feature mixing, data interpolation, etc.
[0010] The above-mentioned non-deep learning methods can improve the richness and diversity of data sets to a certain extent, but they may reduce data quality. For example, excessive addition of noise may cause data signals to be masked, especially when the noise level is close to or exceeds the signal itself, which will significantly reduce data quality and affect the accuracy of subsequent analysis. Operations such as random offsets and transformations may cause deformation of spectral data if the parameters are not set properly. This deformation may not conform to physical or chemical principles, thereby introducing distortion. Distorted data not only cannot provide useful information, but may also mislead the classification model to learn wrong features.
[0011] In addition, compared with the real terahertz spectral data, the terahertz spectral data generated by non-deep learning methods may only differ in the source method, but there is no significant difference in practical significance. This limits the classification model's in-depth understanding and effective generalization of the inherent complex structure of terahertz spectral data.
[0012] Terahertz spectral data can be generated based on deep generative models, such as generative adversarial networks (GANs) and diffusion models. Through deep network structures, high-level features and complex relationships in data can be captured and learned. These generative models can model the high-dimensional distribution of terahertz spectral data, including nonlinear relationships and implicit dependencies that are difficult to capture with traditional methods. Therefore, they are able to generate new samples that are statistically close to the distribution of real data. These samples not only have surface features similar to the original data, but also retain their inherent structure and patterns. They have the ability to learn complex data distributions, can generate realistic terahertz spectral data, and add real semantic changes, which means that the generated terahertz spectral data is not only similar to the real terahertz spectral data in appearance, but also has substantial changes in content or meaning.
[0013] At present, the research on generative models in spectral data enhancement mainly focuses on GAN networks and their variants. The design of GAN models requires precise parameter selection, otherwise the training is difficult to stabilize and mode collapse is prone to occur. These shortcomings limit the application of GAN models in downstream tasks. At the same time, the main disadvantage of CNN networks is the limitation of their local receptive field, which makes it bottleneck in processing long-range dependencies and global context information. Although the receptive field can be expanded by increasing the depth of the network, for tasks with long-term dependencies (such as time series data, video analysis, etc.), CNN networks usually require additional mechanisms (such as RNN or Transformer) to supplement the limitations of their local feature extraction.
[0014] In addition, due to its lack of ability to dynamically adjust features and adaptively generate according to the input context, CNN networks are weak in cross-modal fusion (such as combining images and text) and conditional generation tasks. In general, the expression ability of CNN networks is relatively rigid and cannot be applied to complex and dynamic tasks.
[0015] In summary, how to effectively generate terahertz spectral data for pharmaceuticals is a technical problem that needs to be solved urgently. Summary of the invention
[0016] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a method for generating terahertz absorption spectrum data of pharmaceuticals based on conditional diffusion, which can effectively realize the generation of terahertz spectrum data of pharmaceuticals and improve the generation quality of terahertz spectrum data of pharmaceuticals.
[0017] According to the technical solution provided by the present invention, a method for generating terahertz absorption spectrum data of pharmaceuticals based on conditional diffusion, the method for generating terahertz absorption spectrum data of pharmaceuticals comprises:
[0018] A terahertz spectrum grayscale image generation model based on conditional diffusion is constructed, and the terahertz spectrum grayscale image generation model is used to generate a target drug candidate grayscale image corresponding to the target drug, and a target drug candidate grayscale image set is formed based on the target drug candidate grayscale image, wherein:
[0019] When using the terahertz spectrum grayscale image generation model to generate a target drug candidate grayscale image, the target category label, target time step and initial noisy image of the target drug are loaded into the terahertz spectrum grayscale image generation model, and the terahertz spectrum grayscale image generation model is configured to perform denoising on the initial noisy image, so as to generate a target drug candidate grayscale image after denoising at the target time step, wherein the dimension of the target drug candidate grayscale image is the same as the dimension of the initial noisy image;
[0020] A target drug reference grayscale image of a target drug is provided, and the feature similarity between each target drug candidate grayscale image in the target drug candidate grayscale image set and the target drug reference grayscale image is calculated, and the feature similarity matching the feature similarity threshold is used as the target feature similarity, so as to use the target drug candidate grayscale image corresponding to the target feature pixel point as the target drug target grayscale image;
[0021] A grayscale image-spectral data conversion process is performed on the target grayscale image of each target drug to generate corresponding terahertz absorption spectrum data of the target drug after the grayscale image-spectral data conversion process.
[0022] When calculating feature similarity, we have:
[0023] SSIM(A,B)=L(A,B)*C(A,B)*S(A,B)
[0024] Among them, SSIM(A,B) is the feature similarity between the target drug candidate grayscale image and the target drug reference grayscale image, A is the target drug candidate grayscale image, B is the target drug reference grayscale image, L(A,B) is the brightness comparison feature between the target drug candidate grayscale image and the target drug reference grayscale image, C(A,B) is the contrast comparison feature between the target drug candidate grayscale image and the target drug reference grayscale image, and S(A,B) is the structure comparison feature between the target drug candidate grayscale image and the target drug reference grayscale image.
[0025] The terahertz spectrum grayscale image generation model includes a noise prediction module and a denoising operation module, wherein:
[0026] When generating a target drug candidate grayscale image, the target category label, target time step and initial noisy image are loaded into the noise prediction module, wherein the initial noisy image is used as a reference noisy image for the first noise prediction, and an inference denoising time step is generated at each denoising process based on the target time step, and thereafter, the noise prediction module is used to predict the target drug prediction noise of the reference noisy image under the target category label and each inference denoising time step;
[0027] Based on the target drug prediction noise at the current reasoning denoising time step, the denoising operation module updates the reference noisy map used in the current reasoning denoising time step to generate a reference denoised map after the update, and loads the reference denoised map into the noise prediction module to serve as the reference noisy map of the noise prediction module at the next reasoning denoising time step until the number of denoising processes experienced matches the target time step;
[0028] When the number of denoising processes experienced matches the target time step, the baseline denoising image of the current reasoning denoising time step is used as the target drug candidate grayscale image.
[0029] Randomly sample Gaussian noise that conforms to a standard normal distribution to generate an initial noisy image after random sampling;
[0030] After the target drug prediction noise is predicted, the number of inference denoising time steps is decreased until the number of inference denoising time steps is 0;
[0031] For the target drug prediction noise predicted by the noise prediction module, there are:
[0032]
[0033] Among them, t is the number of steps of the current inference denoising time step, is the target drug prediction noise at the tth inference denoising time step, x t is the reference noisy image corresponding to the tth inference denoising time step, c is the target category label, εθ (x t ,c,t) is the conditional prediction noise, T is the target time step;
[0034] When the denoising operation module updates and generates a reference denoising graph, the updating method includes subtracting the target drug prediction noise generated at the current reasoning denoising time step from the reference noisy graph used at the current reasoning denoising time step.
[0035] The noise prediction module is constructed based on MamBa Block, where:
[0036] The noise prediction module includes a feature extraction unit, a feature fusion unit, a post-processing unit, a time step processing unit and a label processing unit;
[0037] The time step processing unit is connected to the feature extraction unit, the label processing unit is connected to the feature fusion unit, and the feature extraction unit is connected to the post-processing unit through the feature fusion unit;
[0038] When generating the target drug candidate grayscale image, the reference noisy image is loaded into the feature extraction unit, the inference denoising time step is loaded into the time step processing unit, and the target category label is loaded into the label processing unit;
[0039] The time step processing unit generates feature extraction scaling offset information based on the current reasoning denoising time step, and loads the feature extraction scaling offset information into the feature extraction unit to adjust the scaling offset state of the feature extraction unit when performing feature extraction on the reference noisy image;
[0040] Based on the target category label, the label processing unit generates feature fusion scaling offset information, and loads the feature fusion scaling offset information into the feature fusion unit to adjust the scaling offset state of the feature fusion unit when performing feature fusion, and the feature fusion unit outputs a noisy image to extract fusion features;
[0041] The post-processing unit extracts fusion features from the noisy image and performs post-processing to generate target drug prediction noise after post-processing.
[0042] The feature extraction unit includes a feature extraction layer normalization layer, a feature extraction scaling offset layer, a MamBa scanning module and a feature extraction post-scaling layer connected in sequence, wherein:
[0043] A residual connection is formed between the normalization layer of the feature extraction layer and the scaling layer after feature extraction;
[0044] The time processing unit includes a time processing multilayer perceptron, which generates corresponding feature extraction scaling offset information based on the current inference denoising time step using the time processing multilayer perceptron, wherein:
[0045] The feature extraction scaling offset information generated by the time step processing unit includes the feature extraction scaling offset coefficient and the feature extraction post-scaling coefficient.
[0046] The feature extraction scaling offset coefficient is loaded into the feature extraction scaling offset layer, and the feature extraction scaling offset coefficient includes a feature extraction scaling sub-coefficient and a feature extraction offset sub-coefficient;
[0047] The post-feature extraction scaling coefficients are loaded into the post-feature extraction scaling layer.
[0048] The feature fusion unit includes a feature fusion layer normalization layer, a feature fusion scaling offset layer, a cross attention unit and a feature fusion post-scaling layer connected in sequence, wherein:
[0049] A residual connection is formed between the normalization layer of the feature fusion layer and the scaling layer after feature fusion;
[0050] The label processing unit includes a label processing multilayer perceptron, which generates corresponding feature fusion scaling offset information based on the target drug label using the label processing perceptron, wherein:
[0051] The feature fusion scaling offset information generated by the label processing unit includes a feature fusion scaling offset coefficient and a feature fusion post-scaling coefficient.
[0052] The feature fusion scaling offset coefficient is loaded into the feature fusion scaling offset layer, and the feature fusion scaling offset coefficient includes a feature fusion scaling sub-coefficient and a feature fusion scaling sub-coefficient;
[0053] The feature fusion post-scaling coefficients are loaded into the feature fusion post-scaling layer.
[0054] When constructing a terahertz spectrum grayscale image generation model, the construction method includes:
[0055] Constructing a basic model for generating a terahertz spectrum grayscale image, wherein the basic model for generating a terahertz spectrum grayscale image includes a noise prediction basic module and a denoising operation basic module;
[0056] Constructing a grayscale image generation training data set, wherein the grayscale image generation training data set includes a plurality of training samples, wherein each training sample includes a terahertz spectrum training basic grayscale image and a training drug label corresponding to the terahertz spectrum training basic grayscale image;
[0057] Configuring model training parameters for generating a basic model for a terahertz spectral grayscale image, wherein the model training parameters at least include a model training time step, so as to generate a corresponding model training denoising time step based on the model training time step;
[0058] When a training data set is generated by using a grayscale image to train a basic model for generating a terahertz spectrum image, the following steps are included:
[0059] Based on the terahertz spectrum training basic grayscale image in each training sample, a terahertz spectrum training noisy grayscale image for each training denoising time step is generated, wherein the terahertz spectrum training noisy grayscale image for the current training denoising time step is generated by adding noise to the terahertz spectrum training noisy image for the previous training denoising time step;
[0060] Loading the terahertz spectrum training noisy grayscale image, the training drug label corresponding to the terahertz spectrum training noisy grayscale image, and the corresponding model training denoising time step into the noise prediction basic module, so as to obtain the corresponding training drug prediction noise through prediction by the noise prediction basic module;
[0061] Based on the training drug prediction noise at the current model training denoising time step and the used terahertz spectrum training noisy image, the denoising operation basic module calculates the corresponding terahertz spectrum training denoised image;
[0062] Based on the terahertz spectrum training denoised image and the corresponding terahertz spectrum training noisy image, the training denoising time step loss of the training sample after the current model training denoising step is calculated;
[0063] Determine the training denoising loss for each training sample based on all training denoising time step losses;
[0064] When the model training of the terahertz spectrum grayscale image generation basic model reaches the target training state, the corresponding terahertz spectrum grayscale image generation model is generated based on the terahertz spectrum grayscale image generation basic model.
[0065] The step value of the model training time step is equal to the step value corresponding to the target time step;
[0066] The target drug label is one of the training drug labels included in the grayscale image generation training data set;
[0067] For each terahertz spectrum training noisy map used in each training denoising time step, we have:
[0068]
[0069] Among them, X k is the noisy image of terahertz spectrum training used in the kth training denoising time step, X0 is the basic grayscale image of terahertz spectrum training, σ is the random noise sampled from the Gaussian noise of the standard normal distribution added in the denoising process, ν k is the hyperparameter for the kth training denoising time step, and K is the value of the model training time step.
[0070] For each training denoising time step loss, we have:
[0071]
[0072] Among them, Loss k is the training denoising time step loss for the kth training denoising time step, σ θ (X k ,c,k) is the training drug prediction noise generated by the prediction of the kth training denoising time step, and E is the expected value.
[0073] The advantages of the present invention are as follows: based on the deep diffusion principle, a terahertz spectrum grayscale image generation model is constructed, and the generation of target drug candidate grayscale images is realized, thereby generating drug-related terahertz absorption data. Compared with traditional non-DL methods and the GAN networks that are currently used more frequently, the generated drug-related terahertz absorption data is of higher quality and has good stability during the training process.
[0074] Compared with the denoising diffusion model, the terahertz spectrum grayscale image generation model introduces additional conditional information, such as the target drug label, and solves the problem that the CNN network mainly focuses on local features and tends to ignore global features. This enables the terahertz spectrum grayscale image generation model to generate high-quality data samples that meet specific conditions, greatly improving the flexibility and controllability of the generated content, and can generate diversified outputs, avoiding the uniformity or repetitiveness that may be produced by unconditional models. These conditions can be more accurately captured and reflected in reasoning, thereby generating higher quality pharmaceutical terahertz absorption data.
[0075] The constructed terahertz spectrum grayscale image generation model pays special attention to highlighting the important local features in the data, avoiding the neglect of these features by the conditional denoising diffusion probability model, thus ensuring that key features are not missed.
[0076] The candidate grayscale images of target drugs are screened by feature similarity, and those candidate grayscale images of target drugs that are significantly different from the reference grayscale images of target drugs are eliminated, which significantly improves the quality of generated terahertz absorption spectrum data. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] Figure 1 A schematic diagram of an embodiment of the present invention for generating terahertz absorption spectrum data of pharmaceuticals.
[0078] Figure 2 A schematic diagram of an embodiment of a terahertz spectrum grayscale image generation model of the present invention.
[0079] Figure 3 A schematic diagram of an embodiment of a noise prediction module of the present invention.
[0080] Figure 4 A schematic diagram of an embodiment of the present invention for training a terahertz spectrum grayscale image generation model. DETAILED DESCRIPTION
[0081] The present invention will be further described below in conjunction with specific drawings and embodiments.
[0082] In order to effectively realize the generation of drug terahertz spectrum data and improve the generation quality of drug terahertz spectrum data, the present invention provides a method for generating drug terahertz absorption spectrum data based on conditional diffusion. Specifically, the method for generating drug terahertz absorption spectrum data includes:
[0083] A terahertz spectrum grayscale image generation model based on conditional diffusion is constructed, and the terahertz spectrum grayscale image generation model is used to generate a target drug candidate grayscale image corresponding to the target drug, and a target drug candidate grayscale image set is formed based on the target drug candidate grayscale image, wherein:
[0084] When using the terahertz spectrum grayscale image generation model to generate a target drug candidate grayscale image, the target category label, target time step and initial noisy image of the target drug are loaded into the terahertz spectrum grayscale image generation model, and the terahertz spectrum grayscale image generation model is configured to perform denoising on the initial noisy image, so as to generate a target drug candidate grayscale image after denoising at the target time step, wherein the dimension of the target drug candidate grayscale image is the same as the dimension of the initial noisy image;
[0085] A target drug reference grayscale image of a target drug is provided, and the feature similarity between each target drug candidate grayscale image in the target drug candidate grayscale image set and the target drug reference grayscale image is calculated, and the feature similarity matching the feature similarity threshold is used as the target feature similarity, so as to use the target drug candidate grayscale image corresponding to the target feature pixel point as the target drug target grayscale image;
[0086] A grayscale image-spectral data conversion process is performed on the target grayscale image of each target drug to generate corresponding terahertz absorption spectrum data of the target drug after the grayscale image-spectral data conversion process.
[0087] In view of the shortcomings of the prior art in generating terahertz absorption spectrum data of pharmaceuticals, the present invention provides a method for generating terahertz absorption spectrum data of pharmaceuticals based on conditional diffusion. The specific generation method can be referred to Figure 1 As shown by Figure 1 It can be seen that when generating terahertz absorption spectrum data for pharmaceuticals, it is necessary to first construct a terahertz spectrum grayscale image generation model. After that, the terahertz spectrum grayscale image generation model can be used to generate a candidate grayscale image of the target pharmaceutical. The terahertz spectrum grayscale image generation model and the method for constructing the terahertz spectrum grayscale image generation model will be described in detail below.
[0088] It should be noted that when using the terahertz spectrum grayscale image generation model to generate the target drug candidate grayscale image, it is necessary to load the target drug's target category label, target time step and initial noisy image into the terahertz spectrum grayscale image generation model, so that the terahertz spectrum grayscale image generation model can generate the corresponding target drug candidate grayscale image under the target category label, target time step and initial noisy image.
[0089] Generally, after loading the target drug label, target time step and initial noisy image into the terahertz spectrum grayscale image generation model once, a target drug candidate grayscale image can be generated by using the terahertz spectrum grayscale image generation model; wherein the target category label is the name of the target drug, the target time step is the number of denoising processes performed when the target drug candidate grayscale image is generated by using the terahertz spectrum grayscale image generation model, the dimension of the initial noisy image should be the same as the dimension of the target drug candidate grayscale image, and the dimension of the initial noisy image specifically refers to the image size of the initial noisy image and the initial noisy image. Figure 1 It is usually a two-dimensional grayscale image.
[0090] For the same target drug, the terahertz spectrum grayscale image generation model can generally be used to perform multiple grayscale image generation processes, wherein multiple grayscale image generation processes specifically refer to multiple loading of target category labels, target time steps and initial noisy images into the terahertz spectrum grayscale image generation model. Specifically, each grayscale image generation process will generate a corresponding target drug candidate grayscale image; through multiple target drug candidate grayscale images corresponding to the same target drug, a target drug candidate grayscale atlas set can be formed, that is, the target drug candidate grayscale atlas set should include one or more target drug candidate grayscale images.
[0091] It should be noted that when multiple grayscale images are generated, the same target category label and target time step should generally be loaded into the terahertz spectrum grayscale image generation model, but the initial noisy Figure 1 Generally speaking, the initial noisy image can be generated randomly, such as randomly sampling Gaussian noise that conforms to the standard normal distribution to generate the initial noisy image after random sampling. It can be seen that when multiple grayscale images are generated, the initial noisy image Figure 1 Generally they are not exactly the same.
[0092] In order to improve the generation quality of pharmaceutical terahertz spectral data, after generating the target drug candidate grayscale atlas, a target drug reference grayscale map of the target drug should also be provided, wherein the existing commonly used terahertz spectral detection method can be used to perform terahertz spectral detection on the target drug, and after the detection, the existing commonly used technical means can be used to generate the corresponding target drug reference grayscale map, that is, for a certain target drug, the target drug reference grayscale map of the target drug can be prepared by the existing commonly used technical means, and the method for preparing the target drug reference grayscale map will be explained below.
[0093] After providing the target drug reference grayscale image, the feature similarity between each target drug candidate grayscale image in the target drug candidate grayscale image set and the target drug reference grayscale image is calculated, and the feature similarity threshold is configured according to the type of target drug and the application scenario requirements. For example, the feature similarity threshold can be set to 0.8. Thereafter, the calculated feature similarity can be compared with the feature similarity threshold, and the desired target drug target grayscale image can be selected. Generally, for feature similarities that are not less than the feature similarity threshold, the target feature similarity can be selected, that is, when the feature similarity is not less than the feature similarity threshold, it is considered that the feature similarity matches the feature similarity threshold.
[0094] Since the feature similarity corresponds to the target drug candidate grayscale image one by one, the target drug candidate grayscale image corresponding to the target feature similarity can be selected as the target drug target grayscale image. Since there is a corresponding relationship between the grayscale image and the terahertz absorption spectrum data, the grayscale image-spectrum data conversion process can be performed on each target drug target grayscale image to generate the corresponding target drug terahertz absorption spectrum data after the grayscale image-spectrum data conversion process, and the terahertz absorption spectrum data generation of the target drug is realized at this time.
[0095] It should be noted that the grayscale image-spectral data conversion processing method can be consistent with the existing technology. One feasible method may be: first convert the target grayscale image of the target drug into a one-dimensional array, and then denormalize the converted one-dimensional array, so that the corresponding target drug terahertz absorption spectrum data can be generated after denormalization. Specifically, the method of converting the target grayscale image of the target drug into a one-dimensional array and the method of denormalizing the one-dimensional array can both adopt existing commonly used technical means, such as using a typical denormalization calculation formula for denormalization calculation, specifically:
[0096] x=x norm *(x max -x min )+x min ,
[0097] Among them, x norm is an element in the one-dimensional array to be denormalized, x max is the maximum value of the elements in the one-dimensional array, x min The minimum value of the elements in a one-dimensional array.
[0098] In one embodiment of the present invention, when calculating feature similarity, there is:
[0099] SSIM(A,B)=L(A,B)*C(A,B)*S(A,B)
[0100] Among them, SSIM(A,B) is the feature similarity between the target drug candidate grayscale image and the target drug reference grayscale image, A is the target drug candidate grayscale image, B is the target drug reference grayscale image, L(A,B) is the brightness comparison feature between the target drug candidate grayscale image and the target drug reference grayscale image, C(A,B) is the contrast comparison feature between the target drug candidate grayscale image and the target drug reference grayscale image, and S(A,B) is the structure comparison feature between the target drug candidate grayscale image and the target drug reference grayscale image.
[0101] From the above description, we can see that the target drug candidate grayscale image and the target drug reference grayscale image Figure 1 Generally, the images are two-dimensional and the corresponding dimensions are the same. The following example illustrates how to calculate the brightness comparison feature L(A, B), the contrast comparison feature C(A, B) and the structure comparison feature S(A, B).
[0102] For the target drug candidate grayscale image and the target drug reference grayscale image, we have:
[0103]
[0104] Among them, μ A is the mean value of all pixels in the target drug candidate grayscale image A, μ B is the mean value of all pixels in the target drug reference grayscale image B, NM is the number of all pixels in the target drug candidate grayscale image A and the target drug reference grayscale image B, A i is the pixel value of the i-th pixel in the target drug candidate grayscale image A, B i is the pixel value of the i-th pixel in the target drug candidate grayscale image B, η A is the standard deviation of all pixels in the target drug candidate grayscale image A, η B is the standard deviation of all pixels in the target drug reference grayscale image B, η AB is the covariance of the target drug candidate grayscale image A and the target drug reference grayscale image B.
[0105] Furthermore, when calculating the brightness comparison feature L(A, B), the contrast comparison feature C(A, B) and the structure comparison feature S(A, B), we have:
[0106]
[0107] Among them, the above C1, C2 and C3 should generally be small constants that are not 0, and can usually be selected based on the corresponding pixel value ranges of the target drug candidate grayscale image A and the target drug reference grayscale image B.
[0108] In one embodiment of the present invention, the terahertz spectrum grayscale image generation model includes a noise prediction module and a denoising operation module, wherein:
[0109] When generating a target drug candidate grayscale image, the target category label, target time step and initial noisy image are loaded into the noise prediction module, wherein the initial noisy image is used as a reference noisy image for the first noise prediction, and an inference denoising time step is generated at each denoising process based on the target time step, and thereafter, the noise prediction module is used to predict the target drug prediction noise of the reference noisy image under the target category label and each inference denoising time step;
[0110] Based on the target drug prediction noise at the current reasoning denoising time step, the denoising operation module updates the reference noisy map used in the current reasoning denoising time step to generate a reference denoised map after the update, and loads the reference denoised map into the noise prediction module to serve as the reference noisy map of the noise prediction module at the next reasoning denoising time step until the number of denoising processes experienced matches the target time step;
[0111] When the number of denoising processes experienced matches the target time step, the baseline denoising image of the current reasoning denoising time step is used as the target drug candidate grayscale image.
[0112] Figure 2 An embodiment of a terahertz spectrum grayscale image generation model is shown in the figure. As can be seen from the figure, the terahertz spectrum grayscale image generation model should include a noise prediction module and a denoising operation module. The noise prediction module is connected to the denoising operation module. The noise prediction module can be used to predict and generate target drug prediction noise, and the denoising operation module can be used to realize the operation processing in the denoising process.
[0113] It can be seen from the above description that when performing denoising, the target category label, target time step and initial noisy image should be provided, wherein the target category label, target time step and initial noisy image should be loaded into the noise prediction module. It can be seen from the above description that the target time step is the number of times the denoising process should be experienced, that is, in the process of generating a target drug candidate grayscale image, the number of times the noise prediction module should be used for noise prediction. The value of the target time step can be selected according to actual needs. For example, the target time step can be set to 1000. At this time, the noise prediction module should be used to perform 1000 noise predictions, and only after 1000 noise predictions can the terahertz spectrum grayscale image generation model be used to generate the corresponding target drug candidate grayscale image.
[0114] When the noise is predicted for the first time, the initial noisy image should be used as the baseline noisy image of the noise prediction module; in addition, the inference denoising time step for each noise prediction can be determined based on the target time step. Generally, the number of inference denoising time steps should decrease successively on the target time step until the number of inference denoising time steps is 0; if the target time step is set to 1000 as mentioned above, when the noise prediction module performs the first noise prediction, the number of inference denoising time steps should be 1000, and the number of inference denoising time steps for the second noise prediction should be 999, and so on for other situations, which will not be explained one by one here.
[0115] In the process of generating the target drug candidate grayscale image each time, the target category label loaded into the noise prediction module should remain unchanged, while the inference denoising time step and the benchmark noisy image will change, and the noise prediction state of the noise prediction module can be controlled by whether the number of inference denoising time steps is 0. If the number of inference denoising time steps is not 0, the noise prediction module should perform noise prediction based on the current target category label, inference denoising time step and benchmark noisy image, and generate the corresponding target drug prediction noise.
[0116] From the above description, it can be seen that when the noise prediction module performs the first noise prediction, the baseline noisy map should be the initial noisy map. After the first noise prediction, the denoising operation module should be used to update the baseline noisy map used for the first noise prediction, so that the updated baseline noisy map and the reduced inference denoising time step can be used for the second noise prediction.
[0117] In specific implementation, the operation processing of the denoising operation module at least includes updating the baseline noisy image using the target drug prediction noise generated by the current reasoning denoising time step prediction. For example, after the noise prediction module performs the first noise prediction and generates the corresponding target drug prediction noise, the target drug prediction noise generated by the first noise prediction is used to update the baseline noisy image used for the first noise prediction. It can be seen from the above description that the baseline noisy image used for the first noise prediction should be the initial noisy image. At this time, after the initial noisy image is updated, a baseline denoised image can be generated, that is, the first denoising of the initial noisy image is realized, and the baseline denoised image is used as the baseline noisy image for the second noise prediction by the noise prediction module; the method of updating the baseline noisy image at the remaining reasoning denoising time steps can refer to the description here, and it is updated in sequence in this way until the number of reasoning denoising time steps is 0.
[0118] In one embodiment of the present invention, for the target drug prediction noise predicted by the noise prediction module, there are:
[0119]
[0120] Among them, t is the number of steps of the current inference denoising time step, is the target drug prediction noise at the tth inference denoising time step, x t is the reference noisy image corresponding to the tth inference denoising time step, c is the target category label, ε θ (x t ,c,t) is the conditional prediction noise, T is the target time step;
[0121] When the denoising operation module updates and generates a reference denoising graph, the updating method includes subtracting the target drug prediction noise generated at the current reasoning denoising time step from the reference noisy graph used at the current reasoning denoising time step.
[0122] From the above description, the value of the number of steps t of the current reasoning denoising time step can be determined. In one embodiment of the present invention, when updating and generating the benchmark denoising image, the benchmark noisy image used in the current reasoning denoising time step can be subtracted from the target drug prediction noise generated under the current reasoning denoising time step, wherein the benchmark noisy image minus the target drug prediction noise generated under the current reasoning denoising time step specifically refers to the subtraction of the pixels at the corresponding positions of the benchmark noisy image and the target drug prediction noise. Specifically, as can be seen from the above description, when the benchmark denoising image is updated for the first time, the initial noisy image should be subtracted from the target drug prediction noise generated by the first prediction. The method of updating and generating the benchmark denoising image in other cases can refer to the description here.
[0123] From the above description, it can be seen that when the number of denoising processes experienced matches the target time step, the number of steps t of the current reasoning denoising time step should be 1. At this time, the target drug prediction noise when the number of steps t of the reasoning denoising time step is 1 is calculated according to the above method, and the target drug prediction noise is used to update the baseline noisy image used when the number of steps t of the reasoning denoising time step is 1. Thereafter, the updated baseline denoised image is used as the target drug candidate grayscale image.
[0124] In one embodiment of the present invention, the noise prediction module is constructed based on MamBa Block, wherein:
[0125] The noise prediction module includes a feature extraction unit, a feature fusion unit, a post-processing unit, a time step processing unit and a label processing unit;
[0126] The time step processing unit is connected to the feature extraction unit, the label processing unit is connected to the feature fusion unit, and the feature extraction unit is connected to the post-processing unit through the feature fusion unit;
[0127] When generating the target drug candidate grayscale image, the reference noisy image is loaded into the feature extraction unit, the inference denoising time step is loaded into the time step processing unit, and the target category label is loaded into the label processing unit;
[0128] The time step processing unit generates feature extraction scaling offset information based on the current reasoning denoising time step, and loads the feature extraction scaling offset information into the feature extraction unit to adjust the scaling offset state of the feature extraction unit when performing feature extraction on the reference noisy image;
[0129] Based on the target category label, the label processing unit generates feature fusion scaling offset information, and loads the feature fusion scaling offset information into the feature fusion unit to adjust the scaling offset state of the feature fusion unit when performing feature fusion, and the feature fusion unit outputs a noisy image to extract fusion features;
[0130] The post-processing unit extracts fusion features from the noisy image and performs post-processing to generate target drug prediction noise after post-processing.
[0131] From the above description, it can be seen that the method of generating the target drug candidate grayscale image by the terahertz spectrum grayscale image generation model is: using the implicit classification diffusion probability model (Classifier-Free) of the denoising diffusion probability model (DDPM). It is known to those skilled in the art that, at present, there are some problems when using the implicit classification diffusion probability model method to generate drug-related terahertz absorption spectrum data. For example, when the implicit classification diffusion probability model uses a CNN network, the CNN network mainly focuses on local features, but in this process it is easy to ignore global features, which is specifically manifested as: when the convolution kernel is operating, it mainly focuses on other elements around the current element, and cannot directly let the current element pay attention to other elements at a long distance. This feature limits the CNN network's ability to grasp and process overall information to a certain extent, and may have an adverse effect on tasks that require comprehensive consideration of global information.
[0132] From the above description, it can be seen that when the present invention generates terahertz absorption spectrum data of pharmaceuticals, it is necessary to first generate a grayscale image of the target pharmaceutical to be selected. When generating the grayscale image of the target pharmaceutical to be selected, it is necessary to judge the scenario based on the overall layout and the long-distance element relationship. This limitation of the CNN network may be reflected, that is, it is impossible to effectively generate a grayscale image of the target pharmaceutical to be selected corresponding to the terahertz absorption spectrum.
[0133] In one embodiment of the present invention, a terahertz spectrum grayscale image generation model is constructed based on the Mamba Block of the state space model (SSM), from which it can be seen that the problem that the CNN network in the prior art mainly focuses on local features and easily ignores the existence of global features can be solved. Specifically, when the terahertz spectrum grayscale image generation model is constructed based on the Mamba Block of the state space model (SSM), at least a noise prediction module is constructed based on the MamBa Block, wherein the noise prediction module should at least include a feature extraction unit, a feature fusion unit, a post-processing unit, a time step processing unit, and a label processing unit.
[0134] Specifically, the feature extraction unit mainly extracts features from the reference noisy image, and in the process of extracting features from the reference noisy image, the feature extraction scaling offset information generated by the time step processing unit is used to adjust the scaling offset state during feature extraction. The features extracted by the feature extraction unit are fused by the feature fusion unit, and during feature fusion, the label processing unit is used to generate feature fusion scaling offset information to adjust the scaling and offset state of the feature fusion unit during feature fusion; finally, the post-processing unit is used to post-process the fused features extracted from the noisy image output by the feature fusion unit, and the target drug prediction noise is generated after post-processing. Figure 3 The specific situation of the noise prediction module is explained.
[0135] In one embodiment of the present invention, the feature extraction unit includes a feature extraction layer normalization layer, a feature extraction scaling offset layer, a MamBa scanning module and a feature extraction post-scaling layer connected in sequence, wherein:
[0136] A residual connection is formed between the normalization layer of the feature extraction layer and the scaling layer after feature extraction;
[0137] The time processing unit includes a time processing multilayer perceptron, which generates corresponding feature extraction scaling offset information based on the current inference denoising time step using the time processing multilayer perceptron, wherein:
[0138] The feature extraction scaling offset information generated by the time step processing unit includes the feature extraction scaling offset coefficient and the feature extraction post-scaling coefficient.
[0139] The feature extraction scaling offset coefficient is loaded into the feature extraction scaling offset layer, and the feature extraction scaling offset coefficient includes a feature extraction scaling sub-coefficient and a feature extraction offset sub-coefficient;
[0140] The post-feature extraction scaling coefficients are loaded into the post-feature extraction scaling layer.
[0141] Figure 3 An embodiment of a feature extraction unit is shown in FIG. Figure 3In the figure, LM1 is the feature extraction layer normalization layer (Layer Norm), SF1 is the feature extraction scaling offset layer (Scale, Shift), MamBa Scan is the MamBa scanning module, and S1 is the feature extraction post-scaling layer (Scale). In the figure, the feature extraction layer normalization layer is connected to the feature extraction scaling offset layer, the feature extraction scaling offset layer is connected to the MamBa scanning module, the MamBa scanning module is connected to the feature extraction post-scaling layer, and the input end of the feature extraction layer normalization layer and the output end of the feature extraction post-scaling layer are both connected to the splicer Cat1, so that the splicer Cat1 can form a residual connection, wherein the splicer Cat1 mainly realizes the splicing of channels.
[0142] It should be noted that the feature extraction layer normalization layer, the feature extraction scaling offset layer, the MamBa scanning module, and the feature extraction post-scaling layer can specifically adopt the structural forms commonly used in the prior art. For details, please refer to the corresponding description of MamBa Block.
[0143] During inference, the baseline noisy image should be loaded into the feature extraction layer normalization layer to normalize the baseline noisy image using the feature extraction layer normalization layer to eliminate the distribution differences between different features. After that, the feature extraction scaling offset layer is used to perform a linear transformation on each normalized feature, and then the MamBa scanning module is used for feature extraction.
[0144] Based on the characteristics of the Mamba scanning module, it can be seen that during the inference process, the feature map output by the feature extraction scaling offset layer is first received. After the feature map is normalized in the Mamba scanning module, it is divided into two branches: one branch extracts features through the forward convolution layer, and then uses the Zigzag scan in the Mamba scanning module to perform an arrangement operation to maintain spatial continuity, then enters the forward scanning layer to process the one-dimensional sequence data to capture long-term dependencies, and finally restores the original order of the data through a reverse arrangement operation; the other branch is directly processed by linear transformation and activation function. The outputs of the two branches are added in the residual connection to promote information flow and alleviate the gradient disappearance problem; the above operations are repeated L times in the Mamba scanning module, and each layer may adopt a different arrangement strategy to enhance the model's understanding of spatial continuity. Finally, the data processed by multiple layers is used as the output of the Mamba scanning module for subsequent processing in the scaling layer after feature extraction.
[0145] From the above description, it can be seen that when the Mamba scanning module is used for feature extraction, spatial continuity can be efficiently utilized to improve performance. The Mamba scanning module adopts the existing commonly used form, and the method and process of operating in the above reasoning process can be consistent with the existing technology and will not be repeated here.
[0146] It is understandable that Figure 3 As well as the feature extraction unit shown above, during feature extraction, it can better capture and adjust the relationship between features, dig out more valuable information, and introduce residual connections. Specifically, the features processed by the MamBa scanning module and the post-feature extraction scaling layer are added to the baseline noisy map. At this time, the main information in the baseline noisy map can be retained, and it can be carefully optimized and adjusted through the operation of the MamBa scanning module, thereby achieving gradual refinement and enhancement of the features and improving the accuracy of feature extraction.
[0147] Figure 3 In the above example, MLP1 is a time processing multi-layer perceptron. When the noise prediction module is used for noise prediction, the current inference denoising time step should be loaded into the time processing multi-layer perceptron. After that, the time processing multi-layer perceptron is used to simultaneously output the feature extraction scaling sub-coefficient, the feature extraction offset sub-coefficient, and the feature extraction post-scaling coefficient. Figure 3 In the above formula, λ1 is the feature extraction scaling sub-coefficient, β1 is the feature extraction offset sub-coefficient, and δ1 is the feature extraction post-scaling coefficient. In specific implementation, the scaling coefficient in the feature extraction scaling offset layer is set to λ1 through the feature extraction scaling sub-coefficient λ1, and at the same time, the offset coefficient in the feature extraction scaling offset layer is set to β1 through the feature extraction offset sub-coefficient β1. Similarly, the scaling coefficient of the feature extraction post-scaling layer is set to δ1 through the feature extraction post-scaling coefficient δ1.
[0148] From the above description, it can be seen that when the noise prediction module performs noise prediction, the number of inference denoising time steps is different. The time processing multilayer perceptron can generate corresponding feature extraction scaling sub-coefficients, feature extraction offset sub-coefficients and feature extraction post-scaling coefficients. After that, the feature extraction unit can be scaled and offset during feature extraction so that the feature extraction module can extract features at the corresponding inference denoising time step, further improving the responsiveness of the terahertz spectrum grayscale image generation model to conditional information. It is deeply integrated with the features of the benchmark noisy image through embedding. This fusion mechanism enables the feature extraction unit to perform targeted feature extraction according to different inference denoising time steps, giving the terahertz spectrum grayscale image generation model greater flexibility and adaptability to meet diverse task requirements.
[0149] It should be noted that the time processing multilayer perceptron can adopt the structural form of the existing commonly used multilayer perceptron, such as the output configuration of the multilayer perceptron output can enable the time processing multilayer perceptron to simultaneously generate the corresponding feature extraction scaling sub-coefficient λ1, feature extraction offset sub-coefficient β1 and feature extraction post-scaling coefficient δ1 based on the inference denoising time step.
[0150] During specific implementation, when the feature extraction scaling sub-coefficient λ1 and the feature extraction offset sub-coefficient β1 are loaded into the feature extraction scaling offset layer, the scaling coefficient of the feature extraction scaling offset layer can be configured to λ1, and at the same time, the offset coefficient can be configured to β1; similarly, after the feature extraction post-scaling coefficient δ1 is loaded into the feature extraction post-scaling layer, the scaling coefficient of the feature extraction post-scaling layer can be configured to δ1.
[0151] From the above description, it can be seen that in the early stage of the inference phase, the corresponding value of the inference denoising time step is large. At this time, the feature extraction scaling sub-coefficient λ1 and the feature extraction post-scaling coefficient δ1 are large, and the feature extraction offset sub-coefficient β1 is small. At this time, the feature extraction unit mainly focuses on recovering the reference noisy image from the noise, and the scaling coefficient emphasizes the original information of the reference noisy image. As the corresponding value of the inference denoising time step gradually decreases, the feature extraction scaling sub-coefficient λ1 and the feature extraction post-scaling coefficient δ1 generated by the time-processed multi-layer perceptron decrease, so that the feature extraction unit pays more attention to noise removal and feature recovery, but the feature extraction offset sub-coefficient β1 gradually increases, helping the feature extraction unit to restore the structure and true distribution of the reference noisy image.
[0152] In one embodiment of the present invention, the feature fusion unit includes a feature fusion layer normalization layer, a feature fusion scaling offset layer, a cross attention unit and a feature fusion post-scaling layer connected in sequence, wherein:
[0153] A residual connection is formed between the normalization layer of the feature fusion layer and the scaling layer after feature fusion;
[0154] The label processing unit includes a label processing multilayer perceptron, which generates corresponding feature fusion scaling offset information based on the target drug label using the label processing perceptron, wherein:
[0155] The feature fusion scaling offset information generated by the label processing unit includes a feature fusion scaling offset coefficient and a feature fusion post-scaling coefficient.
[0156] The feature fusion scaling offset coefficient is loaded into the feature fusion scaling offset layer, and the feature fusion scaling offset coefficient includes a feature fusion scaling sub-coefficient and a feature fusion scaling sub-coefficient;
[0157] The feature fusion post-scaling coefficients are loaded into the feature fusion post-scaling layer.
[0158] Figure 3 An embodiment of a feature fusion unit is shown in FIG. Figure 3In the figure, LM2 is the feature fusion layer normalization layer (Layer Norm), SF2 is the feature fusion scaling offset layer (Scale, Shift), and S2 is the feature fusion post-scaling layer (Scale). In the figure, the feature fusion layer normalization layer is connected to the feature fusion scaling offset layer, the feature fusion scaling offset layer is connected to the cross attention unit (Cross Attention), the cross attention unit is connected to the feature fusion post-scaling layer, and the input end of the feature fusion layer normalization layer and the output end of the feature fusion post-scaling layer are both connected to the splicer Cat2 to form a residual connection using the splicer Cat2, wherein the splicer Cat2 mainly realizes the splicing of channels.
[0159] Specifically, the role of the normalization layer of the feature fusion layer may be similar to that of the normalization layer of the feature extraction layer, such as normalizing the input feature map so that the features of the feature map have a more stable performance, ensuring that the features are uniformly distributed when entering the cross-attention unit, and improving computational efficiency and stability.
[0160] The role of the feature fusion scaling offset layer is similar to that of the feature extraction scaling offset layer. The feature fusion scaling offset coefficient can be used to control the feature fusion. The post-feature fusion scaling layer is used for global scaling, and the scaling of the post-feature fusion scaling layer is controlled by the post-feature fusion scaling coefficient.
[0161] It should be noted that the feature fusion layer normalization layer, feature fusion scaling offset layer, cross attention unit and feature fusion post-scaling layer can adopt the existing commonly used new style. During inference, the Cat2 splicer can output the noisy image to extract the fusion feature. It can be understood that Figure 3 As well as the feature fusion unit shown above, feature fusion can be achieved through the cross-attention unit. Before using cross-attention for feature fusion, the feature map is normalized, scaled and offset through the feature fusion layer normalization layer and the feature fusion scaling offset layer to ensure that the feature map is in a suitable state when entering the cross-attention unit.
[0162] It should be noted that the main function of the cross-attention unit is to capture the correlation between different features, which enables the noise prediction module to generate more relevant and consistent content in different modal or multi-view contexts. After being processed by the cross-attention unit, the feature fusion scaling offset layer performs a scaling operation again, and through the residual connection, the final output of the noisy map extracts the fusion features. It can be seen that the stability and expressiveness of the information flow are further enhanced through the feature fusion unit, ensuring that the information will not lose important content during the transmission process, and can be continuously optimized and enriched.
[0163] Figure 3In the above example, MLP2 is a label processing multi-layer perceptron. When the noise prediction module is used for noise prediction, the current target drug label should be loaded into the label processing multi-layer perceptron. After that, the label processing multi-layer perceptron is used to simultaneously output the feature fusion scaling sub-coefficient, the feature fusion offset sub-coefficient, and the feature fusion post-scaling coefficient. Figure 3 In the above formula, λ2 is the feature fusion scaling sub-coefficient, β2 is the feature fusion offset sub-coefficient, and δ2 is the feature fusion post-scaling coefficient. In the specific implementation, the scaling coefficient in the feature fusion scaling offset layer is set to λ2 through the feature fusion scaling sub-coefficient λ2, and at the same time, the offset coefficient in the feature fusion scaling offset layer is set to β2 through the feature fusion offset sub-coefficient β2. Similarly, the scaling coefficient of the feature fusion post-scaling layer is set to δ2 through the feature fusion post-scaling coefficient δ2.
[0164] The label processing multilayer perceptron can generally adopt the same form as the time processing multilayer perceptron. When the label processing multilayer perceptron and the time processing multilayer perceptron adopt the same form, the label processing multilayer perceptron can refer to the description of the above-mentioned time processing multilayer perceptron, which will not be repeated here. The label processing multilayer perceptron generates the feature fusion scaling sub-coefficient λ2, the feature fusion offset sub-coefficient β2, and the feature fusion post-scaling coefficient δ2, as well as the specific functions, which can refer to the corresponding description of the time processing multilayer perceptron and the feature extraction unit, which will not be repeated here.
[0165] The fusion features extracted from the noisy image output by the splicer Cat2 should be post-processed by a post-processing unit in order to generate target drug prediction noise. In one embodiment of the present invention, the post-processing unit should generally include a post-processing layer normalization layer, a post-processing linear layer and a post-processing Reshap layer connected in sequence, wherein the fusion features extracted from the noisy image are processed by the post-processing layer normalization layer, the post-processing linear layer and the post-processing Reshap layer in sequence, that is, the post-processing layer normalization layer is connected to the output end of the splicer Cat2, and the post-processing Reshap layer serves as the output layer of the noise prediction module, that is, the target drug prediction noise can be output through the post-processing Reshap layer. Figure 3 The connection between the post-processing unit and the feature fusion unit is not shown in the figure. For specific connection conditions, please refer to the description here.
[0166] It should be noted that the post-processing layer normalization layer, post-processing linear layer, and post-processing Reshap layer can all adopt existing commonly used forms. Among them, the post-processing layer normalization layer is mainly used to normalize the fusion features extracted from the noisy image to improve the stability in the subsequent processing process; the post-processing linear layer is mainly used to adjust the feature dimension, distribution, etc., and the post-processing Reshap layer is mainly used to adjust the features to a format that meets the requirements, that is, the target drug prediction noise can meet the requirements through post-processing Reshap.
[0167] In addition, the denoising operation module can adopt an existing commonly used form, which is based on the process of completing the above-mentioned denoising operation, and will not be repeated here.
[0168] In one embodiment of the present invention, when constructing a terahertz spectrum grayscale image generation model, the construction method includes:
[0169] Constructing a basic model for generating a terahertz spectrum grayscale image, wherein the basic model for generating a terahertz spectrum grayscale image includes a noise prediction basic module and a denoising operation basic module;
[0170] Constructing a grayscale image generation training data set, wherein the grayscale image generation training data set includes a plurality of training samples, wherein each training sample includes a terahertz spectrum training basic grayscale image and a training drug label corresponding to the terahertz spectrum training basic grayscale image;
[0171] Configuring model training parameters for generating a basic model for a terahertz spectral grayscale image, wherein the model training parameters at least include a model training time step, so as to generate a corresponding model training denoising time step based on the model training time step;
[0172] When a training data set is generated by using a grayscale image to train a basic model for generating a terahertz spectrum image, the following steps are included:
[0173] Based on the terahertz spectrum training basic grayscale image in each training sample, a terahertz spectrum training noisy grayscale image for each training denoising time step is generated, wherein the terahertz spectrum training noisy grayscale image for the current training denoising time step is generated by adding noise to the terahertz spectrum training noisy image for the previous training denoising time step;
[0174] Loading the terahertz spectrum training noisy grayscale image, the training drug label corresponding to the terahertz spectrum training noisy grayscale image, and the corresponding model training denoising time step into the noise prediction basic module, so as to obtain the corresponding training drug prediction noise through prediction by the noise prediction basic module;
[0175] Based on the training drug prediction noise at the current model training denoising time step and the used terahertz spectrum training noisy image, the denoising operation basic module calculates the corresponding terahertz spectrum training denoised image;
[0176] Based on the terahertz spectrum training denoised image and the corresponding terahertz spectrum training noisy image, the training denoising time step loss of the training sample after the current model training denoising step is calculated;
[0177] Determine the training denoising loss for each training sample based on all training denoising time step losses;
[0178] When the model training of the terahertz spectrum grayscale image generation basic model reaches the target training state, the corresponding terahertz spectrum grayscale image generation model is generated based on the terahertz spectrum grayscale image generation basic model.
[0179] It can be understood that when constructing a terahertz spectrum grayscale image generation model, a terahertz spectrum grayscale image generation basic model should be constructed first. Therefore, the terahertz spectrum grayscale image generation model is an untrained model, and the terahertz spectrum grayscale image generation model is a trained model. It can be seen that the situation of the terahertz spectrum grayscale image generation basic model should be the same as that of the terahertz spectrum grayscale image generation model. Therefore, the terahertz spectrum grayscale image generation basic model includes a noise prediction basic module and a denoising operation basic module. The noise prediction basic module and the denoising operation basic module can refer to the corresponding descriptions of the above-mentioned noise prediction module and the denoising operation module, which will not be repeated here.
[0180] In order to meet the training requirements of the basic model for generating terahertz spectrum grayscale images, a grayscale image generation training data set should be constructed. The grayscale image generation training data set should include several training samples, each training sample includes a terahertz spectrum training basic grayscale image and a training drug label corresponding to the terahertz spectrum training basic grayscale image. In addition, when constructing the grayscale image generation training data set, it should be based on multiple types of training drugs. At this time, the number of training drug labels in the grayscale image generation training data set should be consistent with the type of training drugs. Generally, multiple different terahertz spectrum training basic grayscale images should be generated using each training drug.
[0181] In specific implementation, the target drug label is one of the training drug labels contained in the grayscale image generation training data set. Therefore, when constructing the terahertz spectrum grayscale image generation model, the loaded target drug label should correspond to the name of a training drug. When the drug corresponding to the current drug label does not belong to one of the training samples, it will result in the inability to generate the target drug candidate grayscale image, or the generated target drug candidate grayscale image is of poor quality and difficult to meet the actual application needs.
[0182] When training the basic model for generating terahertz spectral grayscale images, the model training parameters should generally be configured, such as at least configuring the model training time step. In specific implementation, the step value of the model training time step should preferably be equal to the step value corresponding to the target time step. As described above, the model training time step can be set to 1000. In addition, the number of iterations, batch size, and learning rate should also be set. Specifically, the number of iterations can be set to 10000, the batch size can be set to 32, and the learning rate can be fixed to 8*10 -5, the specific meanings of the number of iterations, batch size, and learning rate can be consistent with the existing technology. For example, when the batch size is 32, it specifically means that 32 training samples can be loaded into the basic model for generating terahertz spectrum grayscale images at one time. When the number of iterations is 10,000, it means that the basic model for generating terahertz spectrum grayscale images is trained for 10,000 generations, wherein all training samples in the grayscale image generation training data set are used for model training, and one generation of training is completed, which is specifically consistent with the existing technology and will not be repeated here.
[0183] From the above description, it can be seen that the Hertz spectrum grayscale image generation model is based on the principle of the implicit classification diffusion probability model. Therefore, when training the basic model for generating the Hertz spectrum grayscale image, two processes of forward diffusion and reverse diffusion should be included. Among them, the forward diffusion process is a fixed Markov chain process. The main purpose is to gradually "destroy" or "disrupt" the basic grayscale image of the terahertz spectrum training to an easy-to-handle distribution, usually an isotropic Gaussian normal distribution.
[0184] During the forward diffusion process, Gaussian noise is gradually added to the basic grayscale image of terahertz spectrum training through a series of time steps (or diffusion steps). The mean and variance of the noise added in each model training denoising time step can be set in advance. At this time, the predictability and controllability of the forward diffusion process can be ensured.
[0185] The reverse diffusion process is a process opposite to the forward diffusion process, and its purpose is to recover the basic grayscale image of terahertz spectrum training from the noisy image. However, since the forward diffusion process is random and information is gradually lost during the diffusion process, it is impossible to directly reverse this process. Therefore, the reverse diffusion process relies on the terahertz spectrum grayscale image generation basic model to predict the noise that needs to be removed at each model training denoising time step, that is, it is necessary to predict and generate the training drug prediction noise.
[0186] From the above description, it can be seen that the process of forward diffusion is an approximate posterior estimation modeled by a Markov chain. In this process, Gaussian noise is gradually added to the basic grayscale image of terahertz spectrum training. After the basic grayscale image of terahertz spectrum training is gradually added with Gaussian noise, the noisy basic grayscale image of terahertz spectrum training will be converted into a Gaussian distribution N(0, I), where I represents a unit matrix with the same dimension as the input sample. The mean and standard deviation of the Gaussian noise added to each model training denoising time step should be set in advance, such as the standard deviation of the Gaussian noise can be set by hyperparameters, thereby configuring the mean and standard deviation of the Gaussian noise added to each model training denoising time step.
[0187] At each model training denoising time step, Gaussian noise is gradually added to the terahertz spectrum training basic grayscale image according to the following formula. In one embodiment of the present invention, for the terahertz spectrum training noisy image used in each training denoising time step, there is:
[0188]
[0189] Among them, X k is the noisy image of terahertz spectrum training used in the kth training denoising time step, X0 is the basic grayscale image of terahertz spectrum training, σ is the random noise sampled from the Gaussian noise of the standard normal distribution added in the denoising process, ν k is the hyperparameter for the kth training denoising time step, and K is the value of the model training time step.
[0190] In specific implementation, at each denoising training time step, the terahertz spectrum training noisy image of the previous denoising training time step is first subjected to denoising, and then the terahertz spectrum grayscale image is used to generate the basic model to denoise the terahertz spectrum training noisy image after the current denoising. According to the above description of the denoising process, the corresponding expression of the terahertz spectrum training noisy image used in each denoising training time step can be obtained.
[0191] From the above description, we can see that the dimension of the noise σ is consistent with the dimension of the basic grayscale image X0 of the terahertz spectrum training, and the hyperparameter ν of the kth training denoising time step is k After determination, the corresponding α can be obtained k , and then the corresponding Thus, the terahertz spectrum training noise map X used in the kth training denoising time step can be obtained k .
[0192] In specific implementation, the hyperparameter ν of the kth training denoising time step k It can be determined in the following ways, one feasible way is: Among them, ν0 is the initial reference noise, and the reference noise ν0 can generally be taken as 0.0001, ν max is the maximum reference noise, the maximum reference noise ν max The general value is 0.02. During model training, the value of the training denoising time step gradually increases from 1 to the value K of the model training time step.
[0193] From the above description, it can be seen that the reverse diffusion is a joint distribution, which estimates the Gaussian distribution of noise and iteratively removes noise. Since it is necessary to estimate the current training denoising time step and the training drug prediction noise under the current training denoising time step, the conditional distribution can be learned through the reverse diffusion process without modifying the forward diffusion process, so as to ensure that the basic model for generating terahertz spectrum grayscale images can sample high-quality samples from the data distribution conditioned on the training drug labels, and these samples maintain a high correlation with the training drug labels while maintaining the high fidelity of the basic grayscale images of terahertz spectrum training.
[0194] By loading the terahertz spectrum training noisy grayscale image, the kth training denoising time step and the training drug label into the noise prediction basic module, the training drug prediction noise can be obtained through the noise prediction basic module. Thereafter, the denoising operation basic module calculates the corresponding terahertz spectrum training denoising image. The method and process of calculating the corresponding terahertz spectrum training denoising image can refer to the above description.
[0195] In the back diffusion process, in one embodiment of the present invention, for each training denoising time step loss, there is:
[0196]
[0197] Among them, Loss k is the training denoising time step loss for the kth training denoising time step, σ θ (X k ,c,k) is the training drug prediction noise generated by the prediction of the kth training denoising time step, and E is the expected value.
[0198] Specifically, the training drug prediction noise σ generated by the kth training denoising time step prediction is θ (X k ,c,k), which can be obtained through the output of the noise prediction basic module, σ is the standard deviation added in the denoising process, and λ k Noise, then, the expected calculation method can be used to obtain the training denoising time step loss Loss of the kth training denoising time step k It can be understood that the same technical approach can be used to obtain the training loss of each training sample at the model training time step K, and then the model training loss of all training samples after one generation of training can be obtained.
[0199] Based on the model training loss, the noise prediction basic module can be updated in reverse until the target training state is reached. It should be noted that when the model training loss tends to be stable or reaches the set number of iterations, the target training state is reached. According to the method of reaching the target training state, the target noise prediction basic module can be selected and determined in a manner commonly used in the field of this technology, and configured as a noise prediction module, and then a terahertz spectrum grayscale image generation model can be generated.
[0200] During specific implementation, the target drug reference grayscale image and the basic grayscale image for terahertz spectrum training can be prepared using the same existing method. The specific generation method is described below by taking the preparation of the target drug reference grayscale image as an example.
[0201] In one embodiment of the present invention, terahertz spectrum processing is performed on a target drug, and an absorption spectrum characteristic diagram of the target drug is generated, including:
[0202] Performing terahertz time-domain spectral transmission processing on the target drug to obtain a terahertz spectral reference signal and a target drug terahertz spectral signal corresponding to the target drug;
[0203] Preprocessing the terahertz spectrum reference signal and the target drug terahertz spectrum signal to generate a terahertz spectrum reference target signal and a target drug terahertz spectrum target signal respectively after the preprocessing;
[0204] Calculate and generate a target absorption coefficient of a target drug based on a terahertz spectrum reference target signal and a terahertz spectrum target signal of a target drug;
[0205] Based on the target absorption coefficient of the target drug, an absorption spectrum characteristic graph of the target drug is generated.
[0206] In specific implementation, the target drug can be subjected to terahertz time-domain spectroscopy transmission processing in an existing commonly used manner, so that after the terahertz time-domain spectroscopy transmission processing, a terahertz spectroscopy reference signal and a target drug terahertz spectroscopy signal corresponding to the target drug can be obtained. The following example illustrates the method of subjecting the target drug to terahertz time-domain spectroscopy transmission processing. A feasible method is: providing a terahertz time-domain spectrometer (THz-TDS), and when the terahertz time-domain spectrometer is detected to determine that the terahertz time-domain spectrometer is working normally, the target drug can be subjected to terahertz time-domain spectroscopy transmission processing. Specifically, the terahertz time-domain spectrum of the air is first collected. At this time, the target drug is not placed in the light beam path of the terahertz time-domain spectrometer, and a terahertz spectroscopy reference signal is formed after the collection; thereafter, the target drug is placed in the light path of the terahertz time-domain spectrometer, and the corresponding terahertz spectroscopy signal of the target drug can be collected using the terahertz time-domain spectrometer.
[0207] It should be noted that the terahertz time-domain spectrometer can use existing commonly used equipment, such as a portable fiber-coupled terahertz spectrometer with dual probes. At this time, the central wavelength of the light wave emitted by the portable fiber-coupled terahertz spectrometer is 1550nm, the spectrum range is 0.1-3THz, the dynamic range in transmission mode is greater than 70db, the fast scanning time is 0-320ps, and the time resolution is 0.1ps. It is understandable that the specific method of processing the target drug through terahertz time-domain spectroscopy transmission and generating the terahertz spectral reference signal and the target drug terahertz spectral signal can be consistent with the existing ones.
[0208] In order to obtain the absorption spectrum characteristic diagram of the target drug, in one embodiment of the present invention, after obtaining the terahertz spectrum signal and the target drug terahertz spectrum signal, the terahertz spectrum reference signal and the target drug terahertz spectrum signal need to be preprocessed respectively, wherein after the terahertz spectrum reference signal is preprocessed, a terahertz spectrum reference target signal can be generated, and when the terahertz spectrum signal of the target drug is preprocessed, a terahertz spectrum target signal of the target drug can be obtained. Specifically, the terahertz spectrum reference signal and the target drug terahertz spectrum signal are preprocessed mainly to extract useful information and improve data quality, so as to improve the accuracy of identifying and classifying the target drug.
[0209] In specific implementation, the methods for preprocessing the terahertz spectrum reference signal and the target drug terahertz spectrum signal are the same. Of course, the methods for preprocessing the terahertz spectrum reference signal and the target drug terahertz spectrum signal can also be different. The specific methods can be selected according to needs, so as to achieve the extraction of the required information. The following takes the preprocessing of the target drug terahertz spectrum signal as an example to explain the specific preprocessing method and process.
[0210] In one embodiment of the present invention, the preprocessing of the terahertz spectrum signal of the target drug includes:
[0211] Searching and determining a target peak of a terahertz spectrum signal of a target drug, and configuring a target processing window that matches the terahertz spectrum signal of the target drug based on the searched and determined target peak;
[0212] Generate a target drug mapping spectrum signal based on the target processing window and the target drug terahertz spectrum signal;
[0213] The target drug mapping spectrum signal is dimensionally matched based on a preset target dimension to generate a target drug terahertz spectrum target signal after the dimension matching process.
[0214] For a specific target drug terahertz spectrum signal, the target peak of the target drug terahertz spectrum signal can be searched and determined, wherein the existing commonly used technical means can be used to realize the peak search of the target drug terahertz spectrum signal, such as defining the peak search conditions, and then searching for the peak that meets the peak search conditions. Generally, the peak search conditions may include peak significance, peak height and / or peak distance, wherein the peak significance specifically refers to the relative height difference between the height of a peak and the corresponding surrounding estimates, and the peak significance can be used to filter out those peaks that are not significant enough compared with the surrounding data, the greater the significance, the more prominent the peak, the peak height specifically refers to the absolute height threshold of the peak, that is, when the height of a peak is greater than or equal to the peak height, the current sampling point will be regarded as a peak; the peak distance specifically refers to the minimum distance between peaks, and the peak distance can avoid detecting multiple peaks that are too close, and also prevent repeated detection of peaks that are too close.
[0215] In specific implementation, according to the category of the target drug and the target drug terahertz spectrum signal of the target drug, the specific peak search conditions can be set with reference to the above description, and the specific conditions are based on whether the peak search of the target drug terahertz spectrum signal can be satisfied. After the search, the target peak value can be obtained. In one embodiment of the present invention, the target peak value can be the maximum peak value of the target terahertz spectrum signal, that is, the peak value with the largest amplitude. In addition, when no peak value is detected based on the peak search condition, or the selected peak index is out of range, a prompt of a search error is output.
[0216] After the target peak is searched, a target processing window needs to be configured, wherein the target processing window can be a commonly used window function, and the target region in the terahertz spectrum signal of the target drug can be extracted by using the target processing window, and the target region is also the region of interest. The following uses the Tukey window as a reference and generates a target processing window as an example to illustrate the specific configuration method and process of the target processing window of the present invention.
[0217] Specifically, the Tukey window is a window function commonly used in signal processing. It combines the characteristics of a rectangular window and a cosine window and has a smooth transition region. When generating a target processing window based on the Tukey window, it is necessary to set the window length of the configured Tukey window. Among them, the window length of the Tukey window can be: window parameter / time interval between adjacent data points in the signal, and then round the result, that is, window_size = int(window_params / time_interval), where window_size is the window length, window_params is the window parameter, time_interval is the time interval between adjacent data points in the signal, and int is the rounding operation. Specifically, the window parameter can be selected according to actual needs; the time interval between adjacent data points in the signal, that is, the time interval between adjacent data points in the terahertz spectral signal of the target drug, that is, the sampling period of the terahertz spectral signal of the target drug. Therefore, the time interval between adjacent data points in the signal can be determined according to the category of the target drug and the sampling period during the terahertz time-domain spectral transmission processing using the terahertz time-domain spectrometer.
[0218] After setting the window length of the Tukey window in the above manner, the Tukey basic window can be configured. When configuring the Tukey basic window, it is necessary to configure the window start parameters. Among them, the window start parameters include the peak left shift parameter and / or the peak right shift parameter. The peak left shift parameter specifically refers to the offset of the starting point of the Tukey basic window relative to the target peak, and the peak right shift parameter specifically refers to the offset of the ending point of the Tukey basic window relative to the target peak. The target peak should be within the main region of the Tukey basic window. Figure 3 The "Ji" - shaped area in the figure is the Tukey basic window. It can be seen from the figure that the characteristics of the Tukey basic window are: flat in the middle and gradually transitioning to zero on both sides; the value in the flat area in the middle of the Tukey basic window remains a constant 1; that is, the flat area in the middle is the main region of the Tukey basic window, and the target peak should be located in the flat area in the middle.
[0219] It should be noted that for the transition areas on both sides of the middle flat area, the width of the transition area can be controlled by the γ parameter (also called taper fraction or taper ratio). The γ parameter is a value between 0 and 1, which specifies the percentage of the transition area in the entire window length. A larger α value means a wider transition area and a shorter middle flat part; a smaller γ value means a narrower transition area and a longer middle flat part. In a feasible embodiment: the γ parameter can be set to 0.25. At this time, the middle flat area accounts for 50%, and the transition areas on both sides of the flat area each account for 25%. In specific implementation, the window start parameter can be selected according to the situation of the terahertz spectrum signal of the target drug. It can be seen from the above description that the selected window start parameter is based on the ability to effectively extract the target area.
[0220] It can be seen from the above description that the dimension of the Tukey basic window is lower than the dimension of the target drug terahertz spectrum signal, that is, the data length of the Tukey basic window is lower than the data length of the target drug terahertz spectrum signal. At this time, the Tukey basic window needs to be filled with data. After the data is filled, the Tukey target window can be formed. The Tukey target window is also the above-mentioned target processing window. In specific implementation, after the Tukey basic window is filled with data, the data length of the Tukey target window should be consistent with the data length of the target drug terahertz spectrum signal. A feasible data filling method can be: fill the starting point and end point of the Tukey basic window with a value of 0.00001; of course, other data filling methods can also be used, which can be selected according to needs, and will not be listed here one by one.
[0221] The above provides an embodiment of using a Tukey window to form a target processing window. After the target processing window is formed, a target drug mapping spectrum signal can be generated based on the target processing window and the target drug terahertz spectrum signal. In one embodiment of the present invention, when generating a target drug mapping spectrum signal, the target processing window and the target drug terahertz spectrum signal are dot-multiplied to generate a target drug mapping spectrum signal after dot multiplication;
[0222] When performing dimension matching processing on the target drug mapping spectral signal, it includes truncation processing or filling processing on the target drug mapping spectral signal.
[0223] From the above description, it can be seen that the target processing window and the target drug terahertz spectrum signal have the same data length. At this time, the target processing window and the target drug terahertz spectrum signal can be point-multiplied, where the point multiplication specifically refers to point-by-point multiplication, that is, multiplying the data at the same position, and the target drug mapping spectrum signal can be generated based on the result of multiplying the data at all positions.
[0224] From the above description, it can be seen that after the target drug mapping spectrum signal is generated, the target drug mapping spectrum signal needs to be dimensionally matched to generate the target drug terahertz spectrum target signal after the dimension matching process. It can be seen that the data length of the target drug terahertz spectrum target signal is consistent with the target dimension of the dimension matching. Generally, the target dimension can be determined according to the category of the target drug. For example, when the target drug is a drug, the target dimension can be set to 2048, that is, the target drug terahertz spectrum target signal should contain spectral signals corresponding to 2048 sampling points.
[0225] Since the data length of the target drug mapping spectral signal may be different from the target dimension, the target drug mapping spectral signal may be truncated or filled according to the data length of the target drug mapping spectral signal when performing the dimension matching process. Since the target drug mapping spectral signal corresponds to the target processing window, at this time, the data length of the target drug mapping spectral signal is from the position corresponding to the starting point of the target processing window to the end position of the target drug mapping spectral signal; when the data length of the target drug mapping spectral signal is greater than the target dimension, a truncation process is performed, wherein when the truncation process is performed, starting from the position corresponding to the starting point of the target processing window until the target dimension is reached, the remaining data points after reaching the target dimension position are truncated. It can be understood that when the data length of the target drug mapping spectral signal is less than the target dimension, a filling process is performed. When filling, the data length of the target drug mapping spectral signal is mainly filled to the target dimension, and the filled data is preferably 0.
[0226] It can be seen from the above description that an embodiment of preprocessing the terahertz spectrum signal of the target drug and generating the terahertz spectrum target signal of the target drug is given; when the same preprocessing method is used for the terahertz spectrum reference signal, the above preprocessing process description can be referred to, and examples will not be given one by one here.
[0227] In one embodiment of the present invention, when calculating and generating a target absorption coefficient of a target drug, the method includes:
[0228] The terahertz spectrum reference target signal and the target drug terahertz spectrum target signal are subjected to frequency domain conversion processing to generate corresponding terahertz spectrum reference frequency domain signal and target drug terahertz spectrum frequency domain signal respectively after the frequency domain conversion processing;
[0229] Filtering the terahertz spectrum reference frequency domain signal and the target drug terahertz spectrum frequency domain signal to generate a terahertz spectrum reference target frequency domain signal and a target drug terahertz spectrum target frequency domain signal, respectively;
[0230] Based on the terahertz spectrum reference target frequency domain signal and the target drug terahertz spectrum target frequency domain signal, the target absorption coefficient of the target drug is calculated and generated. The target absorption coefficient of the target drug is:
[0231]
[0232] Wherein, ω is the angular frequency, S(w) is the target frequency domain signal of the terahertz spectrum of the target drug; R(w) is the reference target frequency domain signal of the terahertz spectrum; H(w) is the transfer function at frequency ω; d is the thickness of the target drug; c is the speed of light in a vacuum; ρ(ω) is the amplitude ratio of the target frequency domain signal of the terahertz spectrum of the target drug and the reference target frequency domain signal of the terahertz spectrum; arg(S(w)) is the phase of the target frequency domain signal of the terahertz spectrum of the target drug; arg(R(w)) is the phase of the reference target frequency domain signal of the terahertz spectrum; is the phase difference between the target frequency domain signal of the terahertz spectrum of the target drug and the reference target frequency domain signal of the terahertz spectrum; n(ω) is the refractive index parameter of the target drug; α(ω) is the target absorption coefficient of the target drug.
[0233] As can be seen from the above description, the terahertz spectrum reference target signal and the target drug terahertz spectrum target signal both contain target dimension data points, wherein each data point corresponds to a sampling time, and an amplitude corresponding to the sampling time. Therefore, the target absorption coefficient of the target drug calculated by the present invention specifically refers to the target absorption coefficient of a data point, wherein the target absorption coefficient of each data point can be calculated in the same way.
[0234] Specifically, the terahertz spectrum reference target signal and the target drug terahertz spectrum target signal can be frequency-domain converted by means of fast Fourier transform, that is, the terahertz spectrum reference target information is fast Fourier transformed to generate a corresponding terahertz spectrum reference frequency-domain signal; the terahertz spectrum target signal of the target drug is fast Fourier transformed to generate a corresponding target drug terahertz spectrum frequency-domain signal. The method and process of frequency-domain conversion processing using Fourier transform can be consistent with the existing method of time-domain-frequency domain conversion, which will not be repeated here.
[0235] After obtaining the terahertz spectrum reference frequency domain signal and the target drug terahertz spectrum frequency domain signal, frequency domain filtering can be performed. It can be seen from the above description that the terahertz spectrum reference frequency domain signal and the target drug terahertz spectrum frequency domain signal can be generated by fast Fourier transform, and after fast Fourier transform, the frequency domain signal has symmetry. Therefore, when performing frequency filtering, only half of the frequency domain signal can be taken to avoid redundancy. In one embodiment of the present invention, for the terahertz spectrum reference frequency domain signal and the target drug terahertz spectrum frequency domain signal, a frequency point with a frequency greater than 0 is selected, so that after the frequency point selection, the terahertz spectrum reference target frequency domain signal and the target drug terahertz spectrum target frequency domain signal can be generated respectively. It can be understood that when the target dimension is 2048, the terahertz spectrum reference target frequency domain signal and the target drug terahertz spectrum target frequency domain signal include 1024 frequency point signals.
[0236] After obtaining the target frequency domain signal based on the terahertz spectrum reference and the target drug terahertz spectrum target frequency domain signal, the target absorption coefficient of the corresponding frequency point can be calculated. Therefore, for a certain frequency point, the corresponding angular frequency ω can be determined. After that, the above calculation formula can be sampled to calculate the target absorption coefficient of the current frequency point. For all frequency points, the corresponding target absorption coefficient can be calculated using the same calculation method, thereby calculating multiple target absorption coefficients.
[0237] In one embodiment of the present invention, when generating the absorption spectrum characteristic graph of the target drug, it includes:
[0238] Configure the absorption coefficient frequency band based on the type of target drug;
[0239] The target absorption coefficient of the target drug generated by calculation is screened by using the configured absorption coefficient frequency band, so as to extract the screened target absorption coefficient of the target drug corresponding to the absorption coefficient frequency band;
[0240] Based on the target absorption coefficient after the target drug is screened, an absorption spectrum characteristic diagram of the target drug is generated, wherein the absorption spectrum characteristic diagram of the target drug includes a two-dimensional grayscale diagram of the absorption spectrum of the target drug.
[0241] From the above description, it can be seen that the frequencies of the corresponding frequency points of the terahertz spectrum reference target frequency domain signal and the target drug terahertz spectrum target frequency domain signal are both greater than 0. When configuring the absorption coefficient frequency band, it should generally be related to the type of target drug. For example, when the target drug is a drug, the reference substance in the reference substance group is generally also a drug. For example, when the reference substance is monoacetylmorphine, beta-phenylethylamine, ketamine, papaverine and other drugs, the frequency domain of interest can be 0-2.5 THz. At this time, the absorption coefficient frequency band is configured to be 0-2.5 THz. The frequency domain of interest specifically refers to the frequency range of the standard absorption peak distribution. When the target drug is of other categories, the corresponding absorption coefficient frequency band can be selected to effectively select all standard absorption peaks.
[0242] It can be seen from the above description that for a target frequency domain signal of the terahertz spectrum of a target drug, multiple target absorption coefficients can be calculated; after the absorption coefficient frequency band is configured, the target absorption coefficient of the target drug calculated and generated can be screened using the configured absorption coefficient frequency band to extract the target absorption coefficient of the target drug after screening corresponding to the absorption coefficient frequency band. Based on the target absorption coefficients of all target drugs after screening, an absorption spectrum characteristic graph of the target drug is generated. Thereafter, the absorption spectrum characteristic graph of the target drug is used as a reference grayscale graph of the target drug. Specifically, the absorption spectrum characteristic graph can be a two-dimensional grayscale graph of the absorption spectrum, that is, the absorption spectrum characteristic graph is a two-dimensional grayscale graph. The specific method and process of generating the absorption spectrum characteristic graph can be consistent with the prior art.
Claims
1. A method for generating pharmaceutical terahertz absorption spectrum data based on conditional diffusion, characterized in that: The method for generating drug terahertz absorption spectrum data comprises: A terahertz spectrum grayscale image generation model based on conditional diffusion is constructed, and the terahertz spectrum grayscale image generation model is used to generate a target drug candidate grayscale image corresponding to the target drug, and a target drug candidate grayscale image set is formed based on the target drug candidate grayscale image, wherein: When using the terahertz spectrum grayscale image generation model to generate a target drug candidate grayscale image, the target category label, target time step and initial noisy image of the target drug are loaded into the terahertz spectrum grayscale image generation model, and the terahertz spectrum grayscale image generation model is configured to perform denoising on the initial noisy image, so as to generate a target drug candidate grayscale image after denoising at the target time step, wherein the dimension of the target drug candidate grayscale image is the same as the dimension of the initial noisy image; A target drug reference grayscale image of a target drug is provided, and the feature similarity between each target drug candidate grayscale image in the target drug candidate grayscale image set and the target drug reference grayscale image is calculated, and the feature similarity matching the feature similarity threshold is used as the target feature similarity, so as to use the target drug candidate grayscale image corresponding to the target feature pixel point as the target drug target grayscale image; A grayscale image-spectral data conversion process is performed on the target grayscale image of each target drug to generate corresponding terahertz absorption spectrum data of the target drug after the grayscale image-spectral data conversion process.
2. The method for generating pharmaceutical terahertz absorption spectrum data based on conditional diffusion according to claim 1 is characterized in that: When calculating feature similarity, we have: SSIM(A,B)=L(A,B)*C(A,B)*S(A,B) Among them, SSIM(A,B) is the feature similarity between the target drug candidate grayscale image and the target drug reference grayscale image, A is the target drug candidate grayscale image, B is the target drug reference grayscale image, L(A,B) is the brightness comparison feature between the target drug candidate grayscale image and the target drug reference grayscale image, C(A,B) is the contrast comparison feature between the target drug candidate grayscale image and the target drug reference grayscale image, and S(A,B) is the structure comparison feature between the target drug candidate grayscale image and the target drug reference grayscale image.
3. The method for generating pharmaceutical terahertz absorption spectrum data based on conditional diffusion according to claim 1, characterized in that: The terahertz spectrum grayscale image generation model includes a noise prediction module and a denoising operation module, wherein: When generating a target drug candidate grayscale image, the target category label, target time step and initial noisy image are loaded into the noise prediction module, wherein the initial noisy image is used as a reference noisy image for the first noise prediction, and an inference denoising time step is generated at each denoising process based on the target time step, and thereafter, the noise prediction module is used to predict the target drug prediction noise of the reference noisy image under the target category label and each inference denoising time step; Based on the target drug prediction noise at the current reasoning denoising time step, the denoising operation module updates the reference noisy map used in the current reasoning denoising time step to generate a reference denoised map after the update, and loads the reference denoised map into the noise prediction module to serve as the reference noisy map of the noise prediction module at the next reasoning denoising time step until the number of denoising processes experienced matches the target time step; When the number of denoising processes experienced matches the target time step, the baseline denoising image of the current reasoning denoising time step is used as the target drug candidate grayscale image.
4. The method for generating pharmaceutical terahertz absorption spectrum data based on conditional diffusion according to claim 3 is characterized in that: Randomly sample Gaussian noise that conforms to a standard normal distribution to generate an initial noisy image after random sampling; After the target drug prediction noise is predicted, the number of inference denoising time steps is decreased until the number of inference denoising time steps is 0; For the target drug prediction noise predicted by the noise prediction module, there are: Among them, t is the number of steps of the current inference denoising time step, is the target drug prediction noise at the tth inference denoising time step, x t is the reference noisy image corresponding to the tth inference denoising time step, c is the target category label, ε θ (x t ,c,t) is the conditional prediction noise, T is the target time step; When the denoising operation module updates and generates a reference denoising graph, the updating method includes subtracting the target drug prediction noise generated at the current reasoning denoising time step from the reference noisy graph used at the current reasoning denoising time step.
5. The method for generating pharmaceutical terahertz absorption spectrum data based on conditional diffusion according to claim 3 is characterized in that: The noise prediction module is constructed based on MamBa Block, where: The noise prediction module includes a feature extraction unit, a feature fusion unit, a post-processing unit, a time step processing unit and a label processing unit; The time step processing unit is connected to the feature extraction unit, the label processing unit is connected to the feature fusion unit, and the feature extraction unit is connected to the post-processing unit through the feature fusion unit; When generating the target drug candidate grayscale image, the reference noisy image is loaded into the feature extraction unit, the inference denoising time step is loaded into the time step processing unit, and the target category label is loaded into the label processing unit; The time step processing unit generates feature extraction scaling offset information based on the current reasoning denoising time step, and loads the feature extraction scaling offset information into the feature extraction unit to adjust the scaling offset state of the feature extraction unit when performing feature extraction on the reference noisy image; Based on the target category label, the label processing unit generates feature fusion scaling offset information, and loads the feature fusion scaling offset information into the feature fusion unit to adjust the scaling offset state of the feature fusion unit when performing feature fusion, and the feature fusion unit outputs a noisy image to extract fusion features; The post-processing unit extracts fusion features from the noisy image and performs post-processing to generate target drug prediction noise after post-processing.
6. The method for generating pharmaceutical terahertz absorption spectrum data based on conditional diffusion according to claim 5, characterized in that: The feature extraction unit includes a feature extraction layer normalization layer, a feature extraction scaling offset layer, a MamBa scanning module and a feature extraction post-scaling layer connected in sequence, wherein: A residual connection is formed between the normalization layer of the feature extraction layer and the scaling layer after feature extraction; The time processing unit includes a time processing multilayer perceptron, which generates corresponding feature extraction scaling offset information based on the current inference denoising time step using the time processing multilayer perceptron, wherein: The feature extraction scaling offset information generated by the time step processing unit includes the feature extraction scaling offset coefficient and the feature extraction post-scaling coefficient. The feature extraction scaling offset coefficient is loaded into the feature extraction scaling offset layer, and the feature extraction scaling offset coefficient includes a feature extraction scaling sub-coefficient and a feature extraction offset sub-coefficient; The post-feature extraction scaling coefficients are loaded into the post-feature extraction scaling layer.
7. The method for generating pharmaceutical terahertz absorption spectrum data based on conditional diffusion according to claim 5, characterized in that: The feature fusion unit includes a feature fusion layer normalization layer, a feature fusion scaling offset layer, a cross attention unit and a feature fusion post-scaling layer connected in sequence, wherein: A residual connection is formed between the normalization layer of the feature fusion layer and the scaling layer after feature fusion; The label processing unit includes a label processing multilayer perceptron, which generates corresponding feature fusion scaling offset information based on the target drug label using the label processing perceptron, wherein: The feature fusion scaling offset information generated by the label processing unit includes a feature fusion scaling offset coefficient and a feature fusion post-scaling coefficient. The feature fusion scaling offset coefficient is loaded into the feature fusion scaling offset layer, and the feature fusion scaling offset coefficient includes a feature fusion scaling sub-coefficient and a feature fusion scaling sub-coefficient; The feature fusion post-scaling coefficients are loaded into the feature fusion post-scaling layer.
8. The method for generating pharmaceutical terahertz absorption spectrum data based on conditional diffusion according to any one of claims 5 or 7, characterized in that: When constructing a terahertz spectrum grayscale image generation model, the construction method includes: Constructing a basic model for generating a terahertz spectrum grayscale image, wherein the basic model for generating a terahertz spectrum grayscale image includes a noise prediction basic module and a denoising operation basic module; Constructing a grayscale image generation training data set, wherein the grayscale image generation training data set includes a plurality of training samples, wherein each training sample includes a terahertz spectrum training basic grayscale image and a training drug label corresponding to the terahertz spectrum training basic grayscale image; Configuring model training parameters for generating a basic model for a terahertz spectral grayscale image, wherein the model training parameters at least include a model training time step, so as to generate a corresponding model training denoising time step based on the model training time step; When a training data set is generated by using a grayscale image to train a basic model for generating a terahertz spectrum image, the following steps are included: Based on the terahertz spectrum training basic grayscale image in each training sample, a terahertz spectrum training noisy grayscale image for each training denoising time step is generated, wherein the terahertz spectrum training noisy grayscale image for the current training denoising time step is generated by adding noise to the terahertz spectrum training noisy image for the previous training denoising time step; Loading the terahertz spectrum training noisy grayscale image, the training drug label corresponding to the terahertz spectrum training noisy grayscale image, and the corresponding model training denoising time step into the noise prediction basic module, so as to obtain the corresponding training drug prediction noise through prediction by the noise prediction basic module; Based on the training drug prediction noise at the current model training denoising time step and the used terahertz spectrum training noisy image, the denoising operation basic module calculates the corresponding terahertz spectrum training denoised image; Based on the terahertz spectrum training denoised image and the corresponding terahertz spectrum training noisy image, the training denoising time step loss of the training sample after the current model training denoising step is calculated; Determine the training denoising loss for each training sample based on all training denoising time step losses; When the model training of the terahertz spectrum grayscale image generation basic model reaches the target training state, the corresponding terahertz spectrum grayscale image generation model is generated based on the terahertz spectrum grayscale image generation basic model.
9. The method for generating pharmaceutical terahertz absorption spectrum data based on conditional diffusion according to claim 8, characterized in that: The step value of the model training time step is equal to the step value corresponding to the target time step; The target drug label is one of the training drug labels included in the grayscale image generation training data set; For each terahertz spectrum training noisy map used in the training denoising time step, we have: Among them, X k is the noisy image of terahertz spectrum training used in the kth training denoising time step, X0 is the basic grayscale image of terahertz spectrum training, σ is the random noise sampled from the Gaussian noise of the standard normal distribution added in the denoising process, ν k is the hyperparameter for the kth training denoising time step, and K is the value of the model training time step.
10. The method for generating pharmaceutical terahertz absorption spectrum data based on conditional diffusion according to claim 9, characterized in that: For each training denoising time step loss, we have: Among them, Loss k is the training denoising time step loss for the kth training denoising time step, σ θ (X k ,c,k) is the training drug prediction noise generated by the prediction of the kth training denoising time step, and E is the expected value.
Citation Information
Cited By
Terahertz-based medicinal material identification method and device
CN121415908A
A method and device for identifying medicinal materials based on terahertz
CN121415908B