Retrieval methods of nuclear magnetic resonance hydrogen spectra in two data formats
By extracting the high-dimensional features of the nuclear magnetic resonance hydrogen spectrum and calculating the similarity, the problem of low hydrogen spectrum search efficiency and accuracy in the prior art is solved, and efficient matching and retrieval of the nuclear magnetic resonance hydrogen spectrum is achieved.
Patent Information
- Application Number
- CN202210746938.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-28
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2042-06-28
AI Technical Summary
The prior art is difficult to effectively match the text data and image data in the nuclear magnetic resonance hydrogen spectrum, resulting in low efficiency and accuracy of hydrogen spectrum retrieval.
By extracting the high-dimensional characteristics of the nuclear magnetic resonance hydrogen spectrum, the similarity between the input data and the data in the database is calculated, the search of the two data formats is realized, and the spectrum of the top 5 digits of the matching degree and its substance name are output.
It improves the efficiency and accuracy of NMR hydrogen spectrum retrieval, and can accurately match the spectrum and substance names in the database.
Smart Images

Figure CN115114471B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of text and image information matching, and relates to a nuclear magnetic resonance hydrogen spectrum retrieval method in two data formats. Background Art
[0002] Nuclear magnetic resonance hydrogen spectrum (also called hydrogen spectrum) is an application that reflects the nuclear magnetic resonance effect of hydrogen-1 in molecules in nuclear magnetic resonance spectroscopy. It can be used to determine the structure of molecules. When the sample contains hydrogen, especially the isotope hydrogen-1, the nuclear magnetic resonance hydrogen spectrum can be used to determine the structure of the molecule. By using it in conjunction with carbon-13 nuclear magnetic resonance, the nuclear magnetic resonance hydrogen spectrum has become a powerful tool for characterizing molecular structure. However, since nuclear magnetic resonance hydrogen spectrum usually requires professional facilities and personnel to analyze the composition of the material through precise measurement and analysis, and the hydrogen spectrum matching process is cumbersome, the original data of the TXT file needs to be exported for retrieval. Therefore, finding a matching algorithm between text data and the corresponding image and realizing the simultaneous retrieval of text data and image data has become an urgent need to be solved.
[0003] After the 1990s, with the rapid development of computer digitization and the widespread popularity of the Internet, image retrieval technology based on content, such as image color, texture, layout, etc., has emerged to analyze and retrieve images. The query condition is an image or a description of the image content. It builds an index by extracting the underlying features and then calculating and comparing the distance between these features and the query conditions to determine the similarity between two images. However, the content features of hydrogen spectra are quite different from the actual application feature representation. The principles and methods of conventional content-based image retrieval and text-based image retrieval technology are far from the principles and methods of actual application in hydrogen spectrum database retrieval. If conventional image retrieval methods are directly applied, the correct results cannot be matched.
[0004] The Chinese patent "CN201410830581.1 A gas chromatography mass spectrometry spectrum retrieval method based on a vector model" provides a gas chromatography mass spectrometry spectrum retrieval method based on a vector model. Matching based solely on the vector space model can only meet ideal acquisition conditions and does not have good adaptability and accuracy when facing actual complex spectra. Summary of the invention
[0005] To solve the above technical problems, the purpose of the present invention is to provide a method for retrieving nuclear magnetic resonance hydrogen spectra in two data formats, by extracting high-dimensional features of the data and calculating the similarity between the high-dimensional features of the input data and the high-dimensional features of the data in the database, thereby retrieving the spectra with the top 5 matching degrees in the database and the names of the substances corresponding to the spectra.
[0006] The present invention provides a nuclear magnetic resonance hydrogen spectrum retrieval method in two data formats, comprising:
[0007] Step 1: Determine whether the input data is image format data or txt file format data;
[0008] Step 2: If the input data is in txt file format, convert the txt file format data into image format and then execute step 3; if the input data is in image format, directly execute step 3;
[0009] Step 3: Preprocess the image format data to obtain a peak map;
[0010] Step 4: Extract peak graph features to obtain an initial feature matrix, and adjust the initial feature matrix according to the peak group spacing threshold to obtain the final input data feature matrix;
[0011] Step 5: Calculate the distance between the input data feature matrix and all sample data feature matrices in the database respectively, and sort them in ascending order of distance to obtain the top 5 spectra and the substance names corresponding to the spectra.
[0012] In the two data formats of the nuclear magnetic resonance hydrogen spectrum retrieval method of the present invention, the conversion of the txt file format data into the image format in step 2 is specifically as follows:
[0013] Step 2.1: Use the PIL library to accurately plot the data in txt, that is, obtain the spectrum corresponding to the data;
[0014] Step 2.2: Crop the spectrum in step 2.1, remove redundant information, and retain the core data.
[0015] In the nuclear magnetic resonance hydrogen spectrum retrieval method of the two data formats of the present invention, the step 3 is specifically:
[0016] Step 3.2.1: Binarize the input spectrum to obtain a 0-1 pixel matrix;
[0017] Step 3.2.2: Scan the pixel matrix row by row to determine the position of the baseline, and set all pixel values below the baseline and outside the two ends to 1;
[0018] Step 3.2.3: The starting point and the end point of the peak are both on the baseline. Based on the position located on the baseline, the coordinates of the first and last points of the peak are located in order from left to right, and the coordinates of all peak pixel points are recorded and stored;
[0019] Step 3.2.4: Draw the peak graph according to the coordinates of the recorded peak pixel points.
[0020] In the nuclear magnetic resonance hydrogen spectrum retrieval method of the two data formats of the present invention, the step 4 is specifically:
[0021] Step 4.1: Get the number of peak groups;
[0022] Step 4.1.1: Scan the peak map obtained after preprocessing at the pixel level from top to bottom;
[0023] Step 4.1.2: Set the clustering threshold to cluster the pixels according to the horizontal coordinates of the pixels;
[0024] Step 4.1.3: The number of pixel clusters is the number of peak groups, which determines the number of columns of the extracted feature matrix;
[0025] Step 4.2: Obtain the height ratio of each peak group;
[0026] Step 4.2.1: For each peak group, determine the peak group and the height of the peak group, and take the maximum value as the height of the peak group;
[0027] Step 4.2.2: Calculate the height proportion of the peak groups, and form a sequence with the length of the height proportion of each peak group into a sequence with the number of peak groups as the first row vector of the feature matrix;
[0028] Step 4.3: Obtain the width ratio of each peak group;
[0029] Step 4.3.1: For each peak group, first obtain the coordinates of the peak group in the pixel matrix, and regard the number of columns occupied by the peak group in the pixel matrix as the peak group width;
[0030] Step 4.3.2: Normalize the peak group widths, and use the normalized peak group widths to form a sequence with a length equal to the number of peak groups, which is used as the second row vector of the feature matrix;
[0031] Step 4.4: Obtain the relative position of each peak group;
[0032] Step 4.4.1: For each peak group, set the relative position of the first peak group to 0 and the relative position of the last peak group to 1 from left to right;
[0033] Step 4.4.2: Calculate the horizontal coordinate of each peak group based on the horizontal coordinates of the first peak group and the last peak group, and form a sequence with a length of the number of peak groups from the relative positions of all peak groups as the third row vector of the feature matrix; wherein the average value of the horizontal coordinates of the left endpoint and the right endpoint of the peak group is taken as the horizontal coordinate of the peak group;
[0034] Step 4.5: Form an initial feature matrix based on the extracted features, set a peak group spacing threshold, and adjust the initial feature matrix based on the peak group spacing threshold to obtain a final input data feature matrix;
[0035] Step 4.5.1: If the distance between two peak groups is less than the peak group distance threshold, the two peak groups are merged, and the two columns in the feature matrix corresponding to the two peak groups are also merged accordingly;
[0036] Step 4.5.2: Take the highest value of the height ratio in the two columns and then normalize it;
[0037] Step 4.5.3: Add the width proportions of the two columns and normalize them;
[0038] Step 4.5.4: The relative positions in the two columns are taken as the average of the relative positions of the two peak groups, and then rearranged so that the relative position of the first peak group is 0 and the relative position of the last peak group is 1.
[0039] In the nuclear magnetic resonance hydrogen spectrum retrieval method of two data formats of the present invention, the step 5 of calculating the distance between the input data feature matrix and a certain sample data feature matrix in the database specifically includes the following steps:
[0040] Step 5.1: Calculate the corresponding row vector similarity threshold of the input data feature matrix and the sample data feature matrix;
[0041] Step 5.2: Based on the similarity threshold of each row vector, the matching parts of the corresponding row vectors of the input data feature matrix and the sample data feature matrix are respectively screened out;
[0042] Step 5.3: Calculate the Manhattan distance d1 of the matching parts of the three row vectors, and calculate the distance d2 of the unmatched parts of the first two rows in the feature matrix. The distance d=d1+d2 of the first two rows of the input data feature matrix and the sample data feature matrix, and the distance of the third row is d1;
[0043] Step 5.4: Sum the distances calculated by the three row vectors and record it as D, which is the distance between the two feature matrices.
[0044] In the nuclear magnetic resonance hydrogen spectrum retrieval method of the two data formats of the present invention, the step 5.1 is specifically:
[0045] Step 5.1.1: Compare the lengths of a corresponding row vector in the input data feature matrix and the sample data feature matrix, and record the longer row vector as A n =a1,a2,…a i ,…a n , the shorter row vector is denoted by B m =b1,b2,…b j ,…b m ;
[0046] Step 5.1.2: For each element a in A i, both create two vectors temp1 and temp2;
[0047] Step 5.1.3: Calculate a in sequence i The relative difference between each element in the row vector B is stored in temp1 in order to obtain a vector temp1 of length m;
[0048] Step 5.1.4: Compare a in turn i Take the larger of each element in row vector B and store them in temp2 in order to get vector temp2 of length m;
[0049] Step 5.1.5: Take the minimum component of temp1 divided by temp2 and store it in the sequence S;
[0050] Step 5.1.6: Take the m+1th value of sequence S as the row vector similarity threshold of row vectors A and B; if n=m, take the mth value as the row vector similarity threshold of row vectors A and B.
[0051] In the nuclear magnetic resonance hydrogen spectrum retrieval method of the two data formats of the present invention, the step 5.2 is specifically:
[0052] Step 5.2.1: If A n =a1,a2,…a i ,…a n and / or B m =b1,b2,…b j ,…b m If it is empty, the matching part is empty;
[0053] Step 5.2.2: If A n =a1,a2,…a i ,…a n and B m =b1,b2,…b j ,…b m Not empty, based on the following formula to determine A n =a1,a2,…a i ,…a n and B m =b1,b2,…b j ,…b m Do the elements in match:
[0054]
[0055] Where r is the row vector A n and B m The row vector similarity threshold of , if the above formula is satisfied, then the two elements a i and b jmatch;
[0056] Step 5.2.3: Traverse A from back to front n and B m , according to A n and B m Depending on the matching of the elements in, select step 5.2.4 or step 5.2.5;
[0057] Step 5.2.4: If a n and b m Match, move forward one position and repeat step 5.2.4 to continue comparing A n-1 =a1,a2,…a i ,…a n-1 and B m-1 =b1,b2,…b j ,…b m-1 ;
[0058] Step 5.2.5: If a n and b m Do not match, compare A respectively n-1 =a1,a2,…a i ,…a n-1 and B m =b1,b2,…b j ,…b m and A n =a1,a2,…a i ,…a n and B m-1 =b1,b2,…b j ,…b m-1 In both cases, the comparison process repeats steps 5.2.4 and 5.2.5, and the matching elements are saved;
[0059] Step 5.2.6: After the traversal is completed, select the case with the most matching elements and save the resulting vector as row vector A n and B m The matching part.
[0060] In the nuclear magnetic resonance hydrogen spectrum retrieval method of the two data formats of the present invention, the step 5.3 is specifically:
[0061] Step 5.3.1: l is the length of the matching part of the corresponding row vector in the input data feature matrix and the sample data feature matrix, A n The matching part is recorded as: X = x1, x2, ... x l ; B m The matching part is recorded as Y=y1, y2, ...y;
[0062] Step 5.3.2: Calculate the Manhattan distance between the matching parts X and Y according to the following formula:
[0063]
[0064] Step 5.3.3: Calculate the penalty parameters R1 and R2 according to the following formula:
[0065]
[0066]
[0067] The row vector A is calculated according to the following formula n and B m The distance d2 of the mismatched part:
[0068]
[0069] The distance step between the first two rows of the input data feature matrix and the sample data feature matrix
[0070] 5.3.4: The distance between the first two rows of the input data feature matrix and the sample data feature matrix is d=d1+d2, and the distance between the third row is d1.
[0071] The nuclear magnetic resonance hydrogen spectrum retrieval method of the present invention in two data formats can establish a feature matrix for the hydrogen spectrum of the detected object and its original txt data, and design a feature matrix distance calculation algorithm according to the characteristics of the feature matrix to obtain the matching degree between the spectra, thereby obtaining the matching result of the detected object in the database, which has high matching efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 It is a flow chart of the nuclear magnetic resonance hydrogen spectrum retrieval method of two data formats of the present invention;
[0073] Figure 2a The txt data of nuclear magnetic resonance hydrogen spectrum of a certain test object;
[0074] Figure 2b It is the hydrogen spectrum converted from the hydrogen spectrum txt data of a certain detected object;
[0075] Figure 3a is the input atlas data;
[0076] Figure 3b is the peak map obtained after preprocessing; DETAILED DESCRIPTION
[0077] like Figure 1 The nuclear magnetic resonance hydrogen spectrum retrieval method of the present invention in two data formats includes:
[0078] Step 1: Determine whether the input data is image format data or txt file format data;
[0079] Step 2: If the input data is in txt file format, convert the txt file format data into image format and then execute step 3; if the input data is in image format, directly execute step 3;
[0080] The specific steps of converting the txt file format data into image format in step 2 are as follows:
[0081] Step 2.1: Use the PIL library to accurately plot the data in txt, that is, obtain the spectrum corresponding to the data;
[0082] Step 2.2: Crop the spectrum in step 2.1, remove redundant information, and retain the core data.
[0083] Figure 2a The txt data of nuclear magnetic resonance hydrogen spectrum of a certain test object; Figure 2b It is a hydrogen spectrum diagram converted from the hydrogen spectrum txt data of a certain detected object.
[0084] Step 3: Preprocess the image format data to obtain the peak map, specifically:
[0085] Step 3.2.1: Binarize the input spectrum to obtain a black-and-white binary image and its 0-1 pixel matrix;
[0086] In the specific implementation, the input image is binarized. Based on the color characteristics of the spectrum and the purpose of peak image discrimination, the binarization threshold T is set to divide the data of the entire image into two parts: a pixel group W greater than T and a pixel group B less than T. Pixel points less than T are assigned a value of 0, and pixel points greater than T are assigned a value of 1, obtaining a black and white binary image and its corresponding 0-1 pixel matrix.
[0087] Step 3.2.2: Scan the pixel matrix row by row. If there are pixels with consecutive 0 values in a row of the pixel matrix, the row corresponds to the border line or baseline of the black-and-white binary image. Set all pixel values below the baseline and outside the two ends to 1.
[0088] In specific implementation, the baseline is generally at the bottom of the spectrum and above the chemical shift scale line. Based on the position of the baseline row, the number of pixels and the arrangement rules, other noises similar to the baseline can be quickly located, and all pixel values in the area below the baseline and outside the two ends are set to 1 to remove some noise.
[0089] Step 3.2.3: The starting point and the end point of the peak are both on the baseline. Based on the position located on the baseline, the coordinates of the first and last points of the peak are located in order from left to right, and the coordinates of all peak pixel points are recorded and stored;
[0090] Step 3.2.4: Set all elements of the 0-1 pixel matrix to 1, and set the elements in the 0-1 pixel matrix corresponding to the peak pixel coordinates of the black-and-white binary image to 0 to obtain a new pixel matrix, and convert the new pixel matrix into a binary image to obtain the peak image. Figure 3a is the input atlas data, Figure 3b This is the peak map obtained after preprocessing.
[0091] Step 4: Extract peak graph features to obtain an initial feature matrix, and adjust the initial feature matrix according to the peak group spacing threshold to obtain the final input data feature matrix;
[0092] In the specific implementation, according to the characteristics of the H NMR spectrum data and graph of the chemical substance, the following features are extracted as the basis for matching, namely: the number of peak groups, the height proportion of the peak group, the width proportion of the peak group and the relative position of the peak group, to form a feature matrix. The feature extraction method is as follows:
[0093] Step 4.1: Get the number of peak groups;
[0094] Step 4.1.1: Scan the peak map obtained after preprocessing at the pixel level from top to bottom;
[0095] Step 4.1.2: When the first pixel is scanned, the clustering threshold is set to perform clustering with the horizontal coordinate of the pixel as the center;
[0096] Step 4.1.3: All pixels corresponding to the horizontal coordinates within the clustering threshold range are considered to be of the same class, thereby obtaining the first peak group;
[0097] Step 4.1.4: Repeat steps 4.1.2 and 4.1.3 for the remaining pixels. The final number of clusters is the number of peak groups, denoted as n. The number of peak groups determines the number of columns of the extracted feature matrix.
[0098] Step 4.2: Obtain the height ratio of each peak group;
[0099] Step 4.2.1: For each peak group, determine the peak group and the height of the peak group, and take the maximum value as the height of the peak group;
[0100] Step 4.2.2: Calculate the height ratio of the peak groups, and form a sequence with a length equal to the number of peak groups from the height ratios of each peak group as the first row vector of the feature matrix.
[0101] In specific implementation, since the height of the peak in the hydrogen spectrum represents the integrated area of the peak, for each peak group, its highest height can be determined according to the position of the highest point in each column and the position of the baseline. Then the peak group height is normalized.
[0102] Step 4.3: Obtain the width ratio of each peak group;
[0103] Step 4.3.1: For each peak group, first obtain the coordinates of the peak group in the pixel matrix, and regard the number of columns occupied by the peak group in the pixel matrix as the peak group width;
[0104] Step 4.3.2: Normalize the peak group widths, and use the normalized peak group widths to form a sequence with a length equal to the number of peak groups as the second row vector of the feature matrix.
[0105] Step 4.4: Obtain the relative position of each peak group;
[0106] Step 4.4.1: For each peak group, set the relative position of the first peak group to 0 and the relative position of the last peak group to 1 from left to right;
[0107] Step 4.4.2: Calculate the horizontal coordinate of each peak group based on the horizontal coordinates of the first peak group and the last peak group, and then obtain the relative position of each peak group. The relative positions of all peak groups are constructed into a sequence with a length of the number of peak groups as the third row vector of the feature matrix; wherein, the average value of the horizontal coordinate of the left endpoint and the horizontal coordinate of the right endpoint of the peak group is taken as the horizontal coordinate of the peak group.
[0108] Step 4.5: Form an initial feature matrix based on the extracted features, set a peak group spacing threshold, and adjust the initial feature matrix based on the peak group spacing threshold to obtain a final input data feature matrix;
[0109] Step 4.5.1: If the distance between two peak groups is less than the peak group distance threshold, the two peak groups are merged, and the two columns in the feature matrix corresponding to the two peak groups are also merged;
[0110] In specific implementation, the merge process is as follows:
[0111] Step 4.5.2: Take the highest value of the height ratio in the two columns and then normalize it;
[0112] Step 4.5.3: Add the width proportions of the two columns and normalize them;
[0113] Step 4.5.4: The relative positions in the two columns are taken as the average of the relative positions of the two peak groups. If the relative position of one of the two peak groups to be merged is 0 or 1, the merged relative position is 0 or 1, and the relative positions of the remaining peak groups are calculated again until no relative position is less than the peak group spacing threshold.
[0114] After the above features are extracted, the number of peak groups is used as the number of columns L of the feature to form a 3×L feature matrix. The first row vector is the height ratio of the peak group, the second row vector is the width ratio of the peak group, and the third row vector is the relative position of the peak group, where the leftmost position is 0 and the rightmost position is 1. Each column vector represents the feature of a peak group.
[0115] Step 5: Calculate the distance between the input data feature matrix and all sample data feature matrices in the database respectively, and sort them in ascending order of distance to obtain the top 5 spectra and the substance names corresponding to the spectra.
[0116] In specific implementation, the distance between the input data feature matrix and a sample data feature matrix in the database is first calculated according to the following method, and then the distances between the input data feature matrix and all sample data feature matrices in the database are calculated respectively, and the top 5 spectra with the smallest distance are selected.
[0117] In step 5, the distance between the input data feature matrix and a sample data feature matrix in the database is calculated, which specifically includes the following steps:
[0118] Step 5.1: Calculate the row vector similarity thresholds corresponding to the input data feature matrix and the sample data feature matrix. Step 5.1 is specifically as follows:
[0119] Step 5.1.1: Compare the lengths of a corresponding row vector in the input data feature matrix and the sample data feature matrix, and record the longer row vector as A n =a1,a2,…a i ,…a n , the shorter row vector is denoted by B m =b1,b2,…b j ,…b m ;
[0120] Step 5.1.2: For each element a in A i , both create two sequences temp1 and temp2;
[0121] Step 5.1.3: Calculate a in sequence i The difference between each element in the row vector B is stored in temp1 in order to obtain a sequence temp1 of length m;
[0122] Step 5.1.4: Compare a in turn i and each element in the row vector B, take the larger one and store it in temp2 in order, and get the sequence temp2 of length m;
[0123] Step 5.1.5: Divide each element in temp1 by the element at the same position in temp2 to get m values, and take the minimum value of these m values and store it in sequence S;
[0124] Step 5.1.6: Take the m+1th value of sequence S as the row vector similarity threshold of row vectors A and B; if n=m, take the mth value as the row vector similarity threshold of row vectors A and B.
[0125] Step 5.2: Based on the similarity threshold of each row vector, the matching parts of the corresponding row vectors of the input data feature matrix and the sample data feature matrix are respectively screened out. The specific steps of step 5.2 are as follows:
[0126] Step 5.2.1: If A n =a1,a2,…a i ,…a n and / or B m =b1,b2,…b j ,…b m If it is empty, the matching part is empty;
[0127] Step 5.2.2: If A n =a1,a2,…a i ,…a n and B m =b1,b2,…b j ,…b m Not empty, based on the following formula to determine A n =a1,a2,…a i ,…a n and B m =b1,b2,…b j ,…b m Do the elements in match:
[0128]
[0129] Where r is the row vector A n and B m The row vector similarity threshold of , if the above formula is satisfied, then the two elements a i and b j match;
[0130] Step 5.2.3: Traverse A from back to front n and B m , according to A n and B m Depending on the matching of the elements in, select step 5.2.4 or step 5.2.5;
[0131] Step 5.2.4: If a n and bm Match, move forward one position and repeat step 5.2.4 to continue comparing A n-1 =a1,a2,…a i ,…a n-1 and B m-1 =b1,b2,…b j ,…b m-1 ;
[0132] Step 5.2.5: If a n and b m Do not match, compare A respectively n-1 =a1,a2,…a i ,…a n-1 and B m =b1,b2,…b j ,…b m and A n =a1,a2,…a i ,…a n and B m-1 =b1,b2,…b j ,…b m-1 In both cases, the comparison process repeats steps 5.2.4 and 5.2.5, and the matching elements are saved;
[0133] Step 5.2.6: After the traversal is completed, select the case with the most matching elements and save the resulting vector as row vector A n and B m The matching part.
[0134] Step 5.3: Calculate the Manhattan distance d1 of the matching part of the three row vectors, and calculate the distance d2 of the unmatched part of the first two rows in the feature matrix. The distance d=d1+d2 of the first two rows of the input data feature matrix and the sample data feature matrix, and the distance of the third row is d1. The specific steps of step 5.3 are:
[0135] Step 5.3.1: l is the length of the matching part of the corresponding row vector in the input data feature matrix and the sample data feature matrix, A n The matching part is recorded as: X = x1, x2, ... x l ; B m The matching part is recorded as Y=y1, y2, ...y;
[0136] Step 5.3.2: Calculate the Manhattan distance between the matching parts X and Y according to the following formula:
[0137]
[0138] Step 5.3.3: Calculate the penalty parameters R1 and R2 according to the following formula:
[0139]
[0140]
[0141] The row vector A is calculated according to the following formula n and B m The distance d2 of the mismatched part:
[0142]
[0143] The distance between the first two rows of the input data feature matrix and the sample data feature matrix Step 5.3.4: The distance between the first two rows of the input data feature matrix and the sample data feature matrix is d=d1+d2, and the distance of the third row is d1.
[0144] Step 5.4: Sum the distances calculated by the three row vectors and record it as D, which is the distance between the two feature matrices.
[0145] After completing the above operations, the distances to the two feature matrices are obtained, and the feature matrices of all graphs in the data graph are traversed according to the calculated distances and sorted in ascending order to obtain the Top1 and Top5 similar substance spectrum results.
[0146] The above description is only a preferred embodiment of the present invention and is not intended to limit the concept of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for retrieving nuclear magnetic resonance hydrogen spectra in two data formats, characterized in that: include: Step 1: Determine whether the input data is image format data or txt file format data; Step 2: If the input data is in txt file format, convert the txt file format data into image format and then execute step 3; if the input data is in image format, directly execute step 3; Step 3: Preprocess the image format data to obtain a peak map; Step 4: Extract peak graph features to obtain an initial feature matrix, and adjust the initial feature matrix according to the peak group spacing threshold to obtain the final input data feature matrix, specifically: Step 4.1: Get the number of peak groups; Step 4.1.1: Scan the peak map obtained after preprocessing at the pixel level from top to bottom; Step 4.1.2: Set the clustering threshold to cluster the pixels according to the horizontal coordinates of the pixels; Step 4.1.3: The number of pixel clusters is the number of peak groups, which determines the number of columns of the extracted feature matrix; Step 4.2: Obtain the height ratio of each peak group; Step 4.2.1: For each peak group, determine the peak group and the height of the peak group, and take the maximum value as the height of the peak group; Step 4.2.2: Calculate the height proportion of the peak groups, and form a sequence with the length of the height proportion of each peak group into a sequence with the number of peak groups as the first row vector of the feature matrix; Step 4.3: Obtain the width ratio of each peak group; Step 4.3.1: For each peak group, first obtain the coordinates of the peak group in the pixel matrix, and regard the number of columns occupied by the peak group in the pixel matrix as the peak group width; Step 4.3.2: Normalize the peak group widths, and use the normalized peak group widths to form a sequence with a length equal to the number of peak groups, which is used as the second row vector of the feature matrix; Step 4.4: Obtain the relative position of each peak group; Step 4.4.1: For each peak group, set the relative position of the first peak group to 0 and the relative position of the last peak group to 1 from left to right; Step 4.4.2: Calculate the horizontal coordinate of each peak group based on the horizontal coordinates of the first peak group and the last peak group, and form a sequence with a length of the number of peak groups from the relative positions of all peak groups as the third row vector of the feature matrix; wherein the average value of the horizontal coordinates of the left endpoint and the right endpoint of the peak group is taken as the horizontal coordinate of the peak group; Step 4.5: An initial feature matrix is formed according to the extracted features, a peak group spacing threshold is set, and the initial feature matrix is adjusted according to the peak group spacing threshold to obtain a final input data feature matrix; Step 4.5.1: If the distance between two peak groups is less than the peak group distance threshold, the two peak groups are merged, and the two columns in the feature matrix corresponding to the two peak groups are also merged accordingly; Step 4.5.2: Take the highest value of the height ratio in the two columns and then normalize it; Step 4.5.3: Add the width proportions of the two columns and normalize them; Step 4.5.4: The relative positions in the two columns are averaged by the relative positions of the two peak groups, and then rearranged so that the relative position of the first peak group is 0 and the relative position of the last peak group is 1; Step 5: Calculate the distance between the input data feature matrix and all sample data feature matrices in the database respectively, and sort them in ascending order of distance to obtain the top 5 spectra and the substance names corresponding to the spectra.
2. The method for retrieving nuclear magnetic resonance hydrogen spectra in two data formats as claimed in claim 1, characterized in that: The specific steps of converting the txt file format data into image format in step 2 are as follows: Step 2.1: Crop the txt file format data, delete redundant information, and retain the core data; Step 2.2: Draw a precise graph according to the core data in txt, that is, obtain the spectrum corresponding to the data.
3. The method for retrieving nuclear magnetic resonance hydrogen spectra in two data formats as claimed in claim 1, characterized in that: The step 3 is specifically as follows: Step 3.2.1: Binarize the input spectrum to obtain a 0-1 pixel matrix; Step 3.2.2: Scan the pixel matrix row by row to determine the position of the baseline, and set all pixel values below the baseline and outside the two ends to 1; Step 3.2.3: The starting point and the end point of the peak are both on the baseline. Based on the position located on the baseline, the coordinates of the first and last points of the peak are located in order from left to right, and the coordinates of all peak pixel points are recorded and stored; Step 3.2.4: Draw the peak graph according to the coordinates of the recorded peak pixel points.
4. The method for retrieving nuclear magnetic resonance hydrogen spectra in two data formats as claimed in claim 1, characterized in that: In step 5, calculating the distance between the input data feature matrix and a sample data feature matrix in the database specifically includes the following steps: Step 5.1: Calculate the corresponding row vector similarity threshold of the input data feature matrix and the sample data feature matrix; Step 5.2: Based on the similarity threshold of each row vector, the matching parts of the corresponding row vectors of the input data feature matrix and the sample data feature matrix are respectively screened out; Step 5.3: Calculate the Manhattan distance d1 of the matching parts of the three row vectors, and calculate the distance d2 of the unmatched parts of the first two rows in the feature matrix. The distance d=d1+d2 of the first two rows of the input data feature matrix and the sample data feature matrix, and the distance of the third row is d1; Step 5.4: Sum the distances calculated by the three row vectors and record it as D, which is the distance between the two feature matrices.
5. The method for retrieving nuclear magnetic resonance hydrogen spectra in two data formats as claimed in claim 4, characterized in that: The step 5.1 is specifically as follows: Step 5.1.1: Compare the lengths of a corresponding row vector in the input data feature matrix and the sample data feature matrix, and record the longer row vector as A n =a1,a2,…a i ,…a n , the shorter row vector is denoted by B m =b1,b2,…b j ,…b m ; Step 5.1.2: For each element a in A i , create two empty vectors temp1 and temp2; Step 5.1.3: Calculate a in sequence i The difference between each element in the row vector B is stored in temp1 in order to obtain a vector temp1 of length m; Step 5.1.4: Compare a in turn i Take the larger of each element in row vector B and store them in temp2 in order to get vector temp2 of length m; Step 5.1.5: Take the minimum component of temp1 divided by temp2 and store it in the sequence S; Step 5.1.6: Take the m+1th value of sequence S as the row vector similarity threshold of row vectors A and B; if n=m, take the mth value as the row vector similarity threshold of row vectors A and B.
6. The method for retrieving nuclear magnetic resonance hydrogen spectra in two data formats as claimed in claim 5, characterized in that: The step 5.2 is specifically as follows: Step 5.2.1: If A n =a1,a2,…a i ,…a n and / or B m =b1,b2,…b j ,…b m If it is empty, the matching part is empty; Step 5.2.2: If A n =a1,a2,…a i ,…a n and B m =b1,b2,…b j ,…b m Not empty, based on the following formula to determine A n =a1,a2,…a i ,…a n and B m =b1,b2,…b j ,…b m Do the elements in match: Where r is the row vector A n and B m The row vector similarity threshold of , if the above formula is satisfied, then the two elements a i and b j match; Step 5.2.3: Traverse A from back to front n and B m , according to A n and B m Depending on the matching of the elements in, select step 5.2.4 or step 5.2.5; Step 5.2.4: If a n and b m Match, move forward one position and repeat step 5.2.4 to continue comparing A n-1 =a1,a2,…a i ,…a n-1 and B m-1 =b1,b2,…b j ,…b m-1 ; Step 5.2.5: If a n and b m Do not match, compare A respectively n-1 =a1,a2,…a i ,…a n-1 and B m =b1,b2,…b j ,…b m and A n =a1,a2,…a i ,…a n and B m-1 =b1,b2,…b j ,…b m-1 In both cases, the comparison process repeats steps 5.2.4 and 5.2.5, and the matching elements are saved; Step 5.2.6: After the traversal is completed, select the case with the most matching elements and save the resulting vector as row vector A n and B m The matching part.
7. The method for retrieving nuclear magnetic resonance hydrogen spectra in two data formats as claimed in claim 6, characterized in that: The step 5.3 is specifically as follows: Step 5.3.1: l is the length of the matching part of the corresponding row vector in the input data feature matrix and the sample data feature matrix, A n The matching part is recorded as: X = x1, x2, ... x l ; B m The matching part is recorded as Y=y1, y2, ...y; Step 5.3.2: Calculate the Manhattan distance between the matching parts X and Y according to the following formula: Step 5.3.3: Calculate the penalty parameters R1 and R2 according to the following formula: The row vector A is calculated according to the following formula n and B m The distance d2 of the mismatched part: The distance step between the first two rows of the input data feature matrix and the sample data feature matrix 5.3.4: The distance between the first two rows of the input data feature matrix and the sample data feature matrix is d=d1+d2, and the distance between the third row is d1.
Citation Information
Patent Citations
Gas chromatography-mass spectrogram retrieval method based on vector model
CN104572910A
Method for improving resolution of NMR (Nuclear Magnetic Resonance) hydrogen spectrogram under non-uniform field
CN103941205A
Method for realizing rapid identification and comparison by utilizing fluorescence spectrum characteristic information
CN110554013A