A denoising method for magnetic resonance spectroscopy based on transformer

By employing a Transformer-based magnetic resonance spectroscopy denoising method that utilizes a self-attention mechanism to process complex signals, this method solves the problems of noise separation and peak preservation in low signal-to-noise ratio environments, achieving efficient noise removal and peak fidelity preservation. It is suitable for high-quality data analysis of magnetic resonance spectroscopy.

CN121117423BActive Publication Date: 2026-02-17XIAMEN UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511657926.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-13
Publication Date
2026-02-17
Estimated Expiration
2045-11-13

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively remove noise in magnetic resonance spectroscopy without extending the scan time, especially in low signal-to-noise ratio environments. Traditional methods are prone to causing distortion of spectral peak signals or noise residue, and lack effective processing of complex domain signals.

Method used

A Transformer-based magnetic resonance spectroscopy denoising method is adopted. By constructing a complex signal and combining it with a Transformer model, the global frequency domain dependency is obtained by utilizing the self-attention mechanism. This establishes a Transformer-based magnetic resonance spectroscopy complex signal denoising model, which achieves accurate noise separation and preservation of spectral peak structural features.

Benefits of technology

It significantly improves the signal-to-noise ratio and resolution of magnetic resonance spectroscopy, enhances the accuracy of spectral peaks and the reliability of quantitative analysis, and is suitable for generating high-quality spectra under various noise levels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121117423B_ABST
    Figure CN121117423B_ABST
Patent Text Reader

Abstract

The application provides a denoising method for magnetic resonance spectrum based on a transformer, and relates to the technical field of signal processing and artificial intelligence, which comprises the following steps: obtaining a free induction decay signal (FID) containing noise and a corresponding label signal, and constructing a training data set; converting the FID into a frequency domain signal through fast Fourier transform and performing amplitude normalization; projecting the real part and the imaginary part of the frequency domain signal into a high-dimensional feature space respectively; and feeding the two channels into a multi-layer transformer encoder based on a multi-head self-attention mechanism respectively to capture long sequence global correlation. The encoding output is separated and decoded to recover the real part and the imaginary part respectively, and the recovered complex frequency domain signal is obtained by combination. During the training process, a complex mean square error is used as a loss function, and a dynamic learning rate scheduling and an early stopping mechanism are combined to improve the convergence stability and the model training efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of signal processing and artificial intelligence technology, and specifically to a method for denoising magnetic resonance spectroscopy based on Transformer. Background Technology

[0002] Magnetic Resonance Spectroscopy (MRS), a spectroscopic detection method that uses magnetic resonance principles to resolve the molecular structure, physical properties, and metabolite composition of substances, has wide applications in medicine, chemistry, and biology. It is particularly promising in areas such as tumor grading, early diagnosis of neurodegenerative diseases, and pharmacokinetic studies. However, it is often limited by low signal-to-noise ratios and long acquisition times. Whether in clinical scanning or high-throughput chemical analysis, the acquired free induction decay (FID) signal is invariably submerged in strong random noise, interfering with quantitative metabolite analysis and even affecting the accuracy of disease diagnosis. Thermal noise, digital quantification noise, and motion artifacts couple with each other, causing baseline drift and the submergence of weak metabolic peaks, directly impacting the accuracy of subsequent peak area integration, quantitative fitting, and pathological interpretation. In practical applications, magnetic resonance spectroscopy is often limited by low signal-to-noise ratio (SNR). Traditional methods to improve SNR rely on "time for quality"—suppressing noise and increasing SNR by repeatedly sampling and averaging. However, the exponentially increasing scan time not only increases the risk of patient intolerance and equipment costs but also creates a bottleneck for high-throughput metabolomics projects. More importantly, in body imaging or in subjects such as infants who cannot remain still for long periods, simple averaging may introduce motion-related artifacts, further distorting the spectral shape.

[0003] In recent years, the signal processing community has successively proposed traditional magnetic resonance denoising methods such as wavelet thresholding, singular value truncation (TSVD), Cadzow low-rank approximation, state-space models, and parameterized linewidth estimation, attempting to improve spectral quality without extending the scan time. These methods generally assume that the signal has a separable "low-rank + sparse" structure in the time or frequency domain, and suppress the noise subspace by manually setting the threshold or truncation order. However, MRS signals are essentially complex sequences composed of multiple exponentially decaying sine curves superimposed. The spectral peak frequencies, linewidths, phases, and relative intensities exhibit high heterogeneity with variations in biological individuals, field strength, and sequence parameters. When dealing with complex multi-component metabolites or low-concentration metabolites, it is extremely difficult to balance "noise reduction" and "fidelity preservation" by fixing the model order and threshold: too small a truncation parameter will leave residual noise, while too large a parameter will clip peaks or merge adjacent peaks, leading to systematic deviations in the quantization results. More challenging is the phase distortion caused by magnetic field inhomogeneity during actual scanning, which causes the time-domain signal to deviate from the ideal exponential decay model. Traditional algorithms based on the low-rank assumption are particularly sensitive to this type of "model mismatch," often resulting in distortion where "noise is not removed but the signal is destroyed." Furthermore, existing algorithms are generally designed for single-frame FID, lacking utilization of long-range correlations and failing to constrain the real / imaginary parts and amplitude / phase as a whole complex domain feature, thus leading to a sharp deterioration in performance under ultra-low signal-to-noise ratio environments. Specifically, while removing noise, they may cause spectral peak signal or broadening distortion. Alternatively, although they may utilize the low-rank characteristics of the FID signal, a truncation parameter needs to be selected, and the denoising effect is limited when processing complex NMR spectra. If the truncation parameter is too large or too small, noise residue and spectral peak loss may occur, making them difficult to apply in practice.

[0004] In recent years, deep learning has demonstrated remarkable potential in denoising and restoration tasks in fields such as computer vision and natural language processing. Convolutional Neural Networks (CNNs), with their local receptive fields and weight sharing, have achieved a leap in PSNR for image denoising; Recurrent Neural Networks (RNNs) and their gated variants (LSTM, GRU) have been used for speech enhancement and temporal prediction. However, when CNNs are simply ported to one-dimensional FID signals, the locality of the convolutional kernels limits their ability to model "long-range decay correlations"; and the serial computation characteristics of RNNs not only make training time-consuming, but also make it difficult to capture the spectral peak coupling relationships hundreds of points apart in a 1024-point long sequence due to gradient vanishing / exploding. The emergence of the Transformer architecture has completely changed this situation, demonstrating its powerful potential in image denoising tasks. Its self-attention mechanism effectively captures global dependencies, avoiding the shortcomings of traditional convolutional neural networks in extracting features from long sequences and the complex training and gradient vanishing or exploding issues of recurrent neural networks. Specifically, the self-attention mechanism can establish global dependencies between any two points in O(1) steps, perfectly matching the "distant but frequency-coupled" characteristics of MRS peak groups; parallel computation significantly shortens training time. However, although the Vision Transformer has shown its prowess in image denoising and low-dose CT reconstruction, a Transformer denoising framework for magnetic resonance spectroscopy—especially complex domain FID sequences—remains a blank. Existing technical solutions mainly focus on using CNN or U-Net structures to denoise magnetic resonance "images." There is no solution that applies "multi-head self-attention + complex high-dimensional mapping" to one-dimensional spectral signals. Furthermore, it has not solved the problem of "how to maintain the spectral peak shape and quantitative information with zero distortion under different noise levels without extending the scan, assuming a priori models, or introducing truncation parameters."

[0005] In view of the above, this application is hereby submitted. Summary of the Invention

[0006] This invention provides a method for denoising magnetic resonance spectroscopy based on Transformer, which can at least partially improve the above-mentioned problems.

[0007] To achieve the above objectives, the present invention adopts the following technical solution:

[0008] A Transformer-based method for denoising magnetic resonance spectroscopy, comprising:

[0009] Obtain the noiseless FID signal generated by the exponential decay model, and perform Gaussian white noise superposition processing on the noiseless FID signal to generate a noisy FID signal. Construct a magnetic resonance spectral signal dataset based on the noiseless FID signal and the noisy FID signal.

[0010] A complex signal denoising model based on Transformer is established. The training set in the magnetic resonance spectrum signal dataset is preprocessed. The preprocessed training set and other datasets in the magnetic resonance spectrum signal dataset are used to train and optimize the complex signal denoising model to obtain the final complex signal denoising model of magnetic resonance spectrum.

[0011] The original FID signal to be denoised is obtained and input into the final magnetic resonance spectrum complex signal denoising model to obtain the corresponding denoised spectrum frequency domain signal, and the denoised time domain FID signal is obtained by inverse Fourier transform.

[0012] In summary, the specific steps of the Transformer-based magnetic resonance spectroscopy denoising method include: generating a noise-free free induction attenuation (FID) signal and superimposing different levels of noise to construct training, validation, and test datasets; constructing a Transformer-based complex denoising model for magnetic resonance spectroscopy and training it using the training dataset; obtaining the trained FID signal denoising model, evaluating it using the test dataset, and obtaining the final magnetic resonance spectroscopy denoising model; and applying the final model to the magnetic resonance spectroscopy signal denoising task to output a high-quality frequency domain denoised signal.

[0013] Specifically, this method combines complex signals with a Transformer model, utilizing the model's self-attention mechanism to acquire global dependencies in the frequency domain, thus ensuring the preservation of spectral peak structural characteristics while denoising. In particular, this method introduces dual-channel inputs of real and imaginary parts to the input layer and a positional encoding mechanism, making the final denoised frequency domain signal closer to a noise-free frequency domain signal in terms of amplitude and number of peaks. Through this complex-modeled Transformer structure, the denoising model can more effectively preserve NMR spectral peaks at low signal-to-noise ratios, thereby significantly improving the spectral signal-to-noise ratio and resolution. This method not only improves the accuracy of magnetic resonance spectroscopy data analysis but also provides higher-quality data analysis support for metabolite quantification and related magnetic resonance spectroscopy studies.

[0014] Compared with existing technologies, the advantages of this method are: (1) By combining the global dependency of frequency domain sequences and the Transformer network structure modeled by complex numbers, it can make full use of the sparsity of signals in the frequency domain to achieve accurate noise separation, while preserving the amplitude of frequency domain signals, providing application value for clinical diagnosis of magnetic resonance spectroscopy; (2) It effectively solves the problems of performance degradation and excessively long denoising time of traditional denoising methods in complex noise environments, and can cope with interference of various noise levels to provide high-quality magnetic resonance spectra. Attached Figure Description

[0015] Figure 1 This is a flowchart illustrating the denoising method for magnetic resonance spectroscopy based on Transformer provided in an embodiment of the present invention.

[0016] Figure 2 This is a schematic diagram of the model training process for the Transformer-based magnetic resonance spectroscopy denoising method provided in this embodiment of the invention.

[0017] Figure 3 This is a structural diagram of the encoding layer in the Transformer encoder provided in this embodiment of the invention.

[0018] Figure 4 This is a denoising result image of the final magnetic resonance spectral model used on the test set, provided by an embodiment of the present invention. Figure 4 In this context, au represents any unit. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0020] refer to Figure 1 As shown, the first embodiment of the present invention discloses a Transformer-based magnetic resonance spectroscopy denoising method, which can be executed by a Transformer-based magnetic resonance spectroscopy denoising device (hereinafter referred to as the denoising device), specifically, by one or more processors within the denoising device, to implement the following method:

[0021] S1, acquire the noiseless FID signal generated by the exponential decay model, and perform Gaussian white noise superposition processing on the noiseless FID signal to generate a noisy FID signal. Construct a magnetic resonance spectral signal dataset based on the noiseless FID signal and the noisy FID signal.

[0022] Specifically, step S1 further includes: n A noiseless FID signal Able to model as R The sum of the decay exponential components is given by the following formula: , , n=0,...,N- 1 ,in, s The signal is a noise-free FID signal, and T is the transpose. For complex fields, N The number of sampling points for the frequency domain signal. R This represents the number of spectral peaks contained in the spectrum. Let be the amplitude of the r-th spectral peak. The sampling interval is... Let r be the decay time of the r-th spectral peak. Let r be the resonance frequency of the r-th spectral peak. .

[0023] The noise-free FID signal is subjected to amplitude maximum value normalization processing to ensure that the amplitude of the noise-free FID signal is within a preset standard range. The normalization formula is as follows: , The normalized noise-free FID signal;

[0024] Preset the noise standard deviation range Gaussian white noise obtained from random sampling is superimposed on the normalized noise-free FID signal to generate a noisy FID signal, the formula of which is: ,in, The normalized noise-free FID signal, x For noisy FID signals, It is Gaussian white noise;

[0025] A noisy magnetic resonance spectroscopy signal dataset with a controllable signal-to-noise ratio is constructed based on noiseless FID signals and noisy FID signals. The magnetic resonance spectroscopy signal dataset includes a training set, a validation set, and a test set.

[0026] In this embodiment, a noiseless free induction decay (FID) signal, consistent with the characteristics of a real magnetic resonance spectral signal, is first generated using computer simulation. This noiseless FID signal is constructed based on an exponential decay model, accurately simulating a complex time-domain signal formed by the superposition of multiple spectral peaks in the magnetic resonance spectrum. After generating the noiseless FID signal, its maximum amplitude is normalized to ensure the signal amplitude is within a preset standard range. Subsequently, Gaussian white noise is randomly sampled within a preset noise standard deviation range and superimposed on the normalized noiseless FID signal to generate a noisy FID signal; that is, random Gaussian white noise at different levels is superimposed on it. By controlling the sampling range of the noise standard deviation, the signal-to-noise ratio level can be precisely adjusted, constructing a magnetic resonance spectral signal dataset with different noise intensities. This dataset includes a training set, a validation set, and a test set for subsequent model training, optimization, and performance evaluation. In the training dataset, the number of spectral peaks R is randomly selected between 1 and 20 to enhance the model's denoising and generalization ability for spectral signals of varying complexity.

[0027] In this embodiment, the training dataset contains 36,000 complex FID signals, randomly divided into a training set (32,000 groups) and a validation set (4,000 groups) to ensure the representativeness of the data distribution. Each FID signal contains a real and an imaginary part in complex form, and each signal has 1,024 sampling points. The noiseless signal is obtained through theoretical modeling to ensure no noise interference. The noisy signal is generated by adding Gaussian white noise to the noiseless signal to simulate the real acquisition environment.

[0028] Both the training and test datasets consist of simulation data. The simulation data is generated in MATLAB software by superimposing Gaussian white noise onto a noise-free spectrum, and can be specifically represented as follows: , ,in, Indicates the standard deviation of noise. This represents the normalized, noise-free FID signal. Let R represent an independent vector of length R, where each element follows a normal distribution with mean 0 and variance 1. It is Gaussian white noise.

[0029] S2, establish a complex signal denoising model for magnetic resonance spectrum based on Transformer, preprocess the training set in the magnetic resonance spectrum signal dataset, and use the preprocessed training set and other datasets of the magnetic resonance spectrum signal dataset to train and optimize the complex signal denoising model for magnetic resonance spectrum to obtain the final complex signal denoising model for magnetic resonance spectrum.

[0030] Specifically, step S2 further includes: the magnetic resonance spectrum complex signal denoising model includes an input layer, a complex feature projection layer, a position encoder, a Transformer encoder, a linear decoder, and an output layer, wherein the input layer uses the real and imaginary parts of the complex spectrum as inputs to two linear layer channels respectively; the complex feature projection layer contains two independent linear layers, which process the real and imaginary parts of the frequency domain complex signal respectively, and project the real and imaginary parts of each frequency domain signal from 1 dimension to a 128-dimensional high-dimensional feature space respectively;

[0031] The position encoder concatenates the projected real and imaginary features to obtain a 256-dimensional combined feature vector, and adds position coding, using an alternating sine and cosine coding method to provide position information for each frequency domain component;

[0032] The Transformer encoder is used to extract relevant features of the spectrum. It contains 6 coding layers, each containing 8 attention heads. The 6 coding layers have the same internal structure and achieve deep feature extraction by stacking layers. Each coding layer contains a multi-head self-attention mechanism, a residual network, normalization and a feedforward neural network. The multi-head self-attention mechanism calculates the correlation weights between different frequency domain components, and the feedforward neural network performs feature transformation and nonlinear activation.

[0033] The linear decoder consists of two independent linear layers, which reconstruct the real and imaginary parts of the signal, respectively, and are used to combine the real and imaginary part signals in the frequency domain to form the final complex frequency domain signal output; the output layer is used to restore the denoised complex frequency domain signal.

[0034] The multi-head self-attention mechanism uses different projection matrices to calculate the distribution of multiple attentions, obtains the correlation under different spectra, and then combines them through linear transformation.

[0035] The training set in the magnetic resonance spectral signal dataset is preprocessed, specifically by loading and initializing the training set, and setting the data loading path and data processing method.

[0036] The complex FID signals in the training set are converted into frequency domain signals by fast Fourier transform, and then split into real and imaginary parts and fed into the input layer of the magnetic resonance spectrum complex signal denoising model.

[0037] The magnetic resonance spectrum complex signal denoising model was trained and optimized using the preprocessed training set and other datasets from the magnetic resonance spectrum signal dataset, specifically as follows:

[0038] The magnetic resonance spectrum complex signal denoising model is trained using the preprocessed training set, and then trained and optimized using the AdamW optimizer and the validation set of the magnetic resonance spectrum signal dataset. The learning rate is gradually reduced according to a preset decay strategy. When the loss of the current validation set does not decrease significantly within a preset number of training rounds, the learning rate is reduced.

[0039] The trained complex signal denoising model for magnetic resonance spectroscopy was comprehensively tested and evaluated using the test set of the magnetic resonance spectroscopy signal dataset. The evaluation assessed the generalization ability of the complex signal denoising model on independent test data and its denoising performance on data outside the test set. Specifically, each spectrum in the test set was denoised, and the corresponding denoising results were generated. The denoised results were compared with the labeled signals of the test set, and multiple performance indicators of denoising were calculated to obtain the evaluation results.

[0040] When the evaluation result is deemed satisfactory, the final magnetic resonance spectrum complex signal denoising model is obtained.

[0041] In the training process of the magnetic resonance spectrum complex signal denoising model, the loss function used is the complex mean square error loss. This function calculates the difference between the denoised frequency domain signal and the noise-free frequency domain signal predicted by the model, and its formula is as follows: , M The total number of frequency domain signals. This is represented by taking the real part of the complex signal. To represent the imaginary part of a complex signal, For the first i Complex values ​​of a frequency domain signal after denoising For the first i The target complex value of a frequency domain signal.

[0042] In this embodiment, a Transformer-based denoising model for complex magnetic resonance spectral signals is established. High-dimensional feature mapping is performed on the real and imaginary parts of the magnetic resonance frequency domain signal, mapping them to a high-dimensional vector space. Signal feature extraction and denoising are achieved through an encoder-linear decoder structure. The global dependencies of the frequency domain signal are obtained using a self-attention mechanism, and the combination and output of the real and imaginary parts of the frequency domain signal are achieved through a decoding layer.

[0043] The Transformer model is trained using the constructed dataset, with noisy frequency domain signals as input and noiseless frequency domain signals as label signals. The model is trained by minimizing the mean square error loss function. The complex mean square error loss function is used, and it is optimized by combining an early stopping mechanism and a learning rate scheduling strategy. The trained model is tested using the test dataset to evaluate its performance on the test data. When the evaluation results meet the expected criteria, the trained magnetic resonance spectroscopy denoising model can be obtained.

[0044] Please see Figure 2 and Figure 3This embodiment presents a Transformer-based magnetic resonance spectroscopy denoising model architecture, illustrating the process of inputting a noisy signal, separating the real and imaginary parts, position encoding, using a Transformer encoder, and outputting a denoised frequency domain signal. Specifically, firstly, paired FID data are converted into a frequency domain complex sequence using a Fast Fourier Transform, and then fed into the network in parallel with the real and imaginary parts. After the input layer, two independent linear layers each upscale the 1024-point one-dimensional vector to a 128-dimensional latent space, forming a complex feature projection layer. This step provides sufficient representation capacity for the originally sparse frequency points while preserving the algebraic structure of the complex domain, enabling the network to distinguish between weak peaks and random perturbations. The two sets of 128-dimensional features after projection are concatenated bit-by-bit into a 256-dimensional combined vector, which is then injected with alternating sine and cosine position encoding. This allows the model to perceive frequency order even without convolution, improving reconstruction accuracy when adjacent peaks overlap. After position encoding, the data enters the Transformer encoder. This approach employs a six-layer stack, with eight self-attention heads per layer. All layers share the same internal structure: first, layer normalization is performed, then a multi-head mechanism is used to calculate the correlation weights between arbitrary frequency points, followed by residual connections; after another layer normalization, a feedforward network completes the nonlinear transformation, and the residuals are output again. This six-layer progressive extraction allows the coupling information between distant peaks to be fused layer by layer, laying a global context foundation for simultaneously maintaining spectral peak area and phase. The encoded features are then segmented according to the principle of "the first 128 dimensions corresponding to the real part and the last 128 dimensions corresponding to the imaginary part," each segment being reduced to 1024 points through an independent linear layer and then recombined into a complex spectrum, thus completing linear decoding and output. This "combine-then-separate" strategy ensures the consistency of the internal dimensions of the Transformer while avoiding the mixing of real and imaginary information, significantly reducing the amplitude-phase joint error.

[0045] In simple terms, the process begins with layer normalization, followed by feeding the data into a multi-head self-attention mechanism to calculate global dependencies. The output is then added to the input of the next layer via a residual connection layer. The result is normalized again, then undergoes a nonlinear transformation via a feedforward neural network. Finally, the output of the layer is obtained through a second residual connection. The feedforward neural network contains two linear layers, with the SiLU activation function used in between. The Transformer encoder output features are further decomposed into real and imaginary signals, which are then passed through independent linear decoders and finally synthesized into a denoised frequency domain signal in complex form.

[0046] The model was trained using the AdamW optimizer with an initial learning rate of 1×10⁻⁶. -4 The batch size was set to 16, the training epochs were 150, and the ReduceLROnPlateau learning rate scheduler was used. When the validation set loss did not improve for five consecutive epochs, the learning rate was reduced to half its original value. The minimum learning rate was set to 1×10⁻⁶. -6An early stopping mechanism is implemented: when the validation set loss shows no improvement for 10 consecutive rounds (improvement less than 0.001), training is terminated early to prevent overfitting, and the model with the best LOSS performance on the validation set is saved. During training, the training set loss and validation set loss are recorded every round, and the model is saved every 10 rounds for subsequent analysis of the constructed test dataset. The trained Transformer-based denoising model is tested using the test dataset to evaluate its denoising performance on the test dataset. When the training set loss converges and the validation set loss no longer improves, or when the number of training rounds reaches the set threshold, the magnetic resonance spectroscopy denoising model with the minimum validation set loss function is selected as the final denoising model.

[0047] Throughout the training phase, only the complex mean squared error was used as the loss function, with its gradient synchronously propagated back to both the real and imaginary branches, ensuring that amplitude and phase differences were penalized equally. The AdamW optimizer was selected, with the initial learning rate automatically halved based on whether the validation loss continuously stalled, until early stopping was triggered. The resulting model exhibited stable denoising capabilities on the test set: the spectral peak shape almost perfectly matched the noise-free labels, peak area deviation was compressed to an extremely low level, and baseline noise was significantly flattened. Furthermore, the inference process required no manual thresholding or model order, truly achieving high-fidelity denoising under the condition of "zero increase in scan time," providing reliable data support for subsequent metabolite quantification and clinical diagnosis.

[0048] Please see Figure 1 S3, acquire the original FID signal to be denoised, and input it into the final magnetic resonance spectrum complex signal denoising model to obtain the corresponding denoised spectrum frequency domain signal, and obtain the denoised time domain FID signal through inverse Fourier transform.

[0049] Please see Figure 4In this embodiment, a trained Transformer-based magnetic resonance spectroscopy denoising model is used to denoise the magnetic resonance FID signals in the test dataset, obtaining a denoised frequency domain signal, which can be recovered into a time domain signal and saved using inverse Fourier transform (IFFT). Specifically, the FID time domain signal to be denoised is input into the trained Transformer-based magnetic resonance spectroscopy denoising model to obtain a denoised frequency domain signal, which can be recovered into a high-quality denoised time domain FID signal using inverse Fourier transform (IFFT). After obtaining the final Transformer-based magnetic resonance spectroscopy denoising model, it can be applied to the denoising of actual magnetic resonance experimental data. Specifically, the user can input the acquired NMR FID signal into the denoising device to obtain a denoised NMR frequency domain signal, achieving clear metabolite peak detection and analysis. This method not only supports denoising of a single FID signal but also supports parallel denoising processing of multiple FID signals in batches. The denoising time is also shorter than traditional methods, and it has significant advantages in improving the signal-to-noise ratio and preserving spectral peaks after denoising.

[0050] In summary, this method first acquires noisy free induction decay (FID) signals and their corresponding label signals to construct a training dataset. This dataset is then converted to a frequency domain signal using a Fast Fourier Transform (FFT) and its amplitude is normalized. The real and imaginary parts of the frequency domain signal are projected onto a high-dimensional feature space and fed into a multi-layer Transformer encoder based on a multi-head self-attention mechanism via dual channels to capture global correlations in long sequences. The encoded output is then separated and decoded to recover the real and imaginary parts, which are then combined to obtain the denoised complex frequency domain signal. During training, the complex mean square error is used as the loss function, combined with dynamic learning rate scheduling and an early stopping mechanism to improve convergence stability and model training efficiency.

[0051] In summary, this method effectively captures the characteristics of long sequence dependencies and complex signals by combining frequency domain signal input, position encoding, and a Transformer architecture. It significantly reduces noise while preserving the details of the denoised spectrum, thus improving reliability in magnetic resonance spectral analysis and classification tasks. It can achieve effective denoising at different noise levels, preserving spectral peak shapes and detailed information, and is suitable for the preprocessing and analysis of magnetic resonance spectral data, demonstrating strong practicality and value.

[0052] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A method for denoising magnetic resonance spectroscopy based on Transformer, characterized in that, include: Obtain the noiseless FID signal generated by the exponential decay model, and perform Gaussian white noise superposition processing on the noiseless FID signal to generate a noisy FID signal. Construct a magnetic resonance spectral signal dataset based on the noiseless FID signal and the noisy FID signal. A complex signal denoising model based on Transformer is established. The training set in the magnetic resonance spectrum signal dataset is preprocessed. The preprocessed training set and other datasets in the magnetic resonance spectrum signal dataset are used to train and optimize the complex signal denoising model to obtain the final complex signal denoising model of magnetic resonance spectrum. The original FID signal to be denoised is obtained and input into the final magnetic resonance spectrum complex signal denoising model to obtain the corresponding denoised spectrum frequency domain signal, and the denoised time domain FID signal is obtained by inverse Fourier transform. The magnetic resonance spectrum complex signal denoising model includes an input layer, a complex feature projection layer, a position encoder, a Transformer encoder, a linear decoder, and an output layer. The input layer uses the real and imaginary parts of the complex spectrum as inputs to two linear layer channels, respectively. The complex feature projection layer contains two independent linear layers that process the real and imaginary parts of the frequency domain complex signal, respectively, projecting the real and imaginary parts of each frequency domain signal from 1D to a 128-dimensional high-dimensional feature space. The position encoder concatenates the projected real and imaginary features to obtain a 256-dimensional combined feature vector, and adds position coding, using an alternating sine and cosine coding method to provide position information for each frequency domain component; The Transformer encoder is used to extract relevant features of the spectrum. It contains 6 coding layers, each containing 8 attention heads. The 6 coding layers have the same internal structure and achieve deep feature extraction by stacking layers. Each coding layer contains a multi-head self-attention mechanism, a residual network, normalization and a feedforward neural network. The multi-head self-attention mechanism calculates the correlation weights between different frequency domain components, and the feedforward neural network performs feature transformation and nonlinear activation. The linear decoder consists of two independent linear layers, which reconstruct the real and imaginary parts of the signal, respectively, and are used to combine the real and imaginary part signals in the frequency domain into the final complex frequency domain signal output; the output layer is used to restore the denoised complex frequency domain signal. The multi-head self-attention mechanism uses different projection matrices to calculate the distribution of multiple attentions, obtains the correlation under different spectra, and then combines them through linear transformation.

2. The denoising method for magnetic resonance spectroscopy based on Transformer according to claim 1, characterized in that, No. n A noiseless FID signal Can be modeled as R The sum of the decay exponential components is given by the following formula: , , n=0,...,N-1 ,in, s The signal is a noise-free FID signal, and T is the transpose. For complex fields, N R represents the number of sampling points for the frequency domain signal, and R represents the number of spectral peaks in the spectrum. For the first r The amplitude of each spectral peak The sampling interval is... For the first r The decay time of each spectral peak For the first r Each spectral peak resonant frequency .

3. The denoising method for magnetic resonance spectroscopy based on Transformer according to claim 2, characterized in that, The noiseless FID signal is subjected to Gaussian white noise superposition processing to generate a noisy FID signal, specifically as follows: The noise-free FID signal is subjected to amplitude maximum value normalization processing to ensure that the amplitude of the noise-free FID signal is within a preset standard range. The normalization formula is as follows: , The normalized noise-free FID signal; Gaussian white noise, randomly sampled within a preset noise standard deviation range, is superimposed onto the normalized noise-free FID signal to generate a noisy FID signal. The formula is as follows: ,in, The normalized noise-free FID signal, x For noisy FID signals, It is Gaussian white noise; A noisy magnetic resonance spectroscopy signal dataset with a controllable signal-to-noise ratio is constructed based on noiseless FID signals and noisy FID signals. The magnetic resonance spectroscopy signal dataset includes a training set, a validation set, and a test set.

4. The method for denoising magnetic resonance spectroscopy based on Transformer according to claim 1, characterized in that, The training set in the magnetic resonance spectral signal dataset is preprocessed as follows: The training set is loaded and initialized, and the data loading path and data processing method are set. The complex FID signals in the training set are converted into frequency domain signals by fast Fourier transform, and then split into real and imaginary parts and fed into the input layer of the magnetic resonance spectrum complex signal denoising model.

5. The method for denoising magnetic resonance spectroscopy based on Transformer according to claim 1, characterized in that, The magnetic resonance spectrum complex signal denoising model was trained and optimized using the preprocessed training set and other datasets from the magnetic resonance spectrum signal dataset, specifically as follows: The magnetic resonance spectrum complex signal denoising model is trained using the preprocessed training set, and then trained and optimized using the AdamW optimizer and the validation set of the magnetic resonance spectrum signal dataset. The learning rate is gradually reduced according to a preset decay strategy. When the loss of the current validation set does not decrease significantly within a preset number of training rounds, the learning rate is reduced. The trained complex signal denoising model for magnetic resonance spectroscopy was comprehensively tested and evaluated using the test set of the magnetic resonance spectroscopy signal dataset. The evaluation assessed the generalization ability of the complex signal denoising model on independent test data and its denoising performance on data outside the test set. Specifically, each spectrum in the test set was denoised, and the corresponding denoising results were generated. The denoised results were compared with the labeled signals of the test set, and multiple performance indicators of denoising were calculated to obtain the evaluation results. When the evaluation result is deemed satisfactory, the final magnetic resonance spectrum complex signal denoising model is obtained.

6. The method for denoising magnetic resonance spectroscopy based on Transformer according to claim 1, characterized in that, In the training process of the magnetic resonance spectrum complex signal denoising model, the loss function used is the complex mean square error loss. This function calculates the difference between the denoised frequency domain signal and the noise-free frequency domain signal predicted by the model, and its formula is as follows: , M The total number of frequency domain signals. This is represented by taking the real part of the complex signal. To represent the imaginary part of a complex signal, For the first i Complex values ​​of a frequency domain signal after denoising For the first i The target complex value of a frequency domain signal.

Citation Information

Patent Citations

  • Nuclear magnetic resonance spectrum denoising method based on neural network algorithm

    CN110879980A

  • Brain function connection modeling and coding method, device, equipment and medium

    CN120219863A