Nuclear magnetic resonance spectrogram preprocessing method and system based on anchor peak coordinate system and semantic fragment Token and computer medium
By employing a preprocessing method that combines anchor peak coordinates with semantic segmentation and tokenization, we have addressed the nonlinear drift and data representation bottlenecks in NMR spectra, achieving high-precision alignment and AI-friendly input, thereby improving the accuracy of metabolite analysis and disease prediction.
Patent Information
- Application Number
- CN202511537180.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-27
- Publication Date
- 2026-02-03
AI Technical Summary
Existing technologies face challenges in correcting nonlinear drift in nuclear magnetic resonance (NMR) spectra. Traditional methods cannot effectively handle local nonlinear shifts, and there are bottlenecks in NMR spectrum data representation and modeling, making it difficult to adapt to complex spectral structures and high-dimensional noise problems.
A preprocessing method using anchor peak coordinate system and semantic segmentation tokenization is adopted. Through anchor point detection and matching, combined with dynamic time warping and monotonic spline mapping, high-precision alignment is achieved. Token sequences are generated through semantic segmentation and convolutional autoencoder to adapt to deep learning models.
It achieves high-precision, low-distortion spectral alignment, preserves chemical semantic information, provides AI-friendly input, and improves the accuracy and interpretability of metabolite analysis and disease prediction.
Smart Images

Figure CN121458837A_ABST
Abstract
Description
Technical Field
[0002] This invention belongs to the field of one-dimensional nuclear magnetic resonance spectroscopy data processing and artificial intelligence technology, and particularly relates to anchor peak coordinate system and semantic segmentation. Token Methods, systems, and computer media for preprocessing nuclear magnetic resonance spectra. Background Technology
[0003] As a one-dimensional nuclear magnetic resonance ( NMR Metabolic profiling, due to its non-destructive nature, high reproducibility, and broad metabolite coverage, is widely used in metabolomics, disease diagnosis, and drug development. However, two key challenges exist in its practical application: 1. Spectral drift problem Different samples due to pH Factors such as ionic strength, temperature, and instrument differences can cause nonlinear chemical shifts (e.g., 0.01–0.1 ppm) in the signal peaks of the same compound in different spectra. Figure 1 As shown, raw data collected by different devices NMR The spectrum shows a significant peak shift (indicated by the arrow). Traditional correction methods mainly include: Overall translation correction of internal standard (e.g., using) TSP (Based on peak shift): It can only handle linear drift and cannot cope with local nonlinear shifts; Global dynamic time warping ( DTW While it can achieve non-linear alignment, it is prone to excessive distortion. over- warping This can lead to unreasonable matching, especially in areas with no signal or baseline fluctuations. icoshift and other segmentation alignment algorithms rely on fixed interval divisions and are difficult to adapt to complex spectral structures.
[0004] The methods described above do not fully utilize prior information about known stable compound peaks in the spectra, resulting in limited alignment accuracy.
[0005] 2. Bottlenecks in Data Representation and Modeling NMR Spectral data is characterized by high dimensionality and noise; traditional processing methods include: Fixed width bins ( Binning ): Divide the spectrum into equal-width intervals and integrate, but may split multiple peaks of the same metabolite or mix peaks of adjacent different metabolites, losing chemical structure information; Full-spectrum vector input: Directly inputting intensity vectors into the machine learning model, but the feature dimension is high, there is a lot of redundant information, and the model is prone to overfitting; Manual peak extraction relies on expert experience and is difficult to automate.
[0006] In recent years, Transformer Sequence models have achieved great success in natural language and biological sequence modeling, but NMR spectra lack similar "words" or "sequence models." token The semantic unit “” limits its application.
[0007] Therefore, there is an urgent need for a method that integrates prior chemical knowledge, possesses physical interpretability, and supports... AI A friendly gesture NMR Spectrum preprocessing scheme. Summary of the Invention
[0008] Technical Solution: To solve the above-mentioned technical problems, this invention provides a NMR spectrum preprocessing method based on an anchor peak coordinate system and semantic segmentation tokenization, including S01: constructing an anchor peak coordinate system, selecting anchor compounds for detection in the reference and target spectra, and matching multiple pairs of anchor peaks to form an anchor set. Anchor compounds include internal standards and endogenous stable metabolites. S02: Perform dynamic time warping of anchor point constraints based on the anchor point set. The position in the middle is divided into multiple intervals by chemical displacement axis, and local dynamic time warping with endpoint hard constraints and slope penalty is performed in each interval to obtain the optimal alignment path; S03: Monotonic piecewise spline mapping and overlapping stitching fusion: The obtained optimal alignment path is fitted to a monotonic piecewise spline mapping, and overlapping bands are introduced in adjacent intervals for weighted fusion to obtain a continuous and invertible global alignment function. S04: Semantic segmentation. Semantic segmentation is performed on the aligned spectrum based on the valley bottom and the metabolite prior window to obtain non-equal-width fragments, and each fragment can represent a local chemical environment or functional group region. S05: Apply the reference spectrum semantic segmentation boundary obtained in S04 to all target spectrum samples, extract segment signals for each sample in the corresponding interval; extract morphological and prior features for each segment, and generate spectral signal embeddings through a convolutional autoencoder; then fuse the segment features and embedding representations, map them into fixed-dimensional token vectors, and form a token sequence according to the reference spectrum segmentation order, which serves as the input to the deep learning model.
[0009] As an improvement, when matching multiple anchor peak pairs in S01, the reference spectrum R(δ) and each spectrum to be aligned are used. Perform the following steps: (1.1) Perform baseline correction and smoothing; (1.2) Perform wavelet transform and noise suppression on the spectrum, extract candidate peaks based on local maximum detection, and apply height threshold and minimum distance to screen effective peaks; (1.3) Within the preset tolerance window ±0.02–0.05 ppm The corresponding peaks of the internally matched reference spectrum and the target spectrum are used to form a set of anchor point pairs. ,in K ≥3; k The total number of anchor pairs obtained from the initial matching 、 The peak positions of the spectra to be aligned are on the chemical shift axis. Peak positions of the reference spectrum on the chemical shift axis; (1.4) Use the random sampling consensus algorithm to remove mismatches; (1.5) Assign confidence weights to each anchor point , , , : These are the weighting coefficients for each item. For the first k Normalized signal-to-noise ratio of each peak, For the first k Normalized half-peak width of each peak, prior k No. k The score of the prior reliability of each peak; (1.6) Match success determination: A minimum confidence weight threshold W is set based on empirical values. Anchor pairs ≥W are considered valid and retained in the final anchor set. In the process, if the final anchor point K≥3, the match is considered successful; otherwise, the sample fails the matching judgment and is marked as "alignment failed" and included in the abnormal sample queue.
[0010] As an improvement, the specific steps in S02 include: (2.1) dividing the chemical displacement axis of the anchor point into K +1 continuous interval, : represents the (K+1)th interval on the spectrum to be aligned. For the (K+1)th interval on the reference spectrum, where From the starting point to the first anchor point, : From the last anchor point to the destination (1) (2.2) Perform local operations independently within each interval DTW Algorithm, Local DTW The algorithm includes a local window: using a Sakoe-Chiba band, the alignment path is restricted to a band-shaped region near the diagonal, i.e., satisfying... ,in , The first part of the spectrum to be aligned One sampling point, jThe reference spectrum j One sampling point, This refers to the bandwidth ratio. For the spectrum to be aligned k The number of sample points to be taken in the +1 interval. Reference spectrum k The number of sampling points in the +1 interval; Define the stepping pattern: Use the standard symmetric stepping pattern, allowing movement methods: down (1,0), right (0,1), diagonal (1,1), ensuring path monotonicity; cost function. for: (2) in They represent the target spectrum of the first digit. i The sampling point and the reference spectrum at the corresponding sampling point j Local standardized signal strength at each sampling point; , This represents the local normalized gradient at the corresponding point; This is a local slope penalty term; , , The weights are non-negative; the local standardization method is... z-score Standardization or Min-Max standardization; (2.3) Hard constraints and slope penalty, where the hard constraint forces the path start point to be aligned with the left anchor point and the end point to be aligned with the right anchor point; when the local mapping slope α= Δj / Δi Beyond [α] min, α max A linear penalty, also known as a slope penalty, is applied when the slope is too steep to prevent overstretching or compression. The local slope penalty term is defined as follows: (3) in: k For the penalty coefficient, [ [ ] represents a reasonable range for the mapping slope.
[0011] (2.4) The optimal alignment path for each interval is obtained through the above process.
[0012] As an improvement, the specific steps of S03 include (3.1) Path fitting: Optimal matching for each segment of S02 DTW Path, sample several Point pair, among which Represents the chemical shift coordinates in the target spectrum. This represents the chemical shift coordinates in the reference spectrum. A series of piecewise mapping functions are generated by fitting monotonically piecewise cubic Hermite splines to the point pairs. And constrain its first derivative. This ensures the monotonicity and invertibility of each piecewise mapping function; (3.2) Overlapping and fusion: An overlapping band with a length of Δ is introduced at the boundary of adjacent intervals. Construct a weighted fusion function: (5) (6) This function is for the left boundary of the overlapping zone. On the right boundary And it decreases smoothly in between; this is used to ensure that the fused global mapping function has C¹ continuity at the interval boundary, that is, the function itself and its first derivative are continuous; (3.3) Global Mapping and Resampling: Integrate the overlapping and fused mapping functions of all intervals to form a continuous and reversible global mapping function covering the entire chemical shift range. Using this global function, the target spectrum is transformed from the original coordinate system to the reference spectrum coordinate system. Finally, using linear interpolation or cubic spline interpolation, the transformed target spectrum is resampled to the chemical shift coordinate point that is completely consistent with the reference spectrum. The final output is a target spectrum that is highly accurate and continuously aligned with the reference spectrum on the chemical shift axis.
[0013] As an improvement, each non-uniform width semantic segment in S04 represents a local chemical environment or functional group region. Specific steps include: (4.1) Candidate boundary extraction and scoring: Based on the discrete signal data of the reference spectrum, the first-order numerical derivative is calculated, and the points where the derivative sign changes from negative to positive, i.e., local minimum points, are detected to form a set of candidate valley boundaries. Theoretical chemical shift windows of known metabolites are obtained from the metabolite prior database, and their boundaries are extracted to form a set of candidate prior boundaries. The total candidate boundary set is obtained by merging the results. ; and for each candidate boundary c Define a scoring function To quantify its rationale as a true boundary: (7) in, It is a valley significance score calculated based on the spectral derivative. It is a matching score based on a prior database. For overlapping penalty terms; This is a penalty for peak cluster integrity. These are non-negative weighting coefficients; (4.2) Using dynamic programming or Bayesian online variable point detection, under the constraint of fragment width, the total score is maximized to obtain the optimal segmentation solution, resulting in a set of non-equal width semantic fragments.
[0014] As an improvement, : This is achieved by calculating the absolute value integral of the derivative at the candidate boundary c. Obtained The radius of the local window; :like ,but ,otherwise ; If the width of adjacent segments is less than the threshold Then a linear penalty is applied. , The penalty coefficient is... The distance between adjacent boundaries; If candidate boundary c If the peak falls within the peak cluster region of any metabolite, a penalty is imposed:
[0015] in n This is the total number of metabolites to be detected; This is the penalty coefficient; Metabolite i Chemical shifts in functional regions This is an indicator function; it returns 1 if the condition is met, and 0 otherwise.
[0016] As an improvement, the Token The vector is fused with chemical shift order information through position encoding to obtain the final additively fused representation vector. The position encoding is generated based on the chemical shift coordinates of the reference spectrum to ensure the consistency of the spectral image segments in the input sequence. Token sequence As input to a deep learning model, it enables structured representation and feature learning of spectral graphs.
[0017] As a specific embodiment of the present invention, the present invention also provides a nuclear magnetic resonance spectrum preprocessing system based on anchor peak coordinate system and semantic segmentation tokenization. The system includes an anchor peak detection and matching module, a segment registration module, a mapping generation module, a semantic segmentation module, a token encoding module, and a model interface module. Anchor peak detection and matching module, used to obtain the anchor point set; The segmented registration module is used to perform local dynamic time warping of anchor point constraints; The mapping generation module is used to fit monotonic piecewise splines and perform overlapping weighted fusion. The semantic segmentation module is used to identify non-uniform width segments on the aligned spectrogram; The token encoding module is used to extract fragment features and generate token sequences; The model interface module is used to provide token sequences to the deep learning model for training and inference. The deep learning model can perform the following deep learning tasks: mask language modeling, predicting original features using random mask tokens; adjacency prediction to determine whether two tokens are adjacent; comparative learning to align different processing views of the same sample; and downstream tasks including metabolite concentration prediction, disease classification, and biomarker discovery.
[0018] As another specific embodiment of the present invention, a computer program is also provided, which, when executed by a processor, implements the steps of the method described in any of the preceding claims.
[0019] Beneficial Effects: This invention proposes a combination of "anchor peak coordinate system" and "chemically sensed semantic segmentation," using "anchor point constrained DTW + monotonic spline + overlap fusion" as the core alignment technology to construct an end-to-end NMR preprocessing scheme from physical correction to AI modeling. This not only solves the alignment problem of traditional methods but also achieves, for the first time... NMR Chemical semantics of the spectrum T oken Transformation Transformer Advanced models provide high-quality inputs and possess high patent value and industrialization potential.
[0020] Meanwhile, this invention is applicable to the quality control and unified preprocessing of batch metabolomics data, and can also be extended to the retention time or nonlinear alignment and semantic representation of the m / z axis in 2H, 1³C-NMR and LC-MS one-dimensional chromatography-mass spectrometry, and has broad industrial application prospects. Attached Figure Description
[0021] Figure 1 Example 1: Schematic diagram of nonlinear drift of original spectra of different samples.
[0022] Figure 2 : Schematic diagram of the anchor peak detection and matching process of this invention.
[0023] Figure 3 This invention compares the intervals divided by anchor points with the local DTW path.
[0024] Figure 4 : Schematic diagram of monotonic piecewise spline mapping and weighted fusion of overlapping bands in this invention.
[0025] Figure 5 The semantic segmentation boundary is determined in this invention.
[0026] Figure 6 : System module architecture diagram of the present invention. Detailed Implementation
[0027] The technical solutions in the embodiments of the present invention will be clearly and completely described below, so that those skilled in the art can better understand the advantages and features of the present invention, thereby making a clearer definition of the scope of protection of the present invention. The embodiments described in this invention are only some embodiments of the present invention, not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0028] This invention addresses the problems of nonlinear drift in existing NMR spectra, lack of chemical semantics in traditional segmentation, and difficulty in adapting to deep learning models. It provides a NMR spectrum preprocessing method, system, and storage medium based on anchor peak coordinates and semantic segmentation tokenization. The preprocessing method includes: detecting and matching multiple pairs of anchor peaks between the reference and target spectra based on prior knowledge of stable compounds to construct an anchor point set; dividing intervals according to anchor points and performing local dynamic time warping with endpoint constraints and slope penalties. DTW Achieve high-precision alignment; fit monotonically segmented splines and overlap and weighted fuse them to generate continuous and invertible mappings; combine valley detection and metabolite priors on the alignment spectrum to perform semantic segmentation, extract spectrum morphology and prior features, and combine convolutional autoencoder (CNN Autoencoder) to embed and generate fused token vector sequences.
[0029] This invention achieves low-distortion alignment and AI-friendly representation, improving the accuracy and interpretability of metabolite analysis and disease prediction. It is applicable to metabolomics and multi-platform spectroscopic data processing. Compared with existing technologies, this invention has the following significant advantages: (1) High-precision, low-distortion alignment: anchor point constraint + local DTW +Slope penalty significantly suppresses excessive distortion; (2) Seamless continuous mapping: Overlapping splicing and monotonic splines ensure no voids or breaks; (3) Strong chemical semantic representation: Semantic fragmentation preserves multiple peaks and coupling information, which is superior to constant width. binning ; (4) AI-friendly output: Token The sequence length is controllable, the features are interpretable, and it is a natural fit. Transformer ; (5) High robustness: RANSAC Improve the reliability of matching anchor point weight; (6) High scalability: suitable for different sample types and spectrometer platforms.
[0030] The following specific embodiment 1 illustrates the present invention based on anchor peak coordinate system and semantic segmentation. Token The preprocessing methods for nuclear magnetic resonance spectra are described and explained in detail.
[0031] Example 1 1. Technical Background Prostate cancer (PCa) is a common malignant tumor in men. Early screening relies on PSA testing, but this method lacks specificity. In recent years, urine¹H-NMR metabolomics has emerged as a potential auxiliary diagnostic tool due to its non-invasive and high-throughput characteristics. However, urine samples are affected by diet, water intake, and kidney function, resulting in significant nonlinear shifts in the spectral composition. Furthermore, the complex overlap of metabolite signals makes it difficult to extract robust biomarkers using traditional binning methods.
[0032] This embodiment uses the anchor peak coordinate system and semantic segmentation tokenization method proposed in this invention to preprocess and model 200 male urine samples (100 healthy and 100 prostate cancer) to achieve high-precision risk prediction.
[0033] 2. Experimental Data Preparation Sample source: A retrospective cohort study conducted at a tertiary hospital. With ethical approval, 200 cases of morning urine were collected (100 cases in the PCa group, diagnosed by puncture; 100 cases in the control group, with PSA <4 ng / mL and negative MRI).
[0034] NMR acquisition was performed on an NMR AVANCE III HD 600 MHz spectrometer (Bruker Biospin AG, Germany). The 1H spectrum pulse sequence was obtained using a NOESYGPPR1D, with a spectral width of 20 ppm and 32 scans.
[0035] Original spectral range: = -1–11 ppm, excluding the water peak (4.5–5.0 ppm) area.
[0036] Data format: Free Induction Decay (FID) real part spectrum obtained after Fourier transform, exported as .txt format, 37506 data points per spectrum.
[0037] 3. Preprocessing flow Step S1: Construct the anchor peak coordinate system. In this embodiment, the reference spectrum is selected from the control group, choosing the spectrum with the highest signal-to-noise ratio and the most stable baseline. .
[0038] Stable anchor peak selection: TSP (internal standard, = 0.00 ppm), creatine (Cr, = 3.03 ppm), choline (Cho, = 3.20 ppm), lactic acid (Lac, = 1.33 ppm), uric acid (UA, = 7.90 ppm).
[0039] In this invention, two examples of original spectra are shown, revealing a non-linear shift of approximately 0.04 ppm in the lactic acid peak at 1.33 ppm. Figure 1 As shown.
[0040] Furthermore, the anchor peak detection and matching process: Preprocessing: Baseline correction (quadratic polynomial fitting) and Savitzky-Golay smoothing (15-point window, second-order polynomial) are performed on the reference and target spectra. Noise suppression and peak detection: Denoising was performed using 5-level decomposition of db4 wavelet, and candidate peaks were detected using scipy.signal.find_peaks (height > 3 times the noise standard deviation, distance > 100 points). Anchor point matching: On the chemical shift axis, using the reference spectrum as a reference, the Hungarian algorithm is used to match the candidate peaks of the reference spectrum and the target spectrum within a window of ±0.05 ppm to obtain an initial set of anchor point pairs; RANSAC screening: Remove outlier matching points with a deviation >0.03 ppm, and retain valid anchor pairs; Confidence weight calculation: Calculate the confidence weight for each remaining anchor pair. The weighting model is as follows:
[0041] in: For the first k Normalized signal-to-noise ratio of each peak, The normalized half-peak width of the k-th peak, prior k No. k The prior reliability score of each peak; weighting coefficient values: =0.5, =0.3, =0.2. Confidence weight W=0.5, when Anchor pairs ≥W are considered valid and retained in the final anchor set. If the final anchor point K≥3, the matching is considered successful; otherwise, the sample fails the matching judgment and is marked as "alignment failed," included in the abnormal sample queue, and prompted to check the sample quality or instrument status.
[0042] In this embodiment, an average of 4.2 anchor points were successfully matched per spectrum (standard deviation 0.6), all of which met the requirement of K≥3.
[0043] Step S2: Segmented DTW of anchor point constraints.
[0044] 2.1 Interval Division: After sorting by anchor point, the values are divided into 5 intervals: [0.00, 1.33] ppm, [1.33, 3.03] ppm, [3.03, 3.20] ppm, [3.20, 7.90] ppm, and [7.90, 9.00] ppm.
[0045] 2.2 Local DTW parameter settings: Bandwidth ratio: =0.2; Partial window: ; Cost function weights: , , ; Slope constraint: α mi =0.6, α max =1.8, penalty coefficient k =5; Hard constraint: The path start point is forced to align with the left anchor point, and the end point is forced to align with the right anchor point.
[0046] See Figure 3 As shown, it can be concluded that: the local DTW path (solid line) of a typical sample in the range of [1.33, 3.03] ppm is shown. Compared with the global DTW path (dashed line), it can be seen that the path of the present invention is smoother and avoids excessive distortion near the creatine peak.
[0047] Step S3: Monotonic spline mapping and overlapping stitching. Specifically, this includes: first, for each interval... DTW 500 path samples Point pairs; then fit a monotonic piecewise mapping function. ,make sure Then, an overlapping strip is introduced at adjacent anchor points. ppm; finally, a cosine window weighted blending method was used:
[0048] The established global mapping function is applied to all target spectra. Resampling is performed to obtain the aligned spectrum. See in this invention Figure 4 As shown, it can be concluded that: (The text appears to be incomplete and contains several errors. A more accurate translation would require the full context.) = 3.03 ppm (creatine peak) near the overlap and fusion process, and the mapping function after fusion. At the junction Continuous, without jumps or breaks.
[0049] Step S4: Semantic Slicing.
[0050] 4.1 Candidate Boundary.
[0051] First, numerical derivative calculation: Savitzky-Golay filter (11-point window, 3rd order polynomial) is used to detect points where the derivative sign changes from negative to positive (local minimum points) to form a candidate valley boundary set; theoretical chemical shift windows of known metabolites are obtained from the metabolite prior database, and their boundaries are extracted to form a candidate prior boundary set; the two boundary sets are merged.
[0052] As an implementation method of this embodiment, the internal database used includes: Citric acid: 2.51–2.56 ppm, 2.63–2.68 ppm; Creatinine: 3.03–3.07 ppm, 4.04–4.08 ppm; Trimethylamine-N-oxide (TMAO): 3.20-3.30 ppm; Choline: 3.19-3.22 ppm, 4.05-4.09 ppm; α-Ketoglutarate: 2.44–2.48 ppm, 3.00–3.05 ppm.
[0053] 4.2 Boundary Scoring and Dynamic Programming Partitioning. Using the scoring function:
[0054] Furthermore, fragment width constraints were set: Lmin = 0.02 ppm, Lmax = 0.8 ppm; then, dynamic programming was used to solve for the optimal boundary set. The reference spectrum was divided into 135 semantic fragments, covering key metabolite regions, as detailed in [link to documentation]. Figure 5 As shown: The final determined partition boundaries (dashed lines) are displayed.
[0055] Step S5: Token Characterization and feature encoding.
[0056] 5.1 Feature Extraction and Embedding: Morphological characteristics: for each segment Extract the mean signal strength Signal strength variance Maximum signal strength ; CNN autoencoder: Input segment information, extract local pattern features through 3 convolutional layers (kernel=5, stride=2); Feature fusion: Morphological features are concatenated with CNN embedding vectors, and then mapped to fixed-dimensional token vectors via a 2-layer MLP (64 hidden layers, ReLU activation). ; Position coding: Introducing sinusoidal position coding , indicating the chemical shift order; Final output: A token sequence composed of fragments from the reference spectrum. .
[0057] in, This is a vector concatenation operation.
[0058] Token vector discrimination: On a dataset of 200 NMR spectra, the classification accuracy of the Transformer model after inputting the token vector is 94.2% (AUC=0.96). Example
[0059] See Figure 6 As shown, this is the NMR spectrum preprocessing system based on anchor peak coordinate system and semantic segmentation tokenization in this invention. The following is a detailed introduction and explanation of the deep learning training and prediction of the model interface module through specific embodiment 2.
[0060] In this embodiment, the model interface is set up using: Transformer The classifier has 6 layers, 512 hidden dimensions, and an 8-level attention head. The task is binary classification (health vs. prostate cancer), with a training strategy of 70% training, 20% validation, and 10% testing. Furthermore, it underwent pre-training with Masked Language Modeling (MLM) followed by downstream fine-tuning, using cross-entropy as the loss function.
[0061] The final performance results were: AUC = 0.93 on the test set, sensitivity = 88%, specificity = 91%, compared to 0.79 for traditional binning + SVM. This result is interpretable: the high attention weighting regions are concentrated in choline (3.20 ppm), citric acid (2.55 ppm), and TMAO (3.27 ppm), consistent with previous reports.
[0062] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this invention patent should be determined by the appended claims.
Claims
1. A preprocessing method for nuclear magnetic resonance spectra based on anchor peak coordinate system and semantic segmentation tokenization, characterized in that, include: S01: Construct an anchor peak coordinate system, select anchor compounds for detection in the reference and target spectra, and match multiple pairs of anchor peaks to form an anchor point set. Anchor compounds include internal standards and endogenous stable metabolites. S02: Perform dynamic time warping of anchor point constraints based on the anchor point set. The position in the middle is divided into multiple intervals by chemical displacement axis, and local dynamic time warping with endpoint hard constraints and slope penalty is performed in each interval to obtain the optimal alignment path; S03: Monotonic piecewise spline mapping and overlapping stitching fusion: The obtained optimal alignment path is fitted to a monotonic piecewise spline mapping, and overlapping bands are introduced in adjacent intervals for weighted fusion to obtain a continuous and invertible global alignment function. S04: Semantic segmentation. Semantic segmentation is performed on the aligned spectrum based on the valley bottom and the metabolite prior window to obtain non-equal-width fragments, and each fragment can represent a local chemical environment or functional group region. S05: Apply the reference spectrum semantic segmentation boundary obtained in S04 to all target spectrum samples, extract segment signals for each sample in the corresponding interval; extract morphological and prior features for each segment, and generate spectral signal embeddings through a convolutional autoencoder; then fuse the segment features and embedding representations, map them into fixed-dimensional token vectors, and form a token sequence according to the reference spectrum segmentation order, which serves as the input to the deep learning model.
2. The NMR spectrum preprocessing method based on anchor peak coordinate system and semantic segmentation tokenization according to claim 1, characterized in that, When matching multiple anchor peak pairs in S01, the reference spectrum R(δ) and each spectrum to be aligned are used. Perform the following steps: (1.1) Perform baseline correction and smoothing; (1.2) Perform wavelet transform and noise suppression on the spectrum, extract candidate peaks based on local maximum detection, and apply height threshold and minimum distance to screen effective peaks; (1.3) Within the preset tolerance window ±0.02–0.05 ppm The corresponding peaks of the internally matched reference spectrum and the target spectrum are used to form a set of anchor point pairs. ,in K ≥3; k The total number of anchor pairs obtained from the initial matching 、 The peak positions of the spectra to be aligned are on the chemical shift axis. Peak positions of the reference spectrum on the chemical shift axis; (1.4) Use the random sampling consensus algorithm to remove mismatches; (1.5) Assign confidence weights to each anchor point , , , : These are the weighting coefficients for each item. For the first k Normalized signal-to-noise ratio of each peak, For the first k Normalized half-peak width of each peak, prior k No. k The score of the prior reliability of each peak; (1.6) Match success determination: A minimum confidence weight threshold W is set based on empirical values. Anchor pairs ≥W are considered valid and retained in the final anchor set. In the process, if the final anchor point K≥3, the match is considered successful; otherwise, the sample fails the matching judgment and is marked as "alignment failed" and included in the abnormal sample queue.
3. The NMR spectrum preprocessing method based on anchor peak coordinate system and semantic segmentation tokenization according to claim 1 or 2, characterized in that, The specific steps in S02 include: (2.1) dividing the chemical displacement axis of the anchor point into K +1 continuous interval, : represents the (K+1)th interval on the spectrum to be aligned. For the (K+1)th interval on the reference spectrum, where From the starting point to the first anchor point, : From the last anchor point to the destination (1) (2.2) Perform local operations independently within each interval DTW Algorithm, Local DTW The algorithm includes a local window: using a Sacco-Chimbar window band, the alignment path is restricted to a band-shaped region near the diagonal, i.e., satisfying... ,in , The first part of the spectrum to be aligned i One sampling point, j The reference spectrum j One sampling point, This refers to the bandwidth ratio. For the spectrum to be aligned k The number of sample points to be taken in the +1 interval. Reference spectrum k The number of sampling points in the +1 interval; Define the stepping pattern: Use the standard symmetric stepping pattern, allowing movement methods: down (1,0), right (0,1), diagonal (1,1), ensuring path monotonicity; cost function. for: (2) in Representing the target spectrum respectively i The sampling point and the reference spectrum at the corresponding sampling point j Local standardized signal strength at each sampling point; , This represents the local normalized gradient at the corresponding point; This is a local slope penalty term; , , The weights are non-negative; the local standardization method is... z-score Standardization or Min-Max standardization; (2.3) Hard constraints and slope penalty, where the hard constraint forces the path start point to be aligned with the left anchor point and the end point to be aligned with the right anchor point; when the local mapping slope α= Δj / Δi Beyond [α] min, α max A linear penalty, also known as a slope penalty, is applied when the slope is too steep to prevent overstretching or compression. The local slope penalty term is defined as follows: (3) in: k For the penalty coefficient, [ ] is the reasonable range of the mapping slope; (2.4) the optimal alignment path of each interval is obtained through the above process.
4. The method based on anchor peak coordinate system and semantic segmentation as described in claim 1 Token A method for preprocessing nuclear magnetic resonance spectra, characterized in that... The specific steps in S03 include: (3.1) Path fitting: Optimal matching for each segment of S02 DTW Path, sample several Point pair, among which Represents the chemical shift coordinates in the target spectrum. This represents the chemical shift coordinates in the reference spectrum. A series of piecewise mapping functions are generated by fitting monotonically piecewise cubic Hermite splines to the point pairs. And constrain its first derivative. This ensures the monotonicity and invertibility of each piecewise mapping function; (3.2) Overlapping and fusion: An overlapping band with a length of Δ is introduced at the boundary of adjacent intervals. Construct a weighted fusion function: (5) (6) This function is for the left boundary of the overlapping zone. On the right boundary And it decreases smoothly in between; this is used to ensure that the fused global mapping function has C¹ continuity at the interval boundary, that is, the function itself and its first derivative are continuous; (3.3) Global Mapping and Resampling: Integrate the overlapping and fused mapping functions of all intervals to form a continuous and reversible global mapping function covering the entire chemical shift range. Using this global function, the target spectrum is transformed from the original coordinate system to the reference spectrum coordinate system. Finally, using linear interpolation or cubic spline interpolation, the transformed target spectrum is resampled to the chemical shift coordinate point that is completely consistent with the reference spectrum. The final output is a target spectrum that is highly accurate and continuously aligned with the reference spectrum on the chemical shift axis.
5. The NMR spectrum preprocessing method based on anchor peak coordinate system and semantic segmentation tokenization according to claim 1, characterized in that, Each non-uniform-width semantic segment in S04 represents a local chemical environment or functional group region. The specific steps include: (4.1) Candidate boundary extraction and scoring: Based on the discrete signal data of the reference spectrum, the first-order numerical derivative is calculated, and the points where the derivative sign changes from negative to positive, i.e., local minimum points, are detected to form a set of candidate valley boundaries. Theoretical chemical shift windows of known metabolites are obtained from the metabolite prior database, and their boundaries are extracted to form a candidate prior boundary set. The total candidate boundary set is obtained by merging the results. ; and for each candidate boundary c Define a scoring function To quantify its rationale as a true boundary: (7) in, It is a valley significance score calculated based on the spectral derivative. It is a matching score based on a prior database. This is an overlapping penalty term; This is a penalty for peak cluster integrity. These are non-negative weighting coefficients; (4.2) Using dynamic programming or Bayesian online variable point detection, under the constraint of fragment width, the total score is maximized to obtain the optimal segmentation solution, resulting in a set of non-equal width semantic fragments.
6. The NMR spectrum preprocessing method based on anchor peak coordinate system and semantic segmentation tokenization according to claim 1 or 5, characterized in that, : This is achieved by calculating the absolute value integral of the derivative at the candidate boundary c. Obtained The radius of the local window; :like ,but ,otherwise ; If the width of adjacent segments is less than the threshold Then a linear penalty is applied. , The penalty coefficient is... The distance between adjacent boundaries; If candidate boundary c If the peak falls within the peak cluster region of any metabolite, a penalty is imposed: ;in n This is the total number of metabolites to be detected; This is the penalty coefficient; Metabolite i Chemical shifts in functional regions This is an indicator function; it returns 1 if the condition is met, and 0 otherwise.
7. The NMR spectrum preprocessing method based on anchor peak coordinate system and semantic segmentation tokenization according to claim 1, characterized in that, The Token The vector is fused with chemical shift order information through position encoding to obtain the final additively fused representation vector. The position encoding is generated based on the chemical shift coordinates of the reference spectrum to ensure the consistency of the spectral image segments in the input sequence. Token sequence As input to a deep learning model, it enables structured representation and feature learning of spectral graphs.
8. A nuclear magnetic resonance spectrum preprocessing system based on anchor peak coordinate system and semantic segmentation tokenization, characterized in that... The system includes an anchor peak detection and matching module, a segment registration module, a mapping generation module, a semantic segmentation module, a token encoding module, a token encoding module, and a model interface module; The anchor peak detection and matching module is used to obtain the anchor point set; The segmented registration module is used to perform local dynamic time warping of anchor point constraints; The mapping generation module is used to fit monotonic piecewise splines and perform overlapping weighted fusion. The semantic segmentation module is used to identify non-uniform width segments on the aligned spectrogram; The token encoding module is used to extract fragment features and generate token sequences; The model interface module is used to provide token sequences to deep learning models for training and inference. The aforementioned deep learning model can perform the following deep learning tasks: mask language modeling, predicting original features using random mask tokens; adjacency prediction to determine whether two tokens are adjacent; comparative learning to align different processing views of the same sample; and downstream tasks including metabolite concentration prediction, disease classification, and biomarker discovery.
9. A computer medium storing a computer program, characterized in that, When the program is executed by the processor, it implements the steps of the method as described in any one of claims 1–7.
