A nuclear magnetic resonance spectrum automatic analysis method and system based on a neural network
Patent Information
- Application Number
- CN202611554115.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-09
- Publication Date
- 2026-11-03
AI Technical Summary
Existing methods for interpreting nuclear magnetic resonance spectra rely on manual operation, resulting in inconsistent processing results. They are difficult to adapt to different instruments and nuclides, and their accuracy and verifiability are insufficient under complex conditions.
A neural network-based approach is used to identify sub-peaks and form peak groups. Multiple peaks are classified by combining peak group signals, derivatives, and local position coordinates, and physical verification is performed. The chemical shift is corrected by instrument observation frequency, and phase correction and baseline correction are automatically completed. The approach is adaptable to data formats of different instruments and nuclides.
It improves the accuracy and verifiability of automatic interpretation of nuclear magnetic resonance spectra, reduces human intervention, lowers the misjudgment rate, and enhances the compatibility between different instruments and nuclides.
Smart Images

Figure CN123031103A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of nuclear magnetic resonance spectroscopy analysis, and particularly relates to an automatic nuclear magnetic resonance spectrum analysis method and system based on neural networks. Background Technology
[0002] Nuclear magnetic resonance (NMR) spectroscopy belongs to the fields of analytical chemistry and instrumental analysis, and is commonly used to obtain the response information of atomic nuclei in samples under different chemical environments. NMR instruments typically first acquire the free induction decay signal (FID) generated by the sample under the action of a radio frequency pulse. This FID signal is a time-domain signal that varies with time and cannot be directly used as spectroscopic results such as chemical shift, peak shape, coupling constant, and integrals. It usually needs to be converted into a frequency domain spectrum through a Fast Fourier Transform (FFT).
[0003] After obtaining the frequency domain spectrum, phase correction and baseline correction are required based on the actual acquisition conditions. Phase errors may cause spectral peaks to alternate between positive and negative, peak shape tilt, dispersion shape, or asymmetry, while baseline fluctuations may affect peak height, peak width, peak area, and integration results. Therefore, phase correction, baseline correction, noise estimation, peak identification, and peak boundary determination are usually required for the frequency domain spectrum. For cases where adjacent peaks overlap or weak peaks are located near strong peaks, it is also necessary to further identify shoulder peaks and group multiple sub-peaks with common splitting relationships into the same peak group.
[0004] In nuclear magnetic resonance (NMR) spectra, an atomic nucleus under a given chemical environment can appear as a single peak or split into multiple sub-peaks due to spin coupling between adjacent nuclei. A signal composed of multiple related sub-peaks is called a multiplet. Common multiplet types include singlets, doublets, triplets, quartets, double doublets, double triplets, and triple double doublets. The frequency spacing between sub-peaks in a multiplet can be used to calculate the coupling constant J, which is usually expressed in Hz and is an important spectroscopic parameter for determining molecular structure. In proton NMR spectra, the peak area is usually proportional to the number of hydrogen atoms it represents; therefore, the peak area needs to be converted to an integer integral.
[0005] Current NMR spectrum analysis primarily employs methods such as commercial software-assisted analysis, traditional rule or template matching, and manual spectral interpretation. Commercial software typically offers functions like phase correction, baseline correction, peak finding, integration, line fitting, deconvolution, and multipeak analysis. However, in cases of overlapping peaks, peak distortion, strong coupling, low signal-to-noise ratio, or complex splitting, manual selection of processing algorithms, adjustment of detection thresholds, modification of peak boundaries, or verification of analysis results may still be required. Due to the numerous manual steps involved, different operators may produce different results for the same spectrum, impacting the automation level and reproducibility of the processing.
[0006] Traditional rule-based or template-matching methods typically first identify local maxima in the spectrum and then match them with a pre-defined ideal multiplet template based on the number of peaks, peak spacing, and peak intensity ratio. For example, an ideal first-order splitting peak usually has a relatively definite peak intensity ratio and an approximately equidistant structure. However, the peak shape and intensity relationship in actual NMR spectra can be affected by factors such as higher-order coupling, second-order spectral effects, peak overlap, linewidth variations, phase errors, baseline drift, and signal-to-noise ratio variations, causing the measured peak shape to deviate from the ideal template. In particular, double doubles, double triplets, triple doublets, and other complex multiplets involve multiple sub-peaks and multiple coupling constants, and relying solely on the number of peaks, peak spacing, and peak intensity template for judgment can easily lead to misjudgment.
[0007] While manual spectral interpretation can combine the analyst's experience to process complex spectra, it usually requires observing each spectrum one by one, manually adjusting parameters, determining the type of multiple peaks, measuring coupling constants, and setting integration references. This process is inefficient, and the results may be affected by the operator's experience, making it difficult to guarantee consistency between different samples and different personnel.
[0008] In recent years, deep learning methods have also been used for peak identification and multipeak classification in NMR spectra. For example, some published studies have proposed using the entire one-dimensional proton spectrum after Fourier transform as input to perform frequency-point-by-frequency spectral segmentation and splitting type classification, and combining uncertainty estimation to identify overlapping or out-of-distribution signals. However, frequency-point-by-frequency processing based on the entire spectrum usually requires further determination of peak group boundary intervals and the correspondence between individual sub-peaks; at the same time, classification based solely on the output probability of the neural network may not fully utilize NMR physical information such as the number of sub-peaks, the spacing between sub-peaks, the peak intensity relationship, and the coupling constant. When spectral peaks overlap, have shoulder peaks, low signal-to-noise ratio, or high-order coupling, the specific peak shape output by the neural network may lack verifiable physical evidence.
[0009] Furthermore, the acquisition parameters differ between different NMR instruments and for different nuclides. Existing processing workflows typically require reading data separately for different instrument formats such as Bruker, Varian, or JEOL, and distinguishing between the raw FID and the frequency domain spectra already processed by the manufacturer. Proton, carbon, and fluorine spectra also differ in spectral width, observation frequency, peak intensity, baseline characteristics, peak detection threshold, and subsequent integration requirements. Using uniform, fixed processing parameters may be difficult to adapt to different nuclides and acquisition conditions. Especially when calculating coupling constants, chemical shift differences need to be converted to Hz based on the instrument's actual observation frequency for the corresponding nuclide; failure to use the actual observation frequency may affect the consistency of results between different instruments and different spectra.
[0010] Therefore, existing technologies still require an automatic NMR spectrum analysis method and system that is compatible with both raw FID and manufacturer-processed frequency domain spectra, automatically selects the processing path based on nuclides and acquisition parameters, automatically performs phase correction, baseline correction, peak identification, and peak group division, and can combine neural network classification results with NMR physics rules to jointly determine the type of multiple peaks and coupling constants. This method should also be able to identify solvent peaks, impurity peaks, and reference peaks, perform automatic integer integration on proton or fluorine spectra, and save processing parameters, candidate results, and verification status during the analysis process to output reproducible and verifiable structured spectroscopic results. Summary of the Invention
[0011] To address the aforementioned technical problems, this invention provides a method and system for automatic nuclear magnetic resonance spectrum analysis based on neural networks.
[0012] According to a first aspect of the present invention, a method for automatic nuclear magnetic resonance spectral analysis based on a neural network is provided, comprising:
[0013] Obtain the nuclear magnetic resonance frequency domain spectrum to be analyzed and the corresponding instrument observation frequencies;
[0014] Multiple sub-peaks are identified in the nuclear magnetic resonance frequency domain spectrum to be analyzed, and the interrelated sub-peaks are merged to form at least one peak group;
[0015] For each peak group, a multi-channel input feature is constructed, including the peak group signal, the first-order numerical derivative, the second-order numerical derivative, and the local position coordinates, wherein the local position coordinates are obtained based on the chemical shift of each frequency point within the peak group and the instrument observation frequency;
[0016] The multi-channel input features are input into a multi-peak classification neural network to obtain the classification probabilities corresponding to multiple preset multi-peak categories.
[0017] Based on the peak position, peak height, peak width, peak group boundary interval, and their interrelationships and the solvability of coupling constants of the sub-peaks within the peak group, physical verification is performed on the multiple preset multi-peak categories, and physical verification results and coupling constant analysis results corresponding to each preset multi-peak category are obtained.
[0018] Based on the classification probability and the physical verification results corresponding to each preset multipeak category, the predicted multipeak category of the peak group is determined;
[0019] For a specific multipeak category that is predicted to require the output of coupling constants, the peak group will be reverted to a complex multipeak m, or the specific multipeak category will be retained and a corresponding risk flag will be attached, if any of the following situations occur: the classification probability corresponding to the predicted multipeak category does not reach the preset confidence condition, the coupling constant parsing fails, or the physical verification fails.
[0020] In this scheme, by combining peak group-level neural network classification with physical verification based on the solvability of sub-peak structure and coupling constant, and by performing risk gating on specific categories with low confidence or that fail verification, the risk of erroneously outputting specific multiple peak categories in cases of complex splitting, overlapping peaks, and low signal-to-noise ratio can be reduced, thereby improving the verifiability and reliability of the analysis results.
[0021] Optionally, obtaining the nuclear magnetic resonance frequency domain spectrum to be resolved includes:
[0022] Acquire the original free induction decay signal or the frequency domain real spectrum processed by the manufacturer, and the acquisition parameters corresponding to the original free induction decay signal or the frequency domain real spectrum processed by the manufacturer. The acquisition parameters include at least one of the following: atomic nucleus type, instrument observation frequency sfo1, spectral width, emission bias, solvent, number of time domain sampling points, and number of frequency domain spectral points.
[0023] When the frequency domain real spectrum processed by the manufacturer has complete processing parameters, the frequency domain real spectrum processed by the manufacturer is directly read, and the chemical shift axis is calculated inversely based on the spectral width, the emission bias, the instrument observation frequency and the number of frequency domain spectral points to obtain the nuclear magnetic resonance frequency domain spectrum to be analyzed.
[0024] When the frequency domain real spectrum processed by the manufacturer with complete processing parameters is not obtained and the original free induction attenuation signal is obtained, the original free induction attenuation signal is preprocessed to obtain the nuclear magnetic resonance frequency domain spectrum to be analyzed.
[0025] The types of atomic nuclei include hydrogen nuclei, carbon nuclei, and fluorine nuclei, and the acquisition parameters are read from the data files of at least one of the instruments Bruker, Varian, and JEOL.
[0026] In this scheme, by being compatible with the original free induction attenuation signal and the frequency domain real spectrum processed by the manufacturer, and by reading the data files and related acquisition parameters of different instruments, it can adapt to the data formats of different instruments such as Bruker, Varian and JEOL, reducing the need for manual data conversion and configuration of spectrum parameters; by using actual instrument observation frequencies to inversely calculate the chemical shift axis, it also helps to ensure the consistency of subsequent coupling constant calculations.
[0027] Optionally, the preprocessing includes:
[0028] A window function is selected based on the type of atomic nucleus to apodize the original free-induction decay signal;
[0029] The attenuated free-induction signal after apodization is zeroed out to a preset length;
[0030] A fast Fourier transform is performed on the zero-padded free induction attenuation signal to obtain the complex spectrum;
[0031] Automatic phase correction is performed on the complex spectrum to obtain the phase-corrected real spectrum; and
[0032] Baseline correction is performed on the phase-corrected real spectrum to obtain the nuclear magnetic resonance frequency domain spectrum to be analyzed;
[0033] The window function includes at least one of the following: exponential window, Gaussian window, sine clock window, sine square window, and TRAF window;
[0034] This is so that: when the frequency domain real spectrum processed by the manufacturer is directly provided by a JEOL instrument, the apodization and fast Fourier transform are skipped; when the frequency domain real spectrum processed by the manufacturer is provided by a Bruker instrument, the direction of the inversely calculated chemical shift axis is adjusted so that the chemical shift axis is arranged in descending order of value.
[0035] In this scheme, by selecting a window function according to the type of atomic nucleus and performing apodization, zero-padding, FFT, phase correction and baseline correction in sequence, the peak shape, digital sampling density and baseline quality of the frequency domain spectrum after the original FID conversion can be improved, and the stability of subsequent sub-peak identification and peak group division can be improved. By adopting corresponding processing branches for JEOL and Bruker data, the compatibility of frequency domain data from different instruments can be further improved.
[0036] Optionally, identifying multiple sub-peaks and merging interrelated sub-peaks into at least one peak group includes:
[0037] The noise level is estimated based on the intensity signal of the nuclear magnetic resonance frequency domain spectrum to be analyzed, and the noise level is calculated according to the following formula:
[0038] Where σ is the noise level. The intensity of the nuclear magnetic resonance frequency domain spectrum to be analyzed
[0039] The peak group signal is obtained by intercepting the peak group at the boundary of the nuclear magnetic resonance frequency domain spectrum to be analyzed.
[0040] Initial sub-peaks are identified based on peak height thresholds and peak prominence thresholds related to the noise level;
[0041] A shoulder peak detection threshold higher than the peak height threshold is used to identify shoulder peaks located in the vicinity of the initial sub-peak that are not fully characterized by the initial sub-peak.
[0042] Search from the peak position of each sub-peak to both sides until the signal strength is lower than the boundary threshold, or the search distance reaches a preset multiple of the half-width of the sub-peak, to obtain the peak group boundary interval of each sub-peak.
[0043] Sub-peaks that overlap within the boundary intervals of a peak group are merged into the same peak group.
[0044] In this scheme, by adaptively setting peak height and peak prominence thresholds based on noise levels, and combining shoulder peak detection, boundary search based on half-width limit, and merging of overlapping boundary intervals, it is possible to identify insufficiently characterized sub-peaks near strong peaks and group sub-peaks with splitting correlation into the same peak group, thereby improving the integrity of peak group formation under conditions of overlapping peaks, shoulder peaks, and weak peaks.
[0045] Optionally, the multi-peak classification neural network includes a one-dimensional convolutional feature extractor, a location embedding network, a self-attention encoder, a main classification head, and an auxiliary head;
[0046] The peak group signal, the first-order numerical derivative, and the second-order numerical derivative are input into a one-dimensional convolutional feature extractor to obtain local features;
[0047] The local location coordinates are input into the location embedding network to obtain location embedding features;
[0048] The local features are fused with the location embedding features, and the fused features are input into the attention encoder to obtain the encoded features;
[0049] The encoded features are input into the main classification head and the auxiliary head respectively. The main classification head outputs the classification probabilities corresponding to multiple preset multi-peak categories, and the auxiliary head outputs the auxiliary classification result of whether the peak group belongs to a simple peak group or a complex peak group.
[0050] The preset multipeak category includes at least one of the following: single peak s, double peak d, triple peak t, quartet q, quintet p, hexapet h, heptaple peak sep, double double peak dd, double triple peak dt, triple double peak td, triple double double peak ddd, and complex multipeak m.
[0051] In this scheme, a one-dimensional convolutional feature extractor is used to extract peak shape and derivative features, a position embedding network is used to represent local frequency positional relationships, a self-attention encoder is used to model the global correlation between sub-peaks, and a main classification head and a simple / complex peak group auxiliary classification head are combined to improve the ability to distinguish between single peaks, regular split peaks and complex multi-peaks, which is especially beneficial for learning features of complex peak groups.
[0052] Optionally, the peak group signal, the first-order numerical derivative, and the second-order numerical derivative constitute three convolution input channels, and after being standardized with zero mean and unit variance respectively, the local features are obtained by the one-dimensional convolution feature extractor.
[0053] The local location coordinates do not undergo the same normalization process as the peak group signal, the first-order numerical derivative, and the second-order numerical derivative, and the location embedding features are obtained through the location embedding network;
[0054] The one-dimensional convolutional feature extractor includes three sequentially connected one-dimensional convolutional layers. The number of input channels and output channels of the three one-dimensional convolutional layers are 3 to 32, 32 to 64 and 64 to 128, respectively, and the kernel widths are 7, 5 and 3, respectively.
[0055] The location embedding network has an input dimension of 1, a hidden layer dimension of 64, and an output dimension of 128.
[0056] The self-attention encoder consists of 4 encoding layers, a feature dimension of 128, 8 attention heads, a feedforward dimension of 512, and a dropout rate of 0.1%.
[0057] In this scheme, by standardizing the peak group signal and its first and second numerical derivatives respectively, the influence of different peak intensities and dimensions on convolutional feature extraction can be reduced, and the valley points, shoulders, and fine split structures between peaks can be highlighted. By not performing the same standardization on the local position coordinates, the relative spacing information expressed in terms of actual frequency scale can be preserved. By limiting the network structure parameters of the convolutional network, the position embedding network, and the self-attention encoder, stable and repeatable model deployment and inference can be achieved.
[0058] Optionally, based on the peak position, peak height, peak width, peak group boundary interval, and their interrelationships and the solvability of the coupling constant of the sub-peaks within the peak group, physical verification is performed on the multiple preset multipeak categories, and the analytical results of the coupling constant corresponding to each preset multipeak category are obtained, including:
[0059] When the preset multiple peak category is a double peak, the coupling constant is obtained based on the frequency spacing between the two sub-peaks;
[0060] When the preset multipeak category is a triplet, quadruplet, quintuplet, hexaplet, or septuplet, the coupling constant is obtained based on the average value of the frequency spacing between adjacent sub-peaks.
[0061] When the preset multipeak category is a double doublet, two coupling constants are obtained based on the edge spacing and cross-group spacing of the four ordered sub-peaks.
[0062] When the preset multiple peak category is a double triplet or a triple doublet, two coupling constants are obtained based on the sub-peak spacing within the group and the sub-group center spacing.
[0063] When the preset multipeak category is triplet doublet, three coupling constants are obtained based on the edge differences of the eight ordered sub-peaks.
[0064] The coupling constant is determined based on the product of the chemical shift difference between sub-peaks and the instrument observation frequency; coupling constant J:
[0065] ;
[0066] in, Let be the coupling constant expressed in Hz. The chemical shift difference is expressed in ppm. The instrument observation frequency is expressed in MHz.
[0067] When the required number of sub-peaks for the corresponding category cannot be obtained, the sub-peaks cannot be sufficiently distinguished, the geometric relationship between the sub-peaks does not meet the analytical conditions for the corresponding category, or one or more coupling constants obtained exceed the preset range, the analysis of the coupling constants for the corresponding preset multipeak category is determined to be unsuccessful.
[0068] In this scheme, the coupling constant is calculated by using the corresponding sub-peak spacing, subgroup center spacing or edge difference for different multipeak categories, and the conversion from ppm to Hz is completed with the actual instrument observation frequency. This can provide verifiable coupling constant results for specific multipeak categories. By performing failure judgment on the required number of sub-peaks, resolution, geometric relationship and coupling constant range, unreliable coupling constants can be avoided when physical conditions are not met.
[0069] Optionally, determining the predicted multipeak category of the peak group based on the classification probability and the physical verification results corresponding to each of the preset multipeak categories includes:
[0070] For each of the preset multipeak categories, the corresponding classification probability is obtained, and the physical score is obtained based on the corresponding physical verification result;
[0071] The classification probability and the physical score are weighted and combined to obtain the combined score of each of the preset multipeak categories;
[0072] Based on the combined scores, multiple candidate multimodal categories are determined, and the candidate multimodal category with the highest classification probability and the complex multimodal candidate are retained.
[0073] The predicted multipeak category of the peak group is determined based on the multiple candidate multipeak categories.
[0074] In this scheme, by weighting and combining the classification probability of the neural network and the physical verification results, and simultaneously retaining high-probability candidate categories and complex multi-peak candidates, it is possible to avoid relying solely on the probability of a single neural network for decision-making. This allows multi-peak classification to have both data-driven basis and physical constraint basis, and achieves an adjustable balance between the coverage of specific category outputs and the risk of erroneous specific outputs.
[0075] Optional, also includes:
[0076] Write at least one of the following into a structured result: chemical shift, peak group boundary interval, sub-peak position, sub-peak height, sub-peak width, predicted multipeak category, classification probability, physical verification result, coupling constant analysis result, and risk indicator for each peak group, and output the structured result.
[0077] In this scheme, by writing peak group boundaries, sub-peak parameters, multiple peak categories, classification probabilities, physical verification results, coupling constant analysis results, and risk indicators into the structured results, the analysis results can be traced, verified, and easily read by reporting systems, databases, or other downstream analysis systems, thereby improving the reproducibility of the NMR analysis process.
[0078] According to a second aspect of the present invention, a neural network-based automatic nuclear magnetic resonance (NMR) spectrum analysis system is provided for implementing the neural network-based automatic NMR spectrum analysis method as described in any of the preceding claims, the system comprising:
[0079] The data acquisition unit is used to acquire the nuclear magnetic resonance frequency domain spectrum to be analyzed and the instrument observation frequency corresponding to the nuclear magnetic resonance frequency domain spectrum to be analyzed.
[0080] The peak identification and grouping unit is used to identify multiple sub-peaks in the nuclear magnetic resonance frequency domain spectrum to be analyzed, and to merge the interrelated sub-peaks into at least one peak group.
[0081] The feature construction unit is used to construct a multi-channel input feature for each of the peak groups, including the peak group signal, the first-order numerical derivative, the second-order numerical derivative, and the local position coordinates, wherein the local position coordinates are obtained based on the chemical shift of each frequency point within the peak group and the instrument observation frequency.
[0082] The neural network classification unit is used to input the peak group signal, the first-order numerical derivative, the second-order numerical derivative, and the local position coordinates into the multi-peak classification neural network to obtain the classification probabilities corresponding to multiple preset multi-peak categories.
[0083] The physical verification unit is used to perform physical verification on the multiple preset multipeak categories according to the peak position, peak height, peak width, peak group boundary interval, their interrelationships and the solvability of the coupling constant of the sub-peaks in the peak group, and to obtain the physical verification results and coupling constant analysis results corresponding to each preset multipeak category.
[0084] The decision unit is configured to determine the predicted multipeak category of the peak group based on the classification probability and the physical verification results corresponding to each of the preset multipeak categories; and, for a specific multipeak category predicted to require the output of a coupling constant, if any of the following situations occur, the peak group is reverted to a complex multipeak m, or the specific multipeak category is retained and a corresponding risk flag is attached; the situations include:
[0085] The predicted classification probability of the multimodal category did not meet the preset confidence condition, the coupling constant resolution failed, or the physical verification failed.
[0086] In this solution, a systematic processing architecture is constructed by a data acquisition unit, a peak identification and grouping unit, a feature construction unit, a neural network classification unit, a physical verification unit, and a decision-making unit. This architecture connects data reading, peak group formation, neural network classification, physical verification, and risk decision-making into a unified automatic process, reducing the workload of manual parameter connection and result verification between different processing stages.
[0087] In summary, compared with the prior art, the technical solution of the present invention has at least the following technical effects:
[0088] 1. By identifying sub-peaks and forming peak groups, and then classifying multiple peaks by peak groups, the interrelated split sub-peaks are treated as a whole, reducing the analytical error in complex splitting and adjacent sub-peak scenarios.
[0089] 2. The peak group signal, first-order numerical derivative, second-order numerical derivative, and local position coordinates are input into a multipeak classification neural network. Simultaneously, peak shape, shoulder peaks, fine splitting structures, and relative frequency distance expressed in Hz are utilized to improve the discrimination ability of complex multipeak categories such as dd, dt, and td. In ablation experiments, the macro-average F1 score supporting complex categories increased from 75.38% to 83.47%.
[0090] 3. Perform physical verification based on the number of sub-peaks, spacing, intensity relationship, area relationship, peak width relationship, and solvability of coupling constant, and determine the multi-peak category by combining the classification probability, so that the specific category output has the corresponding physical basis.
[0091] 4. When the classification probability is insufficient, the coupling constant resolution fails, or the physical verification fails, a complex multipeak m is output, or a low-confidence, physically unverified flag is added to reduce the risk of incorrect specific category output. In the strict gating implementation, the incorrect specific output rate is reduced from 5.25% to 2.00%. Attached Figure Description
[0092] Figure 1 A flowchart illustrating an automatic nuclear magnetic resonance spectrum analysis method based on a neural network, according to an embodiment of the present invention.
[0093] Figure 2 A flowchart of an automatic nuclear magnetic resonance spectrum analysis method based on a neural network, conforming to a specific embodiment of the present invention;
[0094] Figure 3 A diagram of the neural network structure for multi-peak classification based on neural networks;
[0095] Figure 4 Flowchart of a two-pass automatic phase correction method based on region of interest mask;
[0096] Figure 5 Flowchart of the integer integral solution method for candidate unit area and total loss;
[0097] Figure 6 A schematic diagram illustrating the construction of multi-channel input features for peak group signals, first-order numerical derivatives, second-order numerical derivatives, and local position coordinates;
[0098] Figure 7 This is a labeled diagram of the automatic analysis results of nuclear magnetic resonance spectra according to a specific embodiment of the present invention;
[0099] Figure 8 A flowchart of a two-stage fine-tuning method for physical simulation pre-training and real peak group fine-tuning of a multi-peak classification neural network;
[0100] Figure 9 The graph shows the evaluation results on the frozen test set of twelve multipeak categories;
[0101] Figure 10 The ablation experiment results for the derivative channel, local location coordinates, and auxiliary tasks in a multimodal classification neural network are shown in the figure.
[0102] Figure 11 A trade-off diagram of strict two-condition gating risk for classification probability and physical verification versus output coverage for specific multipeak categories. Detailed Implementation
[0103] To make the objectives, contents, and advantages of the present invention clearer, the specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples.
[0104] This invention provides an automatic nuclear magnetic resonance spectrum analysis method based on neural networks. Figure 1 A flowchart illustrating an automatic nuclear magnetic resonance spectrum analysis method based on a neural network, according to an embodiment of the present invention.
[0105] See Figure 1 The automatic nuclear magnetic resonance spectrum analysis method based on neural networks includes steps S1-S7:
[0106] S1: Obtain the nuclear magnetic resonance frequency domain spectrum to be analyzed and the corresponding instrument observation frequency;
[0107] S2: Identify multiple sub-peaks in the nuclear magnetic resonance frequency domain spectrum to be analyzed, and merge the interrelated sub-peaks to form at least one peak group;
[0108] S3: For each peak group, construct a multi-channel input feature including the peak group signal, first-order numerical derivative, second-order numerical derivative, and local position coordinates, wherein the local position coordinates are obtained based on the chemical shift of each frequency point within the peak group and the instrument observation frequency;
[0109] S4: Input the multi-channel input features into a multi-peak classification neural network to obtain the classification probabilities corresponding to multiple preset multi-peak categories;
[0110] S5: Based on the peak position, peak height, peak width, peak group boundary interval, and their interrelationships and the solvability of coupling constants of the sub-peaks within the peak group, physical verification is performed on the multiple preset multi-peak categories respectively, and physical verification results and coupling constant analysis results corresponding to each preset multi-peak category are obtained;
[0111] S6: Determine the predicted multipeak category of the peak group based on the classification probability and the physical verification results corresponding to each preset multipeak category;
[0112] S7: For predicted multipeak categories that require outputting coupling constants, if the classification probability does not reach the preset confidence level, coupling constant analysis fails, or physical verification fails, the peak group is output as a complex multipeak, or the specific multipeak category is retained with an added risk flag. This invention solves the problems of high reliance on manual intervention, insufficient accuracy and verifiability in complex multipeak identification and coupling constant analysis, poor compatibility of data from different instruments and nuclides, and difficulty in reproducing analysis results during nuclear magnetic resonance spectroscopy analysis.
[0113] Step S7 can be understood as follows: For a peak group predicted to be a specific multipeak category requiring the output of coupling constants, when any of the following occurs: the classification probability corresponding to the specific multipeak category does not reach the preset confidence condition, the coupling constant parsing fails, or the physical verification fails, the peak group is output according to a preset output strategy; wherein, the preset output strategy includes: under a strict backoff strategy, determining the multipeak category of the peak group as complex multipeak m and outputting it; or under a risk retention strategy, retaining the specific multipeak category and adding a corresponding risk flag according to at least one of the following: not reaching the preset confidence condition, the coupling constant parsing fails, or the physical verification fails.
[0114] like Figures 2-11 The specific embodiments shown provide a detailed description of the technical solution of the present invention.
[0115] See Figures 2-11 This invention relates to a neural network-based automatic nuclear magnetic resonance spectrum analysis method and system that automatically completes data reading, atomic nucleus type determination, spectrum preprocessing, sub-peak identification and peak group formation, multipeak classification, physical verification, coupling constant calculation, solvent peak and impurity peak identification, reference calibration, integer integral solving, and structured report generation, starting from the original free induction attenuation signal or the frequency domain real number spectrum already processed by the manufacturer.
[0116] Nuclear Magnetic Resonance (NMR) is an instrument that places a sample in a strong magnetic field and applies radio frequency pulses. The atomic nuclei in the sample, such as hydrogen, carbon, and fluorine nuclei, produce response signals that can be detected by the instrument. The raw signal acquired by the instrument is called the Free Induction Decay (FID). FID is a time-domain signal, typically exhibiting an oscillating signal that gradually decays over time. The system converts the FID into a frequency-domain signal using a Fast Fourier Transform (FFT). The resulting NMR frequency spectrum is typically plotted with chemical shift on the x-axis and signal intensity on the y-axis. The unit of chemical shift is parts per million (ppm).
[0117] Due to the influence of instrument acquisition, reception, and signal processing conditions, the NMR frequency domain spectrum obtained by Fast Fourier Transform may contain phase errors. Phase errors can cause spectral peaks to exhibit alternating positive and negative peaks, peak tilting, dispersive shapes, or asymmetric shapes. Therefore, phase correction is necessary to make the spectral peaks as positive and symmetrical as possible. The NMR frequency domain spectrum may also contain slowly fluctuating background signals, i.e., a baseline. If the baseline is not removed, peak height, peak width, original peak area, noise estimation, and integration results will all be affected.
[0118] In a chemical environment, an atomic nucleus may appear as a single sub-peak in the NMR spectrum to be analyzed, or it may split into multiple sub-peaks due to spin coupling between adjacent nuclei. A group of interconnected sub-peaks formed by the splitting of a signal is called a peak set, or multiplet. The spacing between sub-peaks within a peak set can be converted into a coupling constant, denoted as . The unit is Hz. The coupling constant is an important basis for determining molecular structure. In the proton spectrum, the original area of a peak group is usually proportional to the number of hydrogen atoms it represents. The system needs to convert the original area of the peak group into an integer number of hydrogen atoms. This process is called integral quantification.
[0119] This embodiment employs twelve categories of multipeaks, including singlet (s), doublet (d), triplet (t), quartet (q), quintet (p), sextet (h), heptatet (sep), double doublet (dd), double triplet (dt), triple doublet (td), triple double doublet (ddd), and complex multipeaks (m) that cannot be reliably resolved according to a preset specific category. Here, s stands for singlet, d for doublet, t for triplet, q for quartet, p for pentet, h for hexetet, sep for septet, dd for doublet of doublets, dt for doublet of triplets, td for triplet of doublets, ddd for doublet of doublets, and m represents complex multipeaks. The above category set can be added, deleted, merged, or subdivided according to application requirements and is not a necessary limitation of this invention.
[0120] The technical problems to be solved by this invention include: reducing reliance on manual phase correction, baseline correction, peak finding threshold, and integral reference peak; improving automatic resolution capabilities under conditions of peak overlap, peak distortion, low signal-to-noise ratio, and complex splitting; enabling proton, carbon, and fluorine spectra to automatically select processing parameters and processing branches based on the type of atomic nucleus; combining neural network classification results with NMR physics rules to reduce the output of specific multiple peak categories without reliable physical basis; automatically solving integer integrals without manually specifying an integral reference peak; and outputting analysis results in machine-readable, visualized, and natural language formats, while saving the running configuration to ensure reproducibility of the results.
[0121] Figure 2 The following is a flowchart of an automatic nuclear magnetic resonance spectrum analysis method based on a neural network, in accordance with a specific embodiment of the present invention.
[0122] See Figure 2The system of this invention consists of three sequentially connected functional stages. The first stage is a preprocessing module, code-class name NMRProcessor; the second stage is a spectrum analysis module, code-class name NMRSolver; and the third stage is a reporting module, code-class name NMRReporter. The preprocessing module reads the raw FID and its acquisition parameters, or reads the manufacturer-processed frequency domain real spectrum and its processing parameters, performs at least one of the following processing steps: apodization, zero-padding, FFT, automatic phase correction, and baseline correction, and outputs the NMR frequency domain spectrum object to be analyzed. The spectrum analysis module further performs sub-peak identification and peak group formation, multipeak classification, physical verification and coupling constant calculation, solvent peak identification, impurity peak identification, reference calibration, secondary filtering, and integer integral solving on the NMR frequency domain spectrum object to be analyzed. The reporting module converts the analysis results into a peak object list, peak group objects, visualized data, machine-readable results, and natural language spectroscopic text.
[0123] The processing order of the spectrum analysis module corresponds to the `run` method in `specxmaster / solver.py`. The system first executes `self.finder.analyze(spectrum)` to identify sub-peaks and form peak groups; then it executes `self.fitter.fit(spectrum)` to complete multipeak classification, physical verification, and coupling constant calculation; subsequently, it executes `self.solvent_id.identify(spectrum)` to identify solvent peaks, `self.impurity_id.identify(spectrum)` to identify impurity peaks, `self.ref_aligner.align(spectrum)` to perform reference calibration, and finally `self.secondary_filter.apply(spectrum)` for secondary filtering. When the atomic nucleus type of the spectrum object is 1H or 19F, the system executes...
[0124] The `self.integral_solver.apply(spectrum)` method performs integer integration and returns the processed spectrum object.
[0125] The system employs a three-level data structure to store intermediate results. The first level is the peak object (Peak), which records information such as the index, chemical shift, peak height, full width at half maximum (FWHM), signal-to-noise ratio (SNR), and validity of each individual sub-peak. The second level is the peak group object (PeakGroup), which records the sub-peaks contained in a multipeak or integration unit, start and end boundaries, original area of the peak group, multipeak category, coupling constant, peak type, integer integral, classification probability, candidate multipeak category, and physical verification flags. The third level is the spectrum object (Spectrum), which records the chemical shift axis, signal intensity, atomic nucleus type, instrument observation frequency, solvent, reference offset, and all peak groups.
[0126] The system first reads the instrument file and determines the type of atomic nuclei. Preprocessing-related code is mainly located in specxmaster / processor.py, specxmaster / preprocessing / signal_processor.py, and specxmaster / preprocessing / fid_io.py. The system supports automatic identification of Bruker, Varian, and JEOL instrument formats and extracts the instrument observation frequency (sfo1), spectral width, emission bias, solvent, number of time-domain sampling points, number of frequency-domain spectral points, and other parameters required for spectral axis calculation from the acquisition parameters. The type of atomic nuclei is primarily determined based on the atomic nucleus field in the instrument parameters; when the atomic nucleus field is missing, the system uses a heuristic rule, i.e., calculating the ppm range corresponding to the ratio of spectral width to fundamental frequency. If this value is greater than a preset threshold, the NMR frequency-domain spectrum to be resolved is predisposed to be a carbon spectrum; otherwise, it is predisposed to be a proton spectrum. In one embodiment, the preset threshold is... The actual instrument observation frequency sfo1 is not only used for judgment and spectral axis processing, but also affects the subsequent conversion from ppm to Hz and the calculation of coupling constants. Therefore, the production implementation preferred to use the actual observation frequency on a spectrum-by-spectrum basis; fixing the nominal frequency may reduce cross-instrument consistency.
[0127] After reading the parameters, the system selects a dual-path processing method based on the input data status. If the instrument provides a manufacturer-processed real-valued frequency domain spectrum with complete corresponding processing parameters, the system directly reads this spectrum and then calculates the chemical shift axis based on the emission bias, spectral width, instrument observation frequency, and number of spectral points to obtain the NMR spectrum to be analyzed, skipping time-domain apodization, zero-padding, and Fourier transform. If a complete manufacturer-processed real-valued frequency domain spectrum is unavailable, or its processing parameters are incomplete, the system reads the original complex FID and enters the complete free-induction attenuation signal processing path. This path includes apodization, zero-padding, FFT, necessary spectral axis adjustment, automatic phase correction, and baseline correction. The phase parameters and processing parameters used during operation are written into the operating configuration to ensure that the processing results can be reproduced under the same data and configuration.
[0128] In one implementation, for the real-valued frequency domain spectrum directly provided by a JEOL instrument, the system automatically skips apodization and fast Fourier transform, and passes the real-valued frequency domain spectrum to subsequent processing. For the real-valued frequency domain spectrum provided by a Bruker instrument, the system adjusts the orientation of the inversely calculated chemical shift axes so that the chemical shift axes are arranged in descending order of value.
[0129] In one implementation, the system first performs apodization on the original FID. Apodization involves multiplying the time-domain signal by a window function. Let the time axis be:
[0130]
[0131] in, For time-domain sampling point index, The spectral width is given. The apodized free-induction attenuated signal can be expressed as the product of the original FID and a window function. The system supports five window functions: exponential window, Gaussian window, sine clock window, sine square window, and traf window. The exponential window can be expressed as:
[0132] The Gaussian window can be represented as:
[0133] A sine clock window can be represented as:
[0134] The sine square window can be represented as:
[0135]
[0136] The traf window can be represented as:
[0137] in, This is the line broadening parameter, in Hz. For parameters related to Gaussian windows,
[0138] This represents the maximum value on the time axis. These are the bias parameters for the sinusoidal clock window. The system selects default values based on the type of atomic nucleus; for the proton and fluorine spectra, the values are... Carbon spectrum For JEOL data already in the frequency domain, the system automatically skips apodization.
[0139] In one implementation, after apodization, the system zero-padding the time-domain signal and performing an FFT. The system zero-padding the time-domain signal... The data is then processed using a Fast Fourier Transform (FFT) to obtain the complex spectrum. Zero-padding does not increase the true physical resolution determined by the original acquisition time, but it increases the digital sampling density of the frequency axis, making the peak shape display smoother. It also helps with sub-peak location, sub-peak spacing calculation, peak group boundary interval estimation, and subsequent resampling. For Bruker spectra, the system reverses the chemical shift axis to ensure that the chemical shift axis is arranged according to the common NMR display direction from low field to high field, i.e., the values are arranged from large to small. For JEOL frequency domain data, the system transmits it directly.
[0140] Figure 4 Flowchart of a two-pass automatic phase correction method based on region-of-interest masks. (See attached diagram.) Figure 4 The FFT yields a complex spectrum, requiring phase correction. The system implements automatic phase correction in `specxmaster / preprocessing / phase_correction.py`, employing the entropy minimization-based automatic phase correction method ACME. ACME stands for Automatic Correction of Phase Equation. The system uses a strategy of using a Region of Interest (ROI) mask followed by two rounds of mask reconstruction to improve phase stability in weak signals and multi-peaked spectra.
[0141] The system's phase model includes zero-order phase and first-order phase. Zero-order phase parameters... A uniform rotation is performed on the entire nuclear magnetic resonance frequency domain spectrum to be analyzed, and the first-order phase parameter... It varies linearly with frequency position. For the th For each frequency point, the ordinary phase model can be expressed as:
[0142] The phase-corrected complex spectrum can be expressed as:
[0143] in, For the number of spectral points in the frequency domain, For the first Complex spectrum signal at one frequency point For phase
[0144] The corrected complex spectrum signal, It is the imaginary unit.
[0145] When using a pivot point, the phase model can be expressed as:
[0146] in, This indicates the pivot point location. The proton and carbon spectra were obtained using a double-pass method along the region of interest.
[0147] Fluorine spectroscopy employs a phase correction method with a pivot point.
[0148] In one implementation, phase correction first constructs a Region of Interest (ROI) mask. The system calculates the complex spectral amplitude and selects a certain percentage of the frequencies with the highest amplitude as the Region of Interest (ROI). By default, the frequencies with the highest amplitude are selected. The system can select frequency points and expand the mask to cover the region near the peak. Subsequently, the system evaluates the ACME objective function only within the ROI, rather than allowing all noisy regions to equally affect the optimization.
[0149] The objective function consists of a first-order difference distribution entropy term and a negative intensity penalty term. The real spectrum obtained after candidate phase parameter correction... , No. Each first-order difference can be expressed as:
[0150] After normalizing the first-order difference, we can obtain:
[0151] The entropy term can be expressed as:
[0152]
[0153] The negative intensity part can be represented as:
[0154] The negative intensity penalty term can be expressed as:
[0155]
[0156] The phase optimization objective can be expressed as:
[0157] in, For the first ROI mask value at each frequency point For negative intensity penalty weights,
[0158] The number of effective frequency points within the ROI. This represents the maximum peak intensity used for normalization.
[0159] In one embodiment,
[0160]
[0161] The entropy term is used to evaluate the complexity of the first-order difference distribution. When the phase correction is reasonable, the peak shape in the frequency domain spectrum of the NMR to be analyzed is clearer, and the objective function is usually smaller. The negative intensity penalty term is used to suppress the appearance of negative peaks after phase correction. The system uses multiple different initial phase parameters for multi-starting-point optimization to reduce the influence of local optima of the objective function on the results, obtaining the first-pass zero-order phase parameters and first-order phase parameters.
[0162] After the first phase correction, the system reconstructs the peak mask based on the phase-corrected real spectrum. Specifically, median filtering is performed first, then the median filtering residual is calculated, peaks are detected using the MAD threshold, and the detection results are used for mask reconstruction. Subsequently, a second round of optimization is performed using the phase parameters from the first round as initial values. Multiple iterations can be performed if necessary. Finally, the system outputs the phase-corrected real spectrum, zeroth-order phase parameters, first-order phase parameters, and optional pivot parameters, and these parameters are written into the runtime configuration.
[0163] After phase correction, the system performs baseline correction. The baseline correction code is located in specxmaster / preprocessing / baseline_correction.py. This invention's baseline correction only uses non-peak points to fit the baseline, thus avoiding the actual peaks from raising the fitted baseline.
[0164] The system first performs median filtering on the NMR frequency domain spectrum to be resolved to obtain a coarse baseline reference. Then, it calculates the residual, which is the original NMR frequency domain spectrum minus the coarse baseline. The system uses the median absolute deviation (MAD) to estimate the residual dispersion and follows the principle that "the residual is greater than the peak detection factor multiplied by..." Peak points are identified by multiplying by the residual MAD. (Constant) This is used to convert the MAD scale to an approximate standard deviation scale. After obtaining the peak points, the system performs binary dilation on the peak points to form a peak mask. Positions within the peak mask are considered to belong to the true peak region, while other positions are considered non-peak regions.
[0165] The system performs polynomial fitting only in non-peak regions. For proton and fluorine spectra, an eighth-order polynomial is used for a single-order fitting by default, and the fitting baseline is subtracted from the original NMR spectrum to be resolved. For carbon spectra, the system attempts tenth, seventh, fifth, third, and first-order polynomials sequentially until a suitable order is found, and then the fitting baseline is subtracted from the original NMR spectrum to be resolved.
[0166] After polynomial baseline trimming, the carbon spectrum is further refined using second-order Whittaker smoothing. The system first calculates the minimum envelope using a 201-point sliding minimum, and then solves it using Whittaker smoothing.
[0167] in, It is the identity matrix. It is a second-order difference matrix. For smooth strength, To smooth the results, This is the sliding minimum envelope. In one embodiment, Finally, the system subtracts the 10th percentile of the residual to eliminate the positive bias.
[0168] In one implementation, after phase and baseline correction, the system performs sub-peak identification and peak group formation in specxmaster / peaks / component_finder.py. The system first uses MAD to estimate the noise level, and the noise standard deviation can be expressed as:
[0169] in, The intensity signal of the nuclear magnetic resonance frequency domain spectrum to be analyzed. The noise level is then set. The system then invokes a peak-finding algorithm, applying different detection thresholds based on the type of atomic nucleus. The peak height threshold for the hydrogen spectrum is approximately... The peak height thresholds for carbon and fluorine spectra are approximately [value missing]. The peak prominence threshold is approximately .
[0170] For each detected sub-peak, the system calculates its peak position, peak height, full width at half maximum (FWHM), and signal-to-noise ratio (SNR). The SNR can be expressed as:
[0171] in, This represents the peak height of the sub-peak. Sub-peaks below the corresponding threshold are marked as invalid.
[0172] To detect potentially obscured weak shoulder peaks next to large peaks, the system performs a second peak search. Shoulder peak detection uses a threshold higher than the peak height threshold, for example... The detected shoulder peaks are added as sub-peaks within the peak group, while candidate sub-peaks that are too close to existing sub-peaks are excluded.
[0173] The system then expands the search for sub-peak boundaries to the left and right from the peak position of each sub-peak until the signal intensity is lower than the boundary threshold corresponding to the type of atomic nucleus, or the search distance reaches a preset multiple of the full width at half maximum (FWHM) of the sub-peak, thus obtaining the peak group boundary intervals of each sub-peak. The boundary threshold for the proton spectrum is... The boundary thresholds for carbon and fluorine spectra are The maximum search range is limited to three times the half-width and height, i.e. The height and width are 1 / 2, thus preventing the sub-peak boundaries from extending infinitely into distant noise regions.
[0174] If the boundary intervals of multiple sub-peaks overlap, the system merges these intervals into a single peak group. The system uses trapezoidal integrals to calculate the original area of the peak group and intensity-weighted averaging to calculate the chemical shift of the peak group's centroid. Let the peak group boundary interval contain the first peak. The chemical shift at each frequency point is The signal strength is Then the chemical shift of the peak group's centroid can be expressed as:
[0175] in, To prevent extremely small values where the denominator is zero, the peak group object records information such as start and end boundaries, internal sub-peaks, sub-peak positions, peak heights, peak widths, original peak group area, chemical shift of the peak group's centroid, and validity. This peak group serves as input for neural network classification, as well as for subsequent physical model scoring, coupling constant analysis, solvent peak identification, impurity peak identification, reference calibration, and integer integral solving. The relevant code for multipeak classification includes specxmaster / multiplets / multiplet_fitter.py, specxmaster / utils / model_manager.py, specxmaster / multiplets / nmr_physics.py, and the model code nmr_peak_model. Multipeak classification consists of multi-channel feature construction, neural network classification, joint decision-making based on classification probability and physical verification, and coupling constant analysis. It employs a two-stage training method: physical simulation pre-training followed by fine-tuning with real data.
[0176] For each peak group, the system takes the interval covered by its leftmost to rightmost effective sub-peaks as the input window for the neural network. This window is independent of the user-adjustable integration boundary. The classification window is used to determine the category of the multipeaks, while the integration boundary is used to calculate the original area of the peak group; the two do not share the same variable boundary.
[0177] In one implementation, the system will select the first peak within the peak group. Chemical shift at each frequency point With instrument observation frequency Multiplying them together gives the frequency position in Hz:
[0178] in, The unit is ppm. The unit is MHz. The unit is Hz. Then, the system calculates, with the weighted center of the peak signal intensity as the origin:
[0179] And obtain the local position coordinates:
[0180] in, For the first Signal strength at each frequency point To avoid extremely small constants that divide by zero. Substitute
[0181] The code implementation is as follows:
[0182] Python
[0183] signal = intensity[start_idx : end_idx + 1]pos_hz = ppm_axis[start_idx : end_idx + 1] sfo1weight_center = np.sum(pos_hz signal) / (np.sum(signal) + 1e-6)pos = pos_hz - weight_center
[0184] This local centering method ensures that when the peak group undergoes a chemical shift, the local position coordinates remain essentially unchanged, and the relative distance between sub-peaks, expressed in Hz, is preserved.
[0185] Figure 6 A schematic diagram illustrating the construction of multi-channel input features for peak group signals, first-order numerical derivatives, second-order numerical derivatives, and local position coordinates. (See also...) Figure 6 The system linearly resamples the variable-length window to 512 points, constructing peak group signals, first-order numerical derivatives, second-order numerical derivatives, and local location coordinates. The peak group signals, first-order numerical derivatives, and second-order numerical derivatives serve as the three input channels of a one-dimensional convolutional feature extractor, while the local location coordinates are input separately into the location embedding network.
[0186] The first-order numerical derivative is calculated using `np.gradient(signal)`, and the second-order numerical derivative is obtained by applying `np.gradient` again to the first-order numerical derivative. The peak group signal, first-order numerical derivative, and second-order numerical derivative are standardized to zero mean and unit variance, respectively. Local position coordinates are not standardized together with the first three channels to preserve the physical scale of the actual frequency spacing. The construction code is as follows:
[0187] Python
[0188] d1 = np.gradient(signal)d2 = np.gradient(d1)x = np.stack([signal, d1,d2], axis=0)x = (x - x.mean(axis=1, keepdims=True)) / ( x.std(axis=1,keepdims=True) + 1e-6)
[0189] The local position coordinates pos are passed as independent inputs to the position embedding network. By multiplying ppm by the actual instrument observation frequency sfo1 to obtain the Hz coordinates, the same coupling constant can correspond to a more consistent physical distance at different instrument observation frequencies. Therefore, the local position coordinates are not ordinary sequence numbers, but frequency coordinates with NMR physics meaning.
[0190] Figure 3 A diagram of the neural network structure for multimodal classification. (See also...) Figure 3 The neural network class, named NMRNet, includes a one-dimensional convolutional feature extractor, a location embedding network, a self-attention encoder, a main classifier head, and an auxiliary classifier head. Peak group signals, first-order numerical derivatives, and second-order numerical derivatives are input to the one-dimensional convolutional feature extractor to extract local features; local location coordinates are input to the location embedding network to obtain location embedding features; the local features and location embedding features are fused and input to the self-attention encoder; after global average pooling, the main classifier head outputs the classification probabilities corresponding to the preset multi-peak categories, and the auxiliary classifier head outputs the auxiliary classification result indicating whether the peak group belongs to a simple peak group or a complex peak group.
[0191] The one-dimensional convolutional feature extractor consists of three one-dimensional convolutional layers, with the number of channels as follows: The kernel widths are as follows: Each layer uses the same length padding, batch normalization, and the GELU activation function. The code is as follows:
[0192] Python
[0193] nn.Conv1d(3, 32, 7, padding=3),nn.BatchNorm1d(32),nn.GELU(),nn.Conv1d(32, 64, 5, padding=2),nn.BatchNorm1d(64),nn.GELU(),nn.Conv1d(64, 128, 3,padding=1),nn.BatchNorm1d(128),nn.GELU()
[0194] If we perform an ablation experiment that removes the first-order and second-order numerical derivative channels, the number of input convolution channels is changed from 3 to 1, while the rest of the network structure remains unchanged.
[0195] The position-aware self-attention encoder consists of 4 layers, a feature dimension of 128, 8 attention heads, a feedforward dimension of 512, a dropout rate of 0.1, and uses GELU as the activation function. Local position coordinates are mapped from one-dimensional to a 128-dimensional embedding using a multilayer perceptron.
[0196] Python
[0197] self.pos_embedding = nn.Sequential( nn.Linear(1, 64), nn.GELU(),nn.Linear(64, 128))
[0198] After dimensionality adjustment, the convolutional features are added position-by-position to the positional embeddings and then input into the encoder.
[0199] Python
[0200] x = x.permute(0, 2, 1)x = x + self.pos_embedding(pos.unsqueeze(-1))x= self.encoder(x)
[0201] The control model that does not use local position coordinates does not use the aforementioned position-aware multilayer perceptron, but retains ordinary fixed sinusoidal sequence position encoding, thereby avoiding the confusion between "removing local position coordinates" and "completely lacking sequence order".
[0202] After passing through the self-attention encoder, the system performs global average pooling and outputs the results through the main classification head and auxiliary classification heads. The main classification head is:
[0203] Python
[0204] self.class_head = nn.Sequential( nn.Linear(128, 128), nn.GELU(),nn.Dropout(0.2), nn.Linear(128, 12))
[0205] The auxiliary classification head is:
[0206] Python
[0207] self.group_head = nn.Sequential( nn.Linear(128, 64), nn.GELU(),nn.Linear(64, 2))
[0208] The main classification header outputs the classification probabilities corresponding to the twelve multipeak categories. The auxiliary classification header outputs the auxiliary classification results for simple or complex peak groups. In the current embodiment, dd, dt, td, ddd, and m are classified into the complex peak group, while the remaining categories are classified into the simple peak group.
[0209] Figure 8 This is a flowchart illustrating the two-stage fine-tuning method for physical simulation pre-training and real peak group fine-tuning of a multi-peak classification neural network. (See also...) Figure 8 The model training employs a two-stage process: pre-training using physical simulation and fine-tuning using real data. The physical simulation data is used to construct a complex FID in the time domain, which can be represented as:
[0210] in, For the first The relative intensity of each sub-peak For line width, The intensity is determined by the center frequency and one or more coupling constants. First-order split samples are generated according to the corresponding binomial intensity relationship. Complex multipeak m-type samples are generated by superimposing sub-multipeaks, free peaks, broad peaks, or combinations that cannot be stably classified into a preset specific multipeak category.
[0211] The simulation process can incorporate complex white noise, phase distortion, baseline drift, linewidth variation, exponential apodization, fast Fourier transform, dynamic bounding, and 512-point resampling. This ablation experiment consistently used the same batch of 24,000 simulated samples, the same random seed, and the same number of training epochs to ensure that only specified features were changed between different models.
[0212] The real data was automatically parsed and exported as text by MestReNova. Applicants filtered the automatic results for 1,980 peak groups whose boundaries and multipeak categories were clearly confirmed as correct, forming the `confirmed_correct.csv` file. This dataset should be referred to as a "human-confirmed subset of correct MestReNova results," and not as a full-spectrum expert gold standard independent of commercial software. This set can be used for real-world peak shape transfer learning and internal ablation experiments.
[0213] Real-world data is divided into either complete spectra or raw FIDs. The training set includes 264 spectra and 1,380 peak groups, the validation set includes 40 spectra and 200 peak groups, and the frozen test set includes 80 spectra and 400 peak groups, totaling 384 spectra and 1,980 peak groups. No two sets have the same spectra identifier or the same SHA-256 hash of the raw FID. The frozen test set is evaluated only once after all checkpoints are determined and is not used for training, early stopping, threshold selection, physical gating parameter selection, or candidate ranking calibration.
[0214] The simulated data is pre-trained for 100 training epochs with a batch size of 64, using AdamW as the optimizer, and an initial learning rate of... The weight decays to When fine-tuning with real data, simulated samples are added to the training set according to categories for balanced mixing, with a default target scaling factor of 1.5. In the first stage, the one-dimensional convolutional feature extractor, location embedding network, and self-attention encoder are frozen, and only the main and auxiliary classification heads are trained for 5 training epochs. In the second stage, all networks are unfrozen and trained for 20 training epochs, with the output head learning rate being [missing information]. The learning rates of the self-attention encoder, the one-dimensional convolutional feature extractor, and the location embedding network are... The batch size is 32.
[0215] Both the primary classification task and the auxiliary classification task with simple or complex peak groups use cross-entropy loss, and the total loss can be expressed as:
[0216] in, The main multimodal classification cross-entropy loss, The auxiliary classification cross-entropy loss is used for simple or complex peak groups. The ablation model without auxiliary tasks maintains the same network parameter layout, only setting the auxiliary loss weights to zero to eliminate the impact of changes in the number of parameters.
[0217] After training, the model is exported as a TorchScript file. The deployment package accepts the variable-length peak group signal and local location coordinates as input, and performs resampling, intensity weighting and centering, first-order numerical derivative calculation, second-order numerical derivative calculation, standardization, and classification probability normalization. The model is loaded as a singleton, automatically selecting either the graphics processor or the central processing unit. If the model does not exist or loading fails, the system can use an alternative parsing path based on physical rules or template matching.
[0218] In one implementation, for each preset multimodal category, the system obtains the classification probability output by the neural network. The physical verification is performed based on at least one of the following requirements for this category: number of sub-peaks, spacing between sub-peaks, sub-peak intensity relationship, sub-peak area relationship, sub-peak width relationship, sub-peak geometric relationship, and solvability of coupling constant, to obtain a physical score. One embodiment uses the following combination of scores:
[0219]
[0220] in, To preset multiple peak categories The combined score, The classification probability of the preset multipeak category. The system assigns a physical score to the preset multipeak category. When the physical verification result is invalid, the system attenuates the combined score of the corresponding multipeak category. The system determines multiple candidates based on the combined score and retains the candidate with the highest classification probability and the complex multipeak m candidate. Both the combined weight and the number of candidates are configurable.
[0221] In one implementation, for a single peak *s* and a complex multipeak *m*, the system can directly output the corresponding multipeak category without attaching a coupling constant. For other preset specific multipeak categories that require outputting coupling constants, the system makes a joint decision based on the classification probability and physical verification results. When the classification probability is greater than a preset confidence threshold, the coupling constant is within a preset range, the required subpeak is distinguishable, and the physical verification passes, the preset specific multipeak category and its corresponding coupling constant are output. When the classification probability does not reach the preset confidence condition, the coupling constant parsing fails, the coupling constant exceeds the preset range, the required subpeak cannot be sufficiently distinguished, or the physical verification fails, the peak group is output as a complex multipeak *m*, or the preset specific multipeak category is retained with an attached low confidence flag or a physical verification failure flag. In one embodiment, the preset confidence threshold is... The coupling constant range is to .
[0222] The pseudocode can be represented as:
[0223] Python
[0224] if pred_label in ("s", "m"):output(pred_label, j_values=[])else:j_values = infer_j_from_pattern(pred_label, peaks, sfo1)if confidence>0.6 andj_values and physical_checks_pass:output(pred_label, j_values=j_values)else:output("m", j_values=[])
[0225] The system also supports a coverage-preserving mode. When the joint decision-making conditions of classification probability and physical verification result are not met, the system still retains the specific multipeak category with the highest classification probability, but adds a "low confidence" or "physically unverified" flag, and simultaneously provides alternative candidates such as complex multipeak m. The mode of outputting complex multipeak m and the mode of retaining the specific multipeak category and adding a risk flag are two implementations of the same joint decision-making concept.
[0226] In one implementation, the coupling constant is calculated based on a conversion from ppm to Hz. This is when the chemical shift difference between sub-peaks... The frequency of instrument observations is expressed in ppm. When expressed in MHz, the coupling constant It can be represented as:
[0227] in, The unit is Hz. For a doublet d, the coupling constant is taken as the value between the two sub-peaks.
[0228] The frequency spacing is determined. For triplet t, quartet q, quintet p, hexapet h, and septapet sep, the coupling constant is the average of the frequency spacing between adjacent sub-peaks. For doublet dd, two coupling constants are determined based on the edge spacing of the four ordered sub-peaks and the cross-group spacing. For doublett dt and triplet doublettd, two coupling constants are determined based on the intra-group sub-peak spacing and the sub-group center spacing. For triple doubletddd, three coupling constants are determined based on the edge differences of the eight ordered sub-peaks. The coupling constant determination fails when the required number of sub-peaks cannot be obtained, the sub-peaks cannot be sufficiently distinguished, the geometric relationship of the sub-peaks does not meet the analytical conditions for the corresponding multipeak category, or an effective coupling constant within the preset range cannot be obtained.
[0229] In one implementation, after completing multiplet classification, physical verification, and coupling constant calculation, the system performs solvent peak identification, impurity peak identification, and reference calibration. Related documents are available.
[0230] The files `specxmaster / peaks / solvent_identifier.py`, `specxmaster / peaks / impurity_identifier.py`, and `specxmaster / peaks / reference_aligner.py` are used. Solvent peak identification is based on a solvent knowledge base, which includes solvents such as deuterated chloroform, deuterated dimethyl sulfoxide, deuterated methanol, and deuterated acetone, along with their characteristic peaks. The solvent peak matching tolerance for the proton NMR spectrum is [value missing]. The solvent peak matching tolerance of the carbon spectrum is .
[0231] When the chemical shift of a peak group falls within the matching tolerance range of the corresponding solvent characteristic peak, the system identifies the peak group as a solvent peak and writes the solvent peak label into the structured result of the peak group. If a single-peaked solvent peak is located in a peak group containing other sub-peaks, the system uses valley point segmentation, that is, it determines the valley point with the lowest signal intensity between the solvent peak and its adjacent sub-peaks, and segments the peak group at the valley point to isolate the solvent peak from other peak groups. For adjacent solvent lines in the carbon spectrum, the system combines the adjacent solvent lines and labels the combined peak group as a solvent peak.
[0232] In one implementation, impurity peaks are matched against a solvent-related impurity fingerprint library. Candidate peak groups must simultaneously satisfy the following conditions: chemical shift matches the impurity fingerprint, multiplet category matches the impurity fingerprint, and the original area of the peak group is smaller than the original area of the main peak. It was only after that that it was marked as an impurity peak.
[0233] In one implementation, a reference calibration is used to uniformly correct the chemical shifts of all peak groups. For proton NMR spectroscopy, TMS (tetramethylsilane) is preferentially used, approximately located at... For single peaks, solvent peaks are used first, followed by solvent peaks. For carbon and fluorine spectra, solvent peaks are used first, followed by TMS. The system calculates the global chemical shift based on the difference between the observed position and the standard position of the reference peak, and then shifts the chemical shifts of all peak groups to achieve automated chemical shift calibration.
[0234] After solvent peaks, impurity peaks, and reference peaks are identified, the system performs a secondary filter. This secondary filter comprehensively utilizes the results of multiple peak classification, coupling constant analysis, original peak area, solvent peak markers, impurity peak markers, and peak group validity to remove or mark peak groups unsuitable for use as analyte results. For proton and fluorine spectra, integer integration is performed after secondary filtering; for carbon spectra, different solvent region merging, single-peak processing, and weak signal verification methods are used, and the same integer integration is not performed.
[0235] Figure 5 Flowchart of the method for solving the integer integral of candidate unit area and total loss. (See also...) Figure 5 In one implementation, the integration module is located in
[0236] The `spexmaster / peaks / integral_solver.py` module is used for 1H NMR and fluorine NMR. This module does not require the user to specify a reference peak with a known number of atoms beforehand; instead, it automatically solves for the unit area based on the relationship between the original areas of multiple peak groups. The system first uses the five analyte peak groups with the largest original areas as anchor points, and then assumes a corresponding [value] for each anchor point. to Each atom forms a candidate unit area calculated as "anchor area divided by the assumed number of atoms". Simultaneously, the median of the original area of all candidate analyte peak groups divided by... and median divided by The candidate unit area.
[0237] For each candidate unit area The system calculates the first Area ratio of each peak group:
[0238] And calculate the most recent integer:
[0239]
[0240] in, For the first The original peak area of each analyte peak group It is the area ratio. For the corresponding integer integral. The total loss per unit area of the candidate sample includes the area-weighted relative residual square, soft-zero penalty, simplicity penalty, and minimum integer penalty, which can be expressed as:
[0241] in, The area-weighted relative residual squares. As a soft zeroing penalty, Penalty for simplicity The minimum integer penalty applies. The soft zeroing penalty is defined as follows: when the original area of the relative maximum peak group exceeds... When the peak group is zeroed out, the penalty value is The original area of the relative maximum peak group is to At that time, the penalty value is The original area of the relative maximum peak group is to At that time, the penalty value is The simplicity penalty is:
[0242] The simplicity penalty is used to avoid obtaining a large number of unnecessary large integers. The minimum integer penalty is used to prioritize bringing the smallest effective peak set closer to the nearest integer. The system uses a specific number of atoms to avoid amplifying all integers due to excessively small candidate unit areas. The system ultimately selects the candidate unit area with the minimum total loss.
[0243] In one implementation, after selecting the unit area, the system records the original peak area, area ratio, rounded integer integral, absolute rounding error, and integral confidence level for each analyte peak group. When the absolute rounding error exceeds... When the area ratio is not greater than 1, the corresponding integer integral is marked as high error. Or the integer integral is greater than When the integer integral is not found, it is marked as an abnormal candidate. Adjacent peak groups are only merged if conditions such as consistency in distance, number of peaks, and sub-peak spacing are met. After merging, the candidate unit area and integer integral are solved again. The current code also includes optional heuristics for certain integer boundaries, such as when the area ratio is approximately to And the initial rounding is When, it can be corrected to This value represents the area ratio range, not the chemical shift range.
[0244] In one implementation, the reporting module, located at specxmaster / reporting / , is responsible for converting spectral objects and peak group objects into machine-readable peak, peak group, candidate hypothesis, and classification probability structures, generating the data required for visualization and interaction, and generating natural language spectroscopic text. The report can also output multi-candidate solution results and risk indicators. The system writes at least one of the following parameters into the structured results: chemical shift, peak group boundary interval, sub-peak position, peak height, peak width, original peak group area, multipeak category, candidate multipeak category, classification probability, physical score, combination score, coupling constant, integer integral, physical verification result, solvent peak indicator, impurity peak indicator, and risk indicator for each peak group. The system writes at least one of the following parameters into the runtime configuration: phase correction parameters, baseline correction parameters, sub-peak identification parameters, candidate sorting parameters, physical gating parameters, and integration parameters.
[0245] For example, the system can output:
[0246] text
[0247] 1H NMR (400 MHz, CDCl3): 7.26 (s, 1H), 3.45 (t, J=7.2 Hz, 2H).
[0248] The phase, baseline, sub-peak identification, physical gating, candidate sorting, and integration parameters used during operation are all written into the configuration file to support reproduction.
[0249] The present invention also provides an example of a complete embodiment. Figure 7 This is a specific example of an automatic nuclear magnetic resonance spectrum analysis method based on neural networks, with a complete implementation diagram showing the analysis results. See also... Figure 7 The SMILES string for the example sample is:
[0250] text
[0251] CCOC(=O)c1cc(C=O)c[nH]1
[0252] The samples were prepared using DMSO as solvent. The raw FID values for the 1H and 1C spectra are located at tests / examples / H and tests / examples / C, respectively. The 1H spectrometer observation frequency is [missing information]. The carbon spectrometer observation frequency is The system will rerun from the original FID according to the current default process.
[0253] In the proton NMR spectroscopy processing, the system generated 56 initial peak groups from 90 original sub-peaks. After multiplet classification, solvent and impurity peak identification, reference calibration, secondary filtration, and integer integration, 11 result peak groups were retained, 6 of which were analyte peak groups. The TMS peaks were used for reference calibration to obtain the global chemical shift. . Water peak and The residual DMSO peak was identified and excluded from the integration. The unit area obtained by integration is... .
[0254] The six analyte peak groups and their results are as follows: The peak is a single peak s, the coupling constant is empty, the original area of the peak group is 291998.21, the area ratio is 0.9610, the integer integral is 1H, and the integral confidence level is 0.9331. It is a single peak s, the coupling constant is empty, the original area of the peak group is 282248.56, the area ratio is 0.9289, the integer integral is 1H, and the integral confidence level is 0.8781; It is a double doublet dd, and the coupling constant is and The original area of the peak group is 306969.46, the area ratio is 1.0102, the integer integral is 1H, and the integral confidence level is 0.9824. For a triplet t, the coupling constant is The original area of the peak group is 285689.31, the area ratio is 0.9402, the integer integral is 1H, and the integral confidence level is 0.8975. It is a quartet q, and the coupling constant is The original area of the peak group is 615471.75, the area ratio is 2.0255, the integer integral is 2H, and the confidence level of the integral is 0.9562. For a triplet t, the coupling constant is The original area of the peak group is 911566.07, the area ratio is 3.0000, the integer integral is 3H, and the confidence level of the integral is 1.0000.
[0255] The structured proton spectrum text output by the system is as follows:
[0256] text
[0257] 1H NMR (400 MHz, DMSO): 12.6844 (s, 1H), 9.7644 (s, 1H), 7.8199 (dd,J=3.34, 1.61 Hz, 1H), 7.1332 (t, J=1.92 Hz, 1H), 4.2770 (q, J=7.13 Hz, 2H),1.2983 (t, J=7.11 Hz, 3H).
[0258] The integer integral sum of the six analyte peaks is 9H. The ethoxy group corresponds to... Four peaks and The triplet is integrally divided into 2H and 3H, with coupling constants of 2H and 3H respectively. and They match perfectly. The peak set gives two coupling constants, indicating that the system can output complex splitting and multiple coupling constants.
[0259] In the carbon spectrum processing, the system detected 21 original sub-peaks, forming 21 initial peak groups. After solvent peak identification and secondary filtration, 10 result peak groups were obtained. The signal was identified as a DMSO carbon peak. The weak signals were retained as weak signals to be verified. The eight carbon signals of the analyte were... , , , , , , and The machine-readable output simultaneously saves the multipeak categories and physical verification flags, and the report text can be selected only for the analyte signal.
[0260] Figure 9 The graph shows the evaluation results on the frozen test set of twelve multipeak categories. See also... Figure 9 For model validation, the current twelve-class multipeak classification model isolates the training set, validation set, and frozen test set according to the complete spectrum or the original FID. The frozen test set includes 400 manually verified peak groups, with an accuracy of [missing information]. The macro average F1 score is calculated only for categories with reference samples. The macro-average F1 score calculated only for supported complex multipeak categories dd, dt, and td is... In the test set, ddd and m have no reference samples, while h, p, and sep have only 2, 5, and 3 samples respectively. Therefore, the relevant macro-average indices are calculated based on the supported categories. The above model validation data demonstrates the classification ability of the current twelve-class multimodal classification model on manually confirmed peak groups.
[0261] Figure 10 Figures show the ablation experiment results for the derivative channel, local location coordinates, and auxiliary tasks in a multimodal classification neural network. (See also...) Figure 10 The ablation experiments used the same class set, random seed 42, the same simulated data, the same real training and validation partitions, the same frozen test set, and the same number of training rounds, only changing the technical features under investigation. The accuracy of the complete model was [missing information]. The average F1 score of the supported macro categories is... It supports complex category macro average F1 score. After removing the first and second numerical derivative channels, the accuracy is [percentage missing]. The average F1 score of the supported macro categories is... It supports complex category macro average F1 score. After removing local position coordinates and retaining the positions of ordinary sequences, the accuracy is [missing information]. The average F1 score of the supported macro categories is... It supports complex category macro average F1 score. After removing auxiliary task losses, the accuracy rate is... The average F1 score of the supported macro categories is It supports complex category macro average F1 score. .
[0262] Compared to the complete model, removing the derivative channel decreased accuracy by 1.50 percentage points, and the average F1 score for supporting complex categories decreased by 8.09 percentage points, indicating that derivative features contribute most stably to the differentiation of complex splits such as dd, dt, and td. Removing the auxiliary task decreased accuracy by 0.75 percentage points, and the average F1 score for supporting complex categories decreased by 2.40 percentage points, indicating that simple or complex peak group auxiliary supervision has a gain for complex categories. Removing local location coordinates decreased accuracy by 0.25 percentage points, and the average F1 score for supporting complex categories decreased by 2.83 percentage points, but the overall average F1 score for supporting categories increased. Considering the small number of samples in rare categories and the fact that the experiment only used a single random seed, the existing evidence supports the improvement trend of local location coordinates for complex categories, but it is not generalized that it can stably improve all indicators.
[0263] Figure 11A trade-off plot of strict two-condition gating risk for classification probability and physical verification versus output coverage for specific multimodal categories. (See also...) Figure 11 The joint decision experiment was conducted on the same twelve-class frozen test set, comparing the results of not using joint decision and using joint decision with the condition that "the classification probability reaches the threshold and the physical coupling constant is successfully resolved". Without joint decision, the average accuracy was [missing value]. The specific category output coverage rate is The specific error output is as follows That is, the total error output rate is The proportion of error-specific output to total output is The proportion of outputs with complex multipeaks m is 0. After using joint decision-making, the general accuracy is [missing value]. The specific category output coverage rate is The specific error output is as follows That is, the total error output rate is The proportion of error-specific output to total output is The proportion of outputs with complex multipeaks m is .
[0264] Joint decision-making makes the specific output of errors from Reduce to The relative decline is approximately At the same time The original concrete output is replaced by a complex multimodal output m. Since there are no real m samples in the test set, the complex multimodal output m will reduce the general accuracy. Therefore, the role of joint decision is to adjust the risk of incorrect concrete output and the coverage of concrete class output, rather than to improve the general accuracy.
[0265] The modules of this invention have clear data dependencies. The FID readout module provides the nucleus type, instrument observation frequency, spectral width, and solvent. These parameters determine the apodization and baseline correction strategies, the ppm to Hz conversion, the coupling constant calculation, and solvent peak matching, respectively. Phase correction determines whether the real spectral peak is positive and has an approximately symmetrical peak shape, thus affecting non-peak detection, baseline estimation, peak height measurement, and peak width measurement. The residual distribution after baseline correction is used to estimate noise, which in turn determines the sub-peak detection, shoulder peak detection, and boundary search thresholds. Sub-peak identification and peak groups form the output sub-peak position, peak height, peak width, and peak group boundary interval, which constitute both the neural network input and the input for physical pattern scoring and coupling constant analysis. The classification probability and physical verification results together form the candidate multipeak category, coupling constant, and physical verification flag. These results, along with the original peak group area, are input to solvent peak identification, impurity peak identification, secondary filtering, and final reporting. The proton and fluorine spectra were performed with integer integration, while the carbon spectra employed different solvent region merging, single-peak processing, and weak signal verification methods, reflecting the dynamic process selection driven by the type of atomic nucleus.
[0266] The above relationships represent hierarchical constraints on parameters and data. Except for cases where peak combinations are indeed present in the code and the integral is recalculated, or multiple peaks are processed, ordinary sequential execution does not constitute an infinite feedback loop.
[0267] This invention can also employ other alternatives. Automatic phase correction can be replaced by minimizing the negative peak area, maximizing peak symmetry, or other spectral purity targets, or by predicting phase parameters using a regression model. Baseline correction can be replaced by ALS, arPLS, SNIP, morphological opening operations, or combinations thereof. Sub-peak identification can employ continuous wavelet transform, template matching, one-dimensional segmentation networks, or other robust noise estimation methods. The backbone network can be replaced by residual convolutional networks, recurrent neural networks, state-space models, graph neural networks, or other sequence modeling networks. Local position representation can employ actual Hz, normalized ppm, fixed sinusoidal position, relative position offset, or directly added position channels. Derivative features can be replaced by or combined with wavelet coefficients, Savitzky-Golay derivatives, local curvature, edge or peak shape descriptors. Auxiliary tasks can be replaced by the number of sub-peaks, the number of coupling constants, the resolvability of coupling constants, overlap states, or signal-to-noise ratio prediction. Training methods can be replaced by frequency domain Voigt or pseudo-Voigt generation, joint training, domain adaptation, semi-supervised, self-supervised, or class reweighting. Fixed classification probability thresholds can be replaced by temperature calibration, category thresholds, ensemble uncertainty, or risk coverage calibration. Coupling constant analysis can be replaced by autocorrelation, spacing clustering, overall linear fitting, or direct regression followed by physical constraints. Integer integration methods can be replaced by area ratio clustering, continued fraction approximation, integer programming, or Bayesian inference. Deployment methods can be replaced by ONNX, TensorRT, local services, cloud interfaces, or hardware-embedded inference.
[0268] According to a second aspect of the present invention, a neural network-based automatic nuclear magnetic resonance (NMR) spectrum analysis system is provided for implementing the neural network-based automatic NMR spectrum analysis method as described in any of the preceding claims, the system comprising:
[0269] The data acquisition unit is used to acquire the nuclear magnetic resonance frequency domain spectrum to be analyzed and the instrument observation frequency corresponding to the nuclear magnetic resonance frequency domain spectrum to be analyzed.
[0270] The peak identification and grouping unit is used to identify multiple sub-peaks in the nuclear magnetic resonance frequency domain spectrum to be analyzed, and to merge the interrelated sub-peaks into at least one peak group.
[0271] The feature construction unit is used to construct a multi-channel input feature for each of the peak groups, including the peak group signal, the first-order numerical derivative, the second-order numerical derivative, and the local position coordinates, wherein the local position coordinates are obtained based on the chemical shift of each frequency point within the peak group and the instrument observation frequency.
[0272] The neural network classification unit is used to input the peak group signal, the first-order numerical derivative, the second-order numerical derivative, and the local position coordinates into the multi-peak classification neural network to obtain the classification probabilities corresponding to multiple preset multi-peak categories.
[0273] The physical verification unit is used to perform physical verification on the multiple preset multipeak categories according to the peak position, peak height, peak width, peak group boundary interval, their interrelationships and the solvability of the coupling constant of the sub-peaks in the peak group, and to obtain the physical verification results and coupling constant analysis results corresponding to each preset multipeak category.
[0274] The decision unit is configured to determine the predicted multipeak category of the peak group based on the classification probability and the physical verification results corresponding to each of the preset multipeak categories; and, for a specific multipeak category predicted to require the output of a coupling constant, if any of the following situations occur, the peak group is reverted to a complex multipeak m, or the specific multipeak category is retained and a corresponding risk flag is attached; the situations include:
[0275] The predicted classification probability of the multimodal category did not meet the preset confidence condition, the coupling constant resolution failed, or the physical verification failed.
[0276] This invention addresses the problems of high dependence on manual parameters, fragmented processes, and insufficient reproducibility of results by providing an automated processing chain executed sequentially by `NMRProcessor`, `NMRSolver`, and `NMRReporter`. The system can read raw FID or manufacturer-processed real-valued frequency domain spectra, supports instrument data formats such as Bruker, Varian, and JEOL, and selects the appropriate processing path based on acquisition parameters such as atomic nucleus type, instrument observation frequency, spectral width, emission bias, solvent, and number of spectral points. For raw FID, the system automatically performs apodization, zero-padding, FFT, automatic phase correction, and baseline correction. For manufacturer-processed real-valued frequency domain spectra with complete processing parameters, the system can directly calculate the chemical shift axis and proceed to subsequent analysis. For real-valued frequency domain spectra directly provided by JEOL, apodization and FFT can be skipped. This reduces the need for manually setting phase pivot, baseline order, sub-peak detection threshold, and integral reference peak, and allows phase correction parameters, baseline correction parameters, sub-peak identification parameters, candidate sorting parameters, physical gating parameters, and integral parameters to be written into the runtime configuration, thereby improving the automation level and reproducibility of the processing.
[0277] This invention addresses the insufficient robustness of template matching under complex splitting, overlapping peaks, shoulder peaks, and low signal-to-noise ratio conditions by employing a peak group-level multi-peak hybrid classification method. The system first forms peak groups based on robust noise estimation, sub-peak identification, secondary shoulder peak detection, boundary expansion, and overlapping boundary merging. Then, for each peak group, it constructs a peak group signal, first-order numerical derivative, second-order numerical derivative, and local position coordinates. The peak group signal, first-order numerical derivative, and second-order numerical derivative are input into a one-dimensional convolutional feature extractor. The local position coordinates are mapped by a position embedding network and fused with the convolutional features. Finally, a self-attention encoder and a multi-task output head output the classification probabilities of multiple multi-peak categories, as well as the auxiliary classification results for simple or complex peak groups.
[0278] The first and second numerical derivatives highlight the valleys, shoulders, and fine splitting structures between peaks, enabling the neural network to learn more discriminative local morphological features from peak group signals. Ablation experiments on the frozen test set show that the full model has a macro-average F1 score supporting complex categories of 83.47%. After removing the first and second numerical derivative channels, the macro-average F1 score supporting complex categories drops to 75.38%, and the overall accuracy decreases from 93.50% to 92.00%. Therefore, derivative-enhanced input can provide experimental support for complex multi-peak category recognition.
[0279] This invention sets up an auxiliary classification task of simple peak groups or complex peak groups in addition to the main multimodal classification task, and uses joint loss to train the neural network. The auxiliary task allows the network to learn the difference features between simple and complex peak groups while learning specific multimodal categories, thereby improving the representation learning and classification discrimination ability of complex multimodal categories. In ablation experiments, while keeping the network parameter layout unchanged and only setting the auxiliary loss weight to zero, the macro-average F1 score supporting complex categories decreased from (83.47%) to (81.07%), indicating that the auxiliary supervision of simple or complex peak groups has a beneficial effect on the recognition of complex multimodal categories.
[0280] This invention obtains the frequency position by multiplying the chemical shift by the instrument observation frequency, and then uses the weighted center of the peak group signal intensity as the origin to obtain the local position coordinates. The local position coordinates are expressed in Hz as the relative frequency distance, preserving the NMR physical meaning of the sub-peak spacing, and are embedded into a self-attention encoder via a multilayer perceptron. Since the overall category index and complex category index do not change in the same direction in existing ablation experiments, the local position coordinates can be used as a technical feature to enhance the ability to identify complex multipeak categories, rather than being described as having a stable improvement effect on all evaluation indicators.
[0281] This invention addresses the problem that neural networks may only output specific multipeak categories but lack verifiable physical evidence. It combines classification probabilities with physical verification results for joint decision-making. For different multipeak categories, the system performs physical verification based on at least one of the following: number of subpeaks, subpeak spacing, subpeak intensity relationship, subpeak area relationship, subpeak width relationship, subpeak geometric relationship, and solvability of coupling constants. Candidate multipeak categories are formed by combining the classification probability output by the neural network with the physical score. For specific multipeak categories requiring coupling constants, the system can output the specific multipeak category and coupling constant when the classification probability reaches a preset threshold, the coupling constant is within a preset range, the required subpeaks are distinguishable, and the physical verification passes. If the corresponding conditions are not met, the system can output a complex multipeak `m`, or retain the specific multipeak category and add a low-confidence flag or a flag indicating that the physical verification is not complete.
[0282] This joint decision-making approach allows the system output to not only include multiple peak categories, but also save the positions of the sub-peaks used, coupling constants, physical verification status, candidate categories, classification probabilities, physical scores, and combination scores. This facilitates downstream personnel in distinguishing between "specific and verified" results and "specific but unverified" or "unreliable" results. Strict gating experiments show that without strict gating, the error rate for specific outputs is 21 / 400, or 5.25%. After using the joint decision-making approach where "classification probability reaches the threshold and physical coupling constant is successfully resolved," the error rate is 8 / 400, or 2.00%, a decrease of approximately 61.9%. Correspondingly, the specific category output coverage decreases from 98.75% to 87.75%. Therefore, the effect of this technique is a quantifiable adjustment between the risk of erroneous specific outputs and the coverage of specific category outputs, rather than a necessary increase in accuracy.
[0283] This invention addresses the problem of independent modules and uncoordinated use of physical parameters in existing processes by employing a step-by-step analytical process driven by parameters such as nucleus type, instrument observation frequency, spectral width, and solvent. The instrument observation frequency simultaneously participates in the construction of local position coordinates and the calculation of coupling constants; phase correction, baseline correction, and noise estimation jointly influence the quality of sub-peak identification and peak group formation; the position, height, width, and boundary of sub-peaks within a peak group serve as inputs for neural network classification, as well as for physical verification and coupling constant analysis; the original peak group area, along with multipeak categories, solvent peak markers, impurity peak markers, and physical verification markers, participates in secondary filtering, integer integration, and report generation. Therefore, the system is not a simple assembly of several unrelated modules, but rather an integrated automatic analytical process formed through shared physical parameters and step-by-step data constraints.
[0284] This invention addresses the problem of instability in integer integration caused by the need for manually specifying reference peaks, weak peaks, or overlapping peaks. It provides a robust integer integration method that eliminates the need for manually specifying reference peaks with a known number of atoms. The method uses the analyte peak group with the largest original area among the first five peak groups as anchor points. For each anchor point, it assumes 1 to 6 atoms to form candidate unit areas and supplements them with candidate unit areas obtained by dividing the median of the original areas of all candidate analyte peak groups by 1 or 2. The system calculates the area ratio, nearest integer, and rounded residual for each candidate unit area and selects the unit area by incorporating the total loss including area-weighted relative residual squares, soft zeroing penalty, simplicity penalty, and minimum integer penalty. This method can penalize significant peak groups that are zeroed out and constrain unreasonable large integer integrals, reducing the risk of significant peak groups being incorrectly zeroed out, overall amplification of the entire integration, or unreasonable integration ratios.
[0285] This invention also employs a two-stage training method: physical simulation pre-training and fine-tuning with real data. The system can first be pre-trained using simulated FID or frequency domain spectral bands converted from simulated FID, with perturbations such as complex white noise, phase distortion, baseline drift, linewidth variation, and exponential apodization added to the simulated data. Then, based on manually verified real peak group data, the first stage of output head fine-tuning and the second stage of full-network differential learning rate fine-tuning are performed. This training method helps to combine simulated splitting patterns with real spectral peak shapes, improving the model's adaptability to real peak shapes, spectral processing errors, and different splitting structures.
[0286] This invention can automatically generate structured analytical results from raw FID or manufacturer-processed real-valued frequency domain spectra and save the processing configuration. The system supports two input paths: FID and manufacturer-processed spectra. For supported nucleus types, it performs preprocessing, sub-peak identification, peak group formation, multipeak classification, physical verification, solvent peak identification, impurity peak identification, reference calibration, integer integration, and report generation according to the configuration. If the model is missing or loading fails, the system can also use alternative analytical paths based on physical rules or template matching. Therefore, this invention is automated, reproducible, and deployable, but this does not equate to "accuracy superior to all commercial software" without independent comparative verification.
[0287] In summary, this invention provides an automated NMR spectroscopy analysis method and system based on neural networks. The method constructs an automated processing chain from the raw FID or manufacturer-processed frequency domain real-valued spectrum to a structured NMR analysis report. Instrument parameters determine the adaptive processing strategy for atomic nuclei, chemical shift axis calculation, ppm to Hz conversion, and solvent peak matching; phase correction improves peak shape; baseline correction and noise estimation improve sub-peak identification stability; the sub-peak identification module forms peak groups and their sub-peak structures; the neural network performs multipeak classification based on peak group signals, numerical derivatives, and local position coordinates; the physics module calculates and verifies coupling constants; solvent peak, impurity peak, and reference calibration modules ensure the reliability of analyte results; the integer integration module converts the original peak group area into integer atomic numbers; and the reporting module finally outputs machine-readable results, visualization results, and natural language spectroscopic text.
[0288] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for automatic analysis of nuclear magnetic resonance spectra based on neural networks, characterized in that, include: Obtain the nuclear magnetic resonance frequency domain spectrum to be analyzed and the corresponding instrument observation frequencies; Multiple sub-peaks are identified in the nuclear magnetic resonance frequency domain spectrum to be analyzed, and the interrelated sub-peaks are merged to form at least one peak group; For each peak group, a multi-channel input feature is constructed, including the peak group signal, the first-order numerical derivative, the second-order numerical derivative, and the local position coordinates, wherein the local position coordinates are obtained based on the chemical shift of each frequency point within the peak group and the instrument observation frequency; The multi-channel input features are input into a multi-peak classification neural network to obtain the classification probabilities corresponding to multiple preset multi-peak categories. Based on the peak position, peak height, peak width, peak group boundary interval, and their interrelationships and the solvability of coupling constants of the sub-peaks within the peak group, physical verification is performed on the multiple preset multi-peak categories, and physical verification results and coupling constant analysis results corresponding to each preset multi-peak category are obtained. Based on the classification probability and the physical verification results corresponding to each preset multipeak category, the predicted multipeak category of the peak group is determined; For a specific multipeak category predicted to require the output of a coupling constant, the peak group will be reverted to a complex multipeak output, or the specific multipeak category will be retained with a corresponding risk flag, if any of the following occurs: The predicted classification probability of the multimodal category did not meet the preset confidence level, the coupling constant resolution failed, or the physical verification failed.
2. The automatic nuclear magnetic resonance spectrum analysis method based on neural networks according to claim 1, characterized in that, Obtaining the nuclear magnetic resonance frequency domain spectrum to be analyzed includes: Acquire the original free induction decay signal or the frequency domain real spectrum processed by the manufacturer, and the acquisition parameters corresponding to the original free induction decay signal or the frequency domain real spectrum processed by the manufacturer. The acquisition parameters include at least one of the following: atomic nucleus type, instrument observation frequency sfo1, spectral width, emission bias, solvent, number of time domain sampling points, and number of frequency domain spectral points. When the frequency domain real spectrum processed by the manufacturer has complete processing parameters, the frequency domain real spectrum processed by the manufacturer is directly read, and the chemical shift axis is calculated inversely based on the spectral width, the emission bias, the instrument observation frequency and the number of frequency domain spectral points to obtain the nuclear magnetic resonance frequency domain spectrum to be analyzed. When the frequency domain real spectrum processed by the manufacturer with complete processing parameters is not obtained and the original free induction attenuation signal is obtained, the original free induction attenuation signal is preprocessed to obtain the nuclear magnetic resonance frequency domain spectrum to be analyzed. The types of atomic nuclei include hydrogen nuclei, carbon nuclei, and fluorine nuclei, and the acquisition parameters are read from the data files of at least one of the instruments Bruker, Varian, and JEOL.
3. The automatic nuclear magnetic resonance spectrum analysis method based on neural networks according to claim 2, characterized in that, The preprocessing includes: A window function is selected based on the type of atomic nucleus to apodize the original free induction decay signal; wherein, the window function includes at least one of an exponential window, a Gaussian window, a sine clock window, a sine square window, and a Traf window; the apodized free induction decay signal is padded with zeros to a preset length; A fast Fourier transform is performed on the zero-padded free induction attenuation signal to obtain the complex spectrum; Automatic phase correction is performed on the complex spectrum to obtain the phase-corrected real spectrum; and Baseline correction is performed on the phase-corrected real spectrum to obtain the nuclear magnetic resonance frequency domain spectrum to be analyzed; This is so that: when the frequency domain real spectrum processed by the manufacturer is directly provided by a JEOL instrument, the apodization and fast Fourier transform are skipped; when the frequency domain real spectrum processed by the manufacturer is provided by a Bruker instrument, the direction of the back-calculated chemical shift axis is adjusted so that the chemical shift axis is arranged in descending order of value.
4. The automatic nuclear magnetic resonance spectrum analysis method based on neural networks according to claim 1, characterized in that, The step of identifying multiple sub-peaks and merging interrelated sub-peaks into at least one peak group includes: The noise level is estimated based on the intensity signal of the nuclear magnetic resonance frequency domain spectrum to be analyzed, and the noise level is calculated according to the following formula: Where σ is the noise level. The intensity of the nuclear magnetic resonance frequency domain spectrum to be analyzed Signal; Initial sub-peaks are identified based on peak height thresholds and peak prominence thresholds related to the noise level; A shoulder peak detection threshold higher than the peak height threshold is used to identify shoulder peaks located in the vicinity of the initial sub-peak that are not fully characterized by the initial sub-peak. Search from the peak position of each sub-peak to both sides until the signal strength is lower than the boundary threshold, or the search distance reaches a preset multiple of the half-width of the sub-peak, to obtain the peak group boundary interval of each sub-peak. Sub-peaks that overlap within the boundary intervals of a peak group are merged into the same peak group.
5. The automatic nuclear magnetic resonance spectrum analysis method based on neural networks according to claim 1, characterized in that, The multi-peak classification neural network includes a one-dimensional convolutional feature extractor, a location embedding network, a self-attention encoder, a main classification head, and an auxiliary head; The peak group signal, the first-order numerical derivative, and the second-order numerical derivative are input into a one-dimensional convolutional feature extractor to obtain local features; The local location coordinates are input into the location embedding network to obtain location embedding features; The local features are fused with the location embedding features, and the fused features are input into the attention encoder to obtain the encoded features; The encoded features are input into the main classification head and the auxiliary head respectively. The main classification head outputs the classification probabilities corresponding to multiple preset multi-peak categories, and the auxiliary head outputs the auxiliary classification result of whether the peak group belongs to a simple peak group or a complex peak group. The preset multipeak category includes at least one of the following: single peak s, double peak d, triple peak t, quartet q, quintet p, hexapet h, heptaple peak sep, double double peak dd, double triple peak dt, triple double peak td, triple double double peak ddd, and complex multipeak m.
6. The automatic nuclear magnetic resonance spectrum analysis method based on neural networks according to claim 5, characterized in that, The peak group signal, the first-order numerical derivative, and the second-order numerical derivative constitute three convolution input channels. After being standardized with zero mean and unit variance respectively, the local features are obtained by the one-dimensional convolution feature extractor. The local location coordinates do not undergo the same normalization process as the peak group signal, the first-order numerical derivative, and the second-order numerical derivative, and the location embedding features are obtained through the location embedding network; The one-dimensional convolutional feature extractor includes three sequentially connected one-dimensional convolutional layers. The number of input channels and output channels of the three one-dimensional convolutional layers are 3 to 32, 32 to 64 and 64 to 128, respectively, and the kernel widths are 7, 5 and 3, respectively. The location embedding network has an input dimension of 1, a hidden layer dimension of 64, and an output dimension of 128. The self-attention encoder includes 4 encoding layers, a feature dimension of 128, 8 attention heads, a feedforward dimension of 512, and a dropout rate of 0.1%.
7. The automatic nuclear magnetic resonance spectrum analysis method based on neural networks according to claim 1, characterized in that, Based on the peak position, peak height, peak width, peak group boundary intervals, and their interrelationships and the solvability of coupling constants of the sub-peaks within the peak group, physical verification is performed on the multiple preset multipeak categories, and the analytical results of the coupling constants corresponding to each preset multipeak category are obtained, including: When the preset multiple peak category is a double peak, the coupling constant is obtained based on the frequency spacing between the two sub-peaks; When the preset multiple peak category is a triplet, quadruplet, quintuplet, hexaplet, or septuplet, the coupling constant is obtained based on the average value of the frequency spacing between adjacent sub-peaks. When the preset multipeak category is a double doublet, two coupling constants are obtained based on the edge spacing and cross-group spacing of the four ordered sub-peaks. When the preset multiple peak category is a double triplet or a triple doublet, two coupling constants are obtained based on the sub-peak spacing within the group and the sub-group center spacing. When the preset multipeak category is triplet doublet, three coupling constants are obtained based on the edge differences of the eight ordered sub-peaks. The coupling constant is determined based on the product of the chemical shift difference between sub-peaks and the instrument observation frequency; coupling constant J: ; in, Let be the coupling constant expressed in Hz. The chemical shift difference is expressed in ppm. The instrument observation frequency is expressed in MHz; When the required number of sub-peaks for the corresponding category cannot be obtained, the sub-peaks cannot be sufficiently distinguished, the geometric relationship between the sub-peaks does not meet the analytical conditions for the corresponding category, or one or more coupling constants obtained exceed the preset range, the analysis of the coupling constants for the corresponding preset multipeak category is determined to be unsuccessful.
8. The automatic nuclear magnetic resonance spectrum analysis method based on neural networks according to claim 1, characterized in that, The step of determining the predicted multipeak category of the peak group based on the classification probability and the physical verification results corresponding to each of the preset multipeak categories includes: For each of the preset multipeak categories, the corresponding classification probability is obtained, and the physical score is obtained based on the corresponding physical verification result; The classification probability and the physical score are weighted and combined to obtain the combined score of each of the preset multipeak categories; Based on the combined scores, multiple candidate multimodal categories are determined, and the candidate multimodal category with the highest classification probability and the complex multimodal candidate are retained. The predicted multipeak category of the peak group is determined based on the multiple candidate multipeak categories.
9. The automatic nuclear magnetic resonance spectrum analysis method based on neural networks according to claim 8, characterized in that, Also includes: Write at least one of the following into a structured result for each peak group: chemical shift, peak group boundary interval, sub-peak position, sub-peak height, sub-peak width, predicted multipeak category, classification probability, physical verification result, coupling constant analysis result, and risk indicator, and output the structured result.
10. An automatic nuclear magnetic resonance spectrum analysis system based on neural networks, characterized in that, The system is used to implement the neural network-based automatic nuclear magnetic resonance spectrum analysis method as described in any one of claims 1-9, the system comprising: The data acquisition unit is used to acquire the nuclear magnetic resonance frequency domain spectrum to be analyzed and the instrument observation frequency corresponding to the nuclear magnetic resonance frequency domain spectrum to be analyzed. The peak identification and grouping unit is used to identify multiple sub-peaks in the nuclear magnetic resonance frequency domain spectrum to be analyzed, and to merge the interrelated sub-peaks into at least one peak group. The feature construction unit is used to construct a multi-channel input feature for each of the peak groups, including the peak group signal, the first-order numerical derivative, the second-order numerical derivative, and the local position coordinates, wherein the local position coordinates are obtained based on the chemical shift of each frequency point within the peak group and the instrument observation frequency. The neural network classification unit is used to input the peak group signal, the first-order numerical derivative, the second-order numerical derivative, and the local position coordinates into the multi-peak classification neural network to obtain the classification probabilities corresponding to multiple preset multi-peak categories. The physical verification unit is used to perform physical verification on the multiple preset multipeak categories according to the peak position, peak height, peak width, peak group boundary interval, their interrelationships and the solvability of the coupling constant of the sub-peaks in the peak group, and to obtain the physical verification results and coupling constant analysis results corresponding to each preset multipeak category. The decision unit is used to determine the predicted multipeak category of the peak group based on the classification probability and the physical verification results corresponding to each preset multipeak category; and, for a specific multipeak category that is predicted to require the output of a coupling constant, if any of the following situations occur, the peak group is reverted to a complex multipeak m, or the specific multipeak category is retained and a corresponding risk flag is attached; the situations include: the classification probability corresponding to the predicted multipeak category does not reach the preset confidence condition, the coupling constant parsing fails, or the physical verification fails.
