A method and system for magnetotelluric signal denoising based on a self-supervised diffusion model
By combining the self-supervised diffusion model TimeDART with time-frequency analysis and VMD low-frequency trend, the problems of low noise identification accuracy and cumbersome manual annotation in magnetotelluric methods are solved, achieving accurate positioning of noise areas and improved fidelity of effective signals.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANCHANG CAMPUS OF EAST CHINA UNIV OF TECH
- Filing Date
- 2026-04-25
- Publication Date
- 2026-06-09
Smart Images

Figure CN122172322A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method and system for denoising magnetotelluric signals based on a self-supervised diffusion model, which belongs to electromagnetic signal processing technology in geophysical exploration. Background Technology
[0002] The Magnetotelluric Method (MT) is a geophysical exploration method that utilizes natural electromagnetic fields to study the electrical structure of the Earth's interior. By simultaneously observing the electric (EX, EY) and magnetic (HX, HY, HZ) components of the natural electromagnetic field at the Earth's surface, it analyzes the propagation characteristics of electromagnetic waves of different frequencies in the subsurface medium and inverts the subsurface resistivity distribution. This method has significant advantages such as large detection depth (tens of meters to hundreds of kilometers), high resolution, no need for artificial field sources, multi-scale application, and strong geological adaptability, and is widely used in the field of geophysical exploration.
[0003] However, magnetotelluric signals face numerous challenges in actual observation: the natural magnetotelluric field signal itself is weak and highly susceptible to electromagnetic interference from industrial facilities, power lines, vehicles, and other human-induced sources, resulting in a low signal-to-noise ratio; noise types are diverse, including impulse noise, square wave noise, high-frequency noise, and power frequency interference; in urban or industrial areas, noise intensity often far exceeds the effective signal, severely impacting data quality and interpretation accuracy. Therefore, denoising is a core component of magnetotelluric data processing.
[0004] Existing magnetotelluric data denoising methods are mainly divided into two categories: traditional denoising methods and modern deep learning methods. Traditional denoising methods include time-domain statistical methods (such as far-reference techniques and robust estimation), frequency-domain filtering methods (such as notch filtering and adaptive filtering), time-frequency analysis methods (such as wavelet transform, empirical mode decomposition (EMD), and variational mode decomposition (VMD), and sparse representation methods (such as K-SVD dictionary learning). For example, Chinese patent application CN120103501A discloses a denoising method for non-stationary nonlinear magnetotelluric sounding signals. By combining variational mode decomposition (VMD) and independent component analysis (ICA), it achieves denoising of magnetotelluric sounding signals from multiple perspectives, including time-frequency domain and statistical characteristics. This method is effective when the effective signal is subjected to long-term high-energy non-stationary noise. However, such methods have problems such as limited anti-interference ability, over-smoothing of the effective signal, low noise identification accuracy, and poor adaptability to complex noise. Moreover, most of them are global uniform processing and do not perform differentiated optimization for noise regions.
[0005] Modern deep learning methods include Convolutional Neural Networks (DnCNN), Recurrent Neural Networks (LSTM), and Transformer architectures. For example, Chinese patent application CN117590478A discloses a method and system for suppressing magnetotelluric (MT) signal noise based on a convolutional neural network and wavelet thresholding. This method constructs clean MMT data and various types of MMT noise, inputs them along with labels into a convolutional neural network for training, and obtains a multi-classification model. Measured MMT data is segmented and input into the multi-classification model to further subdivide the noise types in each data segment and obtain clean data segments. The measured clean data is then superimposed with various types of MMT noise to create simulated noisy data. For each type of simulated noisy data, wavelet thresholding is used for denoising, and the optimal thresholding parameter (WT) is determined based on the signal-to-noise ratio (SNR). Finally, for each noise type data segment in the measured MMT data, wavelet thresholding is used for denoising using the corresponding optimal WT parameter. Although such methods have improved feature extraction capabilities through machine learning models, they still have drawbacks such as insufficient modeling of long-term time-dependent factors, the need for a large amount of labeled data for training, lack of multi-channel collaborative processing, and the tendency to produce artifacts when processing the boundary between noisy regions and effective signals.
[0006] In summary, existing technologies generally suffer from bottlenecks such as difficulty in balancing "effective signal preservation" and "noise suppression," inaccurate noise region identification, lack of regionalized differentiated processing strategies, and the need for manual annotation, which restrict the application effectiveness of magnetotelluric methods. Therefore, developing an intelligent denoising system that eliminates the need for manual sample annotation, accurately identifies noise, provides highly targeted denoising, can process multi-channel data simultaneously, and ensures the fidelity of the effective signal has significant engineering value and application prospects. Summary of the Invention
[0007] The technical problem solved by this invention is to provide a method and system for denoising magnetotelluric signals based on a self-supervised diffusion model, addressing the issues of low noise identification accuracy and cumbersome manual annotation in existing magnetotelluric methods.
[0008] This invention is achieved using the following technical solution:
[0009] This invention first discloses a method for denoising magnetotelluric signals using a self-supervised diffusion model, comprising the following steps:
[0010] S1. Data preprocessing: Time-series segmentation of the magnetotelluric sequence;
[0011] S2, TimeDART diffusion model processing: The segmented magnetotelluric sequence is input into the TimeDART diffusion model for model training and noise reduction.
[0012] The TimeDART diffusion model includes a noise classifier and a diffusion denoiser. The noise classifier outputs a noise mask and deep semantic features. The deep semantic features serve as the key feature K and value feature V of the cross-attention submodule of the decoder in the diffusion denoiser.
[0013] The diffusion denoising device includes at least a diffusion noise-adding layer and a decoder. The diffusion noise-adding layer is based on obtaining a clean mask by inverting the noise mask, and then forward-adding noise to the magnetotelluric sequence of the region corresponding to the clean mask to obtain a noise-adding sequence. Based on the magnetotelluric sequence of the target noise region corresponding to the noise mask, a target noise sequence is obtained. Then, both the noise-adding sequence and the target noise sequence are input into the decoder for self-supervised training of the diffusion denoising device model.
[0014] S3. Using the trained TimeDART diffusion model, the denoised signal of the target noise area is obtained, and then sequentially spliced with the magnetotelluric sequence of the clean area.
[0015] In a method for denoising magnetotelluric signals using a self-supervised diffusion model according to the present invention, the decoder is further composed of a deep network consisting of stacked multi-layer denoising patch decoding blocks. Each decoding block includes a mask self-attention submodule, a cross-attention submodule, and a feedforward network. Each submodule is followed by a residual connection layer and a layer normalization layer.
[0016] The mathematical model of the cross-attention submodule is as follows:
[0017] ;
[0018] Where Q represents the output from the mask self-attention submodule in the current layer of the decoding block, that is, the query feature after the noisy patch sequence / target noise patch sequence has undergone self-attention processing; K is the dimension of the feature, and T is the matrix transpose symbol. This is the output of the cross-attention submodule.
[0019] In a magnetotelluric signal denoising method based on a self-supervised diffusion model of the present invention, the process of the diffusion denoising layer forward-denoising the magnetotelluric sequence of the region corresponding to the clean mask to obtain the denoised sequence is expressed as follows:
[0020] ;
[0021] in, This is the magnetotelluric sequence for the region corresponding to the clean mask. Let t be the noisy sequence at time step t. This is normalized Gaussian noise; The signal is preserved as coefficients, and the following conditions are met:
[0022] ;
[0023] Where t is the current diffusion time step, T1 is the total number of diffusion steps, and s is the preset minimum offset.
[0024] In a magnetotelluric signal denoising method using a self-supervised diffusion model according to the present invention, the model training process of the diffusion denoiser further includes a loss function that includes at least noise prediction loss and reconstruction loss.
[0025] The noise prediction loss is, for the noisy sequence, a measure of the error between the predicted noise of the diffusion denoiser model and the actual noise added during the diffusion process.
[0026] The reconstruction loss includes statistical characteristic consistency loss and boundary smoothing loss for the target noise region; the statistical characteristic consistency loss characterizes the difference between the statistical characteristic distribution of the target noise region and the statistical characteristic distribution of the clean region; the boundary smoothing loss characterizes the smoothness of the boundary transition between the target noise region and the clean region.
[0027] In a method for denoising magnetotelluric signals using a self-supervised diffusion model according to the present invention, the noise classifier further adopts an encoder architecture design based on the TimeDART network, including a series of modules connected in sequence: a channel independent processing module, a patch segmentation module, an embedding layer, a position encoding layer, a Transformer encoder, and a projection head.
[0028] The input magnetotelluric sequence is multi-channel data, and the independent channel processing module performs dimensional transformation to process the magnetotelluric data of different channels independently.
[0029] The positional encoding layer uses cosine positional encoding and is designed for parity of the encoding dimension index.
[0030] In a magnetotelluric signal denoising method based on a self-supervised diffusion model of the present invention, the method further includes: introducing time-frequency analysis to optimize the noise localization of the noise mask in the noise classifier, specifically:
[0031] A1. Extract the narrow bright band interval of the initial magnetotelluric data to be denoised in the time-frequency spectrum through time-frequency analysis, and obtain the first marker mask corresponding to the narrow bright band interval;
[0032] A2. Perform a logical AND operation between the first marker mask and the binarized noise mask to update the noise edge boundary.
[0033] In a magnetotelluric signal denoising method based on a self-supervised diffusion model of the present invention, the method further includes: introducing noise localization of the noise mask in the VMD-optimized noise classifier, specifically:
[0034] B1. Perform variational mode decomposition (VMD) on the initial magnetotelluric data to be denoised, and extract low-frequency strips, thus constructing an envelope of equal width strips that is highly consistent with the main trend of the initial magnetotelluric data.
[0035] B2. Based on the noise edge boundary determined by the current noise mask, move the low-frequency strips of the interval corresponding to every two adjacent noise edge boundaries. The moving distance is determined according to the signal amplitude corresponding to the noise edge boundary.
[0036] B3. Based on the signal coverage of the low-frequency strip in the corresponding interval after the shift, perform adaptive expansion of the noise interval to achieve complete noise mask.
[0037] If the signal coverage exceeds a preset threshold, the entire range is considered a noise region, and the noise mask is completed to update the noise mask. If the coverage does not exceed the preset threshold, the noise edge is considered a discrete noise point and is not expanded, remaining unchanged.
[0038] This invention also discloses a magnetotelluric signal denoising system based on the above-described self-supervised diffusion model, comprising:
[0039] The data preprocessing module performs time-series segmentation of the magnetotelluric sequence;
[0040] The TimeDART diffusion module incorporates a built-in TimeDART diffusion model. Segmented magnetotelluric sequences are input into the TimeDART diffusion model for model training and denoising. The TimeDART diffusion model includes a noise classifier and a diffusion denoising module. The noise classifier outputs a noise mask and deep semantic features. The deep semantic features serve as the key feature K and value feature V of the cross-attention submodule in the decoder of the diffusion denoising module. The diffusion denoising module includes at least a diffusion noise layer and a decoder. The diffusion noise layer obtains a clean mask by inverting the noise mask, then forward-noises the magnetotelluric sequence corresponding to the clean mask region to obtain a noisy sequence. A target noise sequence is obtained based on the magnetotelluric sequence of the target noise region corresponding to the noise mask. Both the noisy sequence and the target noise sequence are then input into the decoder for self-supervised training of the diffusion denoising module model.
[0041] The sequence splicing module uses the trained TimeDART diffusion model to obtain the denoised signal of the target noise region, and splices it sequentially with the magnetotelluric sequence of the clean region to obtain the denoised magnetotelluric signal.
[0042] The present invention also discloses a computer device, including one or more processors; a memory storing one or more computer programs; wherein the processor calls the computer programs to implement the steps of the magnetotelluric signal denoising method of the self-supervised diffusion model described above in the present invention.
[0043] The present invention also discloses a computer-readable storage medium storing a computer program, which is called by a processor to implement the steps of the magnetotelluric signal denoising method of the self-supervised diffusion model described above.
[0044] The present invention, by adopting the above technical solution, has the following beneficial effects:
[0045] (1) High noise identification accuracy. This invention adopts a multi-level verification mechanism of "TimeDART + time-frequency analysis + VMD low-frequency trend" to construct a cross-domain feature complementary enhancement mechanism, thereby achieving accurate positioning of noise regions and boundaries and solving the problems of fuzzy noise identification and high misjudgment rate in existing methods. The TimeDART diffusion model can effectively capture the temporal evolution characteristics and long-range dependence of magnetotelluric signals, and achieve preliminary identification of noise boundaries. The TimeDART diffusion model captures the temporal evolution mode and boundary position of noise temporal features, time-frequency analysis captures the energy accumulation characteristics and transient localization of noise time-frequency features, and VMD realizes structural domain features, extracts the intrinsic modes of the signal, and geometric constraints. Through the logical fusion and geometric constraints of multi-domain features, a leap from "single-domain coarse identification" to "multi-domain fine positioning" is achieved, significantly improving the integrity and robustness of noise identification. Based on the above complementary characteristics, this invention proposes a dual-path fusion mechanism of "time-domain boundary + time-frequency energy": the noise mask output by the TimeDART diffusion model is based on the time-domain noise boundary of sequence semantics, and the time-frequency analysis outputs the first marker mask corresponding to the narrow bright band interval of the initial magnetotelluric data in the time-frequency spectrum. Based on the time-frequency energy noise boundary of local energy accumulation, only the regions that simultaneously satisfy "time-domain semantic anomaly" and "time-frequency energy anomaly" are retained through logical AND operation. This strategy effectively suppresses single-domain false detections through cross-domain feature cross-validation and achieves accurate calibration of the noise boundary.
[0046] (2) Good signal fidelity. This invention constructs a noise classifier model and a diffusion denoising model based on the overall architecture of the TimeDART diffusion model. The initial magnetotelluric data first passes through the noise classifier to generate a noise mask to identify which time points belong to the noise region. Then, the diffusion denoising model based on the diffusion model only processes these noise regions to generate denoised signal segments. Finally, the denoised target noise region is merged with the clean region of the initial magnetotelluric data, and a smoothing constraint is applied to ensure the continuity and physical rationality of the output signal. By adopting a regional selective denoising strategy, only the noise region is processed, and the effective signal region is completely preserved, avoiding the over-smoothing problem of traditional methods and ensuring the detailed features of the signal.
[0047] (3) No manual sample labeling is required. Based on the TimeDART diffusion model, the self-supervised learning paradigm generates noise masks as pseudo-labels by utilizing the inherent characteristics of magnetotelluric data, thus addressing the pain points of scarce labeled data and high labeling costs in the field of magnetotelluric data; the methods of other modules in this invention also do not require manual data labeling.
[0048] (4) High processing efficiency. This invention reduces the complexity of computing electromagnetic data through patch embedding technology, improves the convergence speed of the model by two-stage separate training of the noise classifier model and the diffusion denoising model, and adapts the batch processing mechanism to large-scale magnetotelluric data processing;
[0049] In summary, this invention provides a magnetotelluric signal denoising method and system based on a self-supervised diffusion model. Combining deep learning, time-frequency analysis, and VMD techniques for extracting low-frequency trends, it eliminates the need for training with manually labeled sample libraries. By directly inputting multi-channel noisy magnetotelluric data, it can achieve precise localization of noisy regions, differentiated denoising, and smooth fusion. While efficiently suppressing noise, it preserves the effective signal characteristics to the greatest extent, improving the automation level of noise suppression, signal-to-noise recognition accuracy, and denoising accuracy. It effectively solves the problems of existing methods, such as the need for manual parameter setting, loss of a significant amount of effective signal, low signal-to-noise recognition accuracy, and weak adaptability. It is suitable for magnetotelluric signal noise suppression in scenarios such as mineral resource exploration, geothermal resource development, earthquake prediction research, deep structural exploration, engineering geological exploration, and environmental geological surveys.
[0050] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. Attached Figure Description
[0051] Figure 1 This is a basic schematic diagram of the noise classifier model and diffusion denoising model provided by the present invention.
[0052] Figure 2 This is a diagram of the encoder-decoder structure in this invention.
[0053] Figure 3 This is a flowchart of the identification and denoising process of the initial magnetotelluric data to be denoised according to the present invention.
[0054] Figure 4 This is a schematic diagram illustrating the specific implementation of magnetotelluric data in the noise identification stage.
[0055] Figure 5 This is a partial sample display of simulation data from a certain measuring point in Qinghai before and after noise was added.
[0056] Figure 6 It is a complete time series visualization of the simulation data before and after noise reduction.
[0057] Figure 7 It is a visualization of the local time series before and after noise reduction of the simulation data.
[0058] Figure 8a , 8b Figures 8c and 8d show the apparent resistivity and phase curves before and after simulation data processing. Detailed Implementation
[0059] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. The technical features involved in the various embodiments of the invention described below can be combined with each other as long as they do not conflict with each other.
[0060] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0062] Example 1
[0063] This invention provides a magnetotelluric signal denoising method based on a time-frequency joint and self-supervised diffusion model, comprising the following steps:
[0064] S1. Data Preprocessing: First, the magnetotelluric data is converted into a processable NumPy array format. Then, Z-score normalization is used for data normalization. Finally, the normalized long-term time series data is segmented in a non-overlapping manner with a window size of 450 time points and a step size of 450, outputting magnetotelluric time series data of shape [N, 450, 5]; N is the number of samples / the number of segments. It should be understood that the above window size and step size are only illustrative examples.
[0065] During the simulation phase, clean magnetotelluric data is mixed with noise signals to form simulated magnetotelluric data. The added noise signals include impulse noise, Gaussian noise, and square wave noise.
[0066] S2. Input the time-series segmented magnetotelluric data into the TimeDART diffusion model for model training and noise reduction.
[0067] The TimeDART diffusion model proposed in this invention includes a noise classifier and a diffusion denoising model, correspondingly dividing the classification and denoising training task into two stages. The first stage of training is the noise classifier training, which is used to initially locate noisy regions, generate a binary noise mask for magnetotelluric data, and then evaluate and save the best noise classifier model. The second stage of training involves freezing the encoder, patch embedding, and classification projection head parameters to obtain the optimal noise classifier model, and then training the diffusion denoising model to obtain the optimal diffusion denoising model.
[0068] Specifically, this embodiment applies the TimeDART diffusion model to this field, employing a two-stage architecture. The first stage acts as a noise classifier, identifying noise edges in magnetotelluric data and locating noise regions. Its encoder outputs a binary noise mask while simultaneously passing the extracted deep semantic features (o1) to the second stage. The second stage, the diffusion denoiser, on the one hand, determines clean regions based on the binary noise mask, and then introduces the diffusion model to forward-add noise to these clean regions to reconstruct the noise; and on the other hand, it determines the target noise region and target noise signal based on the binary noise mask. Furthermore, for both the reconstructed noise and the target noise signal, a cross-attention mechanism is used to reference the clean region features (deep semantic features o1) of the magnetotelluric data, guiding the diffusion denoiser to target the clean region features within the reference sample during noise reduction, ensuring consistency between the denoising result and the original signal, thus achieving model training and improving the denoising effect on the target noise signal. Therefore, the TimeDART diffusion model proposed in this invention eliminates the need for manual data annotation, enabling end-to-end completion of the entire process from noise identification to signal reconstruction, and realizing a self-supervised training paradigm.
[0069] like Figure 1As shown: The input magnetotelluric data first passes through a noise classifier model to generate a binary noise mask, identifying which time points in the magnetotelluric time series data belong to noisy regions and which belong to clean regions. Then, for the clean regions, a forward noise reconstruction is performed to reconstruct the noise signal. Following this, the deep semantic features o1 of the noise classifier model are referenced to perform targeted denoising on the reconstructed noise, guiding the training of the diffusion denoising model. This facilitates the diffusion denoising model to perform targeted and precise denoising on the target noise regions, generating denoised signal segments. Finally, the denoised data from the target noise regions is sequentially merged with the clean region data from the initial magnetotelluric time series data.
[0070] The model input is set as a noisy magnetotelluric time series X, with dimensions defined as [B, L, C]. Here, B, L, and C correspond to batch size, time series length, and number of feature channels, respectively. Feature channels typically cover five typical components of the magnetotelluric signal (Ex, Ey, Hx, Hy, Hz), where Ex is the east component of the horizontal electric field (electric field along the east-west direction), Ey is the north component of the horizontal electric field (electric field along the north-south direction), Hx is the north component of the horizontal magnetic field (magnetic field along the north-south direction), Hy is the east component of the horizontal magnetic field (magnetic field along the east-west direction), and Hz is the vertical magnetic field component (magnetic field along the vertical direction).
[0071] Phase 1: Noise Classifier.
[0072] The noise classifier adopts an encoder architecture based on the TimeDART model, which includes a series of modules connected in sequence: a channel independent processing module, a patch segmentation module, an embedding layer, a position encoding layer, a Transformer encoder, and a projection head. Its main task is to identify the noise region in the magnetotelluric signal in the input sample data and the deep semantic features o1 that characterize the features of the clean region.
[0073] The independent channel processing module is used for channel conversion, processing magnetotelluric data from different channels independently. In this embodiment, the original magnetotelluric data X has five typical components (Ex, Ey, Hx, Hy, Hz) in its channel C channels. After processing by the independent channel processing module, each component is processed separately, and the corresponding dimensions become: This design takes into full account that different electromagnetic components may have different noise characteristics, thus allowing the noise classifier model to learn independently the magnetotelluric data characteristics of each channel.
[0074] The patch segmentation module divides the magnetotelluric data of each channel into multiple patch sequences using a sliding window method. In this embodiment, the patch segmentation uses a sliding window method to divide the magnetotelluric data of each channel into fixed-length patch segments according to the time series. The feature shape after segmentation is as follows: , where n represents the number of patch sequences and l represents the length of the patch sequence.
[0075] The embedding layer converts each patch sequence (magnetic data) into a high-dimensional feature representation, thereby obtaining a magnetotelluric data tensor. In this embodiment, the embedding layer is a linear layer that maps the patch sequence from the l-dimensional dimension to the d-dimensional dimension, thus obtaining... The magnetotelluric data tensor is used to convert the raw magnetotelluric data signal into a high-dimensional feature representation, which prepares for subsequent Transformer processing.
[0076] The location coding layer uses sine and cosine functions to generate location codes for the magnetotelluric data tensor after the embedding layer.
[0077] In this embodiment, the cosine position encoding employs a parity design for the encoding dimension index, targeting the patch sequence at any position pos in the magnetotelluric data tensor and the encoding dimension index of the patch sequence. Formal definition:
[0078] ,
[0079] .
[0080] Where pos corresponds to the n-dimensionality of the magnetotelluric data tensor, representing the position index of the patch sequence; i corresponds to the d-dimensionality, representing the dimension index of the encoding vector; For even-numbered dimensions of the corresponding encoding vector, counting starts from 0. For odd-numbered dimensions, each group (2i, 2i+1) corresponds to a different frequency base. and d is the dimension of the current Patch sequence. , These represent the values in the i-th and i+1-th dimensions of the position encoding vector corresponding to the position index pos; that is, each position pos has a set of d-dimensional position encoding vectors. This refers to the i-th element in the positional encoding vector. This encoding method, through the angle sum property of trigonometric functions, allows the relative relationship between any two positions to be represented by a linear combination of their absolute positional codes. Specifically, for position... and The positional codes of these positions have the following relationship:
[0081] .
[0082] in, For frequency parameters, for The orthogonal correspondences. This characteristic allows the model to easily learn relative positional relationships, making it particularly well-suited to the temporal dependencies of time series data.
[0083] Before entering the positional encoding layer, an SOS token is added to the beginning of the sequence of sample data, and the last position of the sequence is discarded, thus keeping the sequence length unchanged. The SOS token serves as a start marker for the sequence, helping the model better understand the beginning position of the sequence, enabling the model to better capture the sequence's initial features and overall temporal logic.
[0084] The Transformer encoder uses the CausalTransformer architecture, such as Figure 2 As shown, the Transformer encoder in this embodiment includes three Transformer coding blocks. The output of the previous Transformer coding block serves as the input of the next Transformer coding block. Each Transformer coding block contains a multi-head self-attention mechanism and a feedforward neural network. It should be understood that the three-layer structure in this embodiment is for illustrative purposes only. In other feasible embodiments, the layers of the Transformer coding blocks can be adaptively adjusted.
[0085] In this embodiment, the multi-head self-attention mechanism employs a causal mask (lower triangular mask) to ensure that each location can only focus on itself and previous locations, thus conforming to the causal nature of magnetotelluric data time series. Specifically, when calculating attention weights, the attention score for future locations is set to negative infinity using a mask matrix, and after softmax, the weights of these locations approach zero. This design strictly adheres to the causal characteristics of time series, conforming to the physical causal law of MT signals formed by the propagation of electromagnetic fields in the underground medium, effectively avoiding non-physical correlations caused by "future information leakage." Multi-head attention allows the noisy classifier model to learn information from different representation subspaces, enhancing the model's expressive power. Each attention head independently calculates the Query, Key, and Value, and the outputs of multiple heads are concatenated and linearly transformed to obtain the final output. Since this design is achievable with existing technology, it will not be described in further detail, and other feasible attention mechanisms can be replaced with existing technologies in other feasible embodiments.
[0086] The feedforward neural network consists of two linear layers and a GELU activation function to perform a non-linear transformation on the attention output. Residual connections and LayerNorm are applied after each sub-layer to stabilize the training process and accelerate convergence.
[0087] The projection head employs an autoregressive flattening projection head (ARFlattenHead) (existing technology) to project high-dimensional features back into the original signal space. The output of the Transformer encoder passes through the ARFlattenHead, which projects high-dimensional features back into the original signal space. Specifically, it first maps the patch sequence from d-dimensional to l-dimensional using a linear layer, then flattens the patch sequence into a continuous time series, and finally adjusts the dimensional order to obtain an output of [B, L, C]. If the length of the flattened sequence is inconsistent with the original input length, linear interpolation is used for adjustment.
[0088] Specifically: Record the first l The output of the Transformer coded block is H ( l If ), then the final output of the Transformer encoder is It contains deep semantic information of the original signal. The encoder output... After being mapped back to the original signal space by the ARFlattenHead projection head, it is first processed through a linear layer. d Dimension mapping to l The dimensions are then determined, the patch sequence is flattened into a continuous time series, and finally the dimensional order is adjusted to obtain the reconstructed signal [B, L, C]. .
[0089] Finally, the reconstructed signal is calculated using the sigmoid function. The noise probability is generated based on the difference between the noise data and the original magnetotelluric data X, and a binary noise mask is generated based on the noise probability. The binary noise mask serves as the output of the noise classifier model and is included in the output of the Transformer encoder within the noise classifier model. Input the diffusion denoising model trained in the second stage. The output is... The dimension is Output As a deep semantic feature o1, it contains deep semantic information of the original signal and will be used to generate the Key and Value of the cross-attention submodule of the second-stage decoder, providing feature references for clean regions within the sample for the denoising process.
[0090] The noise mask in this embodiment is a binary noise mask m, and the construction process is as follows:
[0091] First, the probability of generating noise: .
[0092] In the formula, when When the difference from X is large, the sigmoid function output is close to 1, indicating that the position is likely noise; when the difference is small, the output is close to 0, indicating that the position may be a clean signal.
[0093] Then, by setting a threshold, such as 0.8, the noise probability is converted into a binary noise mask m:
[0094] .
[0095] Second stage: diffusion denoising device.
[0096] The diffusion denoiser employs the concept of a diffusion model, and its ultimate task is to denoise the noisy regions identified by the noise classifier model, achieving high-quality magnetotelluric signal reconstruction. The denoising process of the diffusion denoiser model includes the following sub-steps:
[0097] S21. Based on the binary noise mask, determine the target noise region and the clean region; then extract the magnetotelluric data of the target noise region, and divide it into multiple noise patch sequences through the channel independent processing module and the patch segmentation module to obtain the target noise; and for the clean region, after being divided into multiple clean patch sequences through the channel independent processing module and the patch segmentation module, introduce a diffusion model to add forward noise to the clean patch sequences to obtain the reconstructed noise.
[0098] On the one hand, the target noise region r is extracted based on the binary noise mask output by the noise classifier. X represents the original input magnetotelluric data. The extracted target noise region r also passes through the Channel Independence module and the Patch segmentation module to obtain the corresponding noise region. The tensor is denoted as Xn, which represents the set of noise patch sequences (target noise). The channel-independent processing module and patch segmentation module in the diffusion denoising model are the same as those in the noise classifier model; therefore, their data processing procedures will not be described.
[0099] Secondly, the input original magnetotelluric data X also undergoes channel independence processing and patch segmentation to obtain X. p The clean region mask M is determined based on the binary noise mask. clean From X p Find the set of clean Patch sequences using the middle index, denoted as And thus to Forward diffusion is performed to add noise. It should be understood that this applies to both the binary noise mask and the clean region mask M. clean Either channel independence processing and patch segmentation can be performed first, or the clean region of the index or the target noisy region can be processed first.
[0100] The forward noise addition process is the core step of the diffusion model. The diffusion model first randomly samples each patch for one time step t. T1 is the total number of diffusion steps. Different noise addition schedules are assigned to different patches in the set, and then forward diffusion is carried out through a cosine scheduling strategy to achieve a gradual transformation of signal into noise, ensuring the rationality and convergence of the diffusion process.
[0101] The cosine scheduling strategy defines the signal preservation coefficient using the square cosine function. The intensity of noise addition at each step is indirectly controlled, and its mathematical expression is:
[0102] .
[0103] Where t is the current diffusion time step, and s is a preset small offset used to avoid retaining the coefficient when t=0. The initial signal perturbation caused by the abrupt change ensures smooth noise addition in the early stages of diffusion, while mitigating the problem of excessive noise addition when t approaches T. Signal preservation coefficient. The value is (0,1] and decreases monotonically as time step t increases, which determines the retention ratio of the original Patch signal and the noise superposition intensity during forward diffusion.
[0104] Noise addition coefficient at each step As the diffusion rate is determined by the cumulative signal retention factor By reverse derivation, no additional intermediate parameters need to be defined; the derivation formula is as follows:
[0105] .
[0106] In the formula, the initial value The default value is 1, and the result is calculated using this formula. This ensures that the noise addition process conforms to the asymptotic characteristics of cosine modulation, making Maintain a small value in the early stage of diffusion and increase it slowly in the later stage to avoid premature destruction of signal characteristics.
[0107] After normalizing the added noise and the original patch signal to maintain dimensional consistency, the forward diffusion process achieves a gradual transformation of the original signal into noise through the following formula:
[0108] .
[0109] in, For a clean Patch collection The clean patch sequence in the middle, The Patch sequence after adding noise at time step t. This is normalized Gaussian noise. Gaussian noise is disordered but conforms to a certain mathematical distribution.
[0110] This formula satisfies the weight. + =1, ensuring The energy range is consistent with the original signal to avoid amplitude drift; as the time step t increases, Monotonically decreasing, weights of the original signal components Gradually decrease, noise component The weight gradually increases, making Gradually submerged by noise; when t=T (reaching the total time step), It approaches pure Gaussian noise, completing the entire forward diffusion process.
[0111] S22. Input both the target noise and the reconstruction noise from step S21 into the decoder for model training. Specifically, the patch sequence generates query features via the decoder's masked self-attention submodule, and the co-encoder outputs... (Deep semantic feature o1) serves as the K feature (Key feature) and V feature (Value feature) of the cross-attention submodule in the decoder, realizing a progressive mapping from noise features to clean signals.
[0112] Specifically, the core task of the diffusion denoiser is to target and denoise the noise regions identified by the noise classifier. This stage is based on the progressive denoising idea of the diffusion model, and uses the cross-attention mechanism in the decoder block to process the deep semantic features extracted by the noise classifier in the first stage. Using the semantic features of clean regions as a reference, high-quality signal reconstruction is achieved.
[0113] The decoder consists of a deep network composed of stacked layers of denoising patch decoder blocks, such as... Figure 2 As shown, each decoding block contains a masked self-attention submodule, a cross-attention submodule, and a feedforward network. Each submodule is followed by a residual connection layer and a layer normalization layer to effectively alleviate the vanishing gradient problem and ensure stable gradient propagation during training. Both the noisy patch sequence and the target noise patch sequence serve as the raw input to the decoder, first passing through a patch embedding layer and a positional encoding layer; then, the initial query features for the decoder are obtained through the masked self-attention submodule in the decoding block. The patch embedding layer and positional encoding layer are completely consistent with the encoder preprocessing in the first stage.
[0114] The Masked Self-Attention (MSA) submodule allows the decoder's Query features to focus on other positional information within the sequence, enabling feature interaction within the sequence and outputting... This means that subsequent features are used as query features. The decoder of the preferred diffusion denoising model employs a partial mask mechanism. Unlike traditional causal masks that only mask future positions that are not yet modeled, this mechanism masks future positions while adhering to causal constraints, and randomly masks historical positions at a preset ratio. This preset ratio is controlled by the mask_ratio hyperparameter, such as 30%. By randomly masking some historical positions, the model avoids over-reliance on feature information from specific historical positions, enhancing its robustness to positional perturbations. Its regularization effect can effectively suppress overfitting. This module employs a partial mask mechanism, which, while adhering to causal constraints (masking future positions), randomly masks some historical positions at a preset ratio to avoid over-reliance on feature information from specific historical positions, thus enhancing its robustness to positional perturbations.
[0115] Output The next module is the Cross-Attention submodule, a core module that distinguishes the decoder from the encoder and is the key mechanism for achieving collaboration between the first and second stages. Through Cross-Attention, the decoder's Query feature (representing the "noisy features that need denoising") "queries" the output of the first-stage encoder. The key / value pairs represent "reference features of the clean region within the sample". This mechanism allows the decoder to refer to statistical features such as trends and fluctuations within the clean region of the same sample when reconstructing noisy regions, learn the mapping relationship between noise and the original signal, ensure that the denoising result is consistent with the clean region, and avoid producing artifacts that do not match the style of the original signal.
[0116] Its calculation follows the standard attention mechanism formula:
[0117] .
[0118] Where Q represents the output from the mask self-attention submodule in the current layer decoding block. That is, the query features of the noisy patch sequence / target noise patch sequence after self-attention processing; K and V both come from the output of the stage-one encoder. This refers to the deep semantic features of the original signal, which contain statistical information about clean regions. It is the dimension of the K vector. This is used to scale the dot product result, preventing the gradient of the softmax function from vanishing due to excessively large values. As shown above, the cross-attention submodule, as a key connection mechanism in the encoder-decoder architecture, is responsible for aligning and fusing the clean semantic features of the encoder with the query features of the decoder. Through the cross-attention mechanism, the decoder's query features can "query" the clean semantic features of the encoder, learn the mapping relationship between noise and the original signal, and achieve accurate recovery of the original signal from noise.
[0119] To further improve the model's generalization ability, the cross-attention submodule is preferred to adopt a partial masking mechanism, which randomly masks part of the key positions according to a preset ratio, thereby reducing the model's dependence on specific semantic features.
[0120] Output of cross attention Further processing is performed using a feedforward network (FFN) to output the desired result. The feedforward network has the same structure as the encoder, consisting of two linear layers and a GELU activation function: the first linear layer enhances the feature dimension of the magnetotelluric data, and the GELU activation function introduces a nonlinear mapping; the second linear layer restores the feature dimension of the magnetotelluric data to the original dimension, realizing in-depth processing and dimension adaptation of the features.
[0121] The final output of the decoder is processed by an autoregressive flattened head (ARFlattenHead), denoted as the final output of the decoder. The projection head maps the high-dimensional semantic features output by the decoder to the dimensional space of the original signal, and finally outputs the denoised region features F. The tensor format is [B,L,C], where B is the batch size, L is the sequence length, and C is the number of channels, which is consistent with the dimension of the original input signal.
[0122] S23. The denoised magnetotelluric data of the target noisy area is fused with the magnetotelluric data of the clean area to ensure the continuity, naturalness, and consistency with the physical laws of the magnetotelluric data of the fused signal. The fusion process employs a mask-weighted fusion strategy.
[0123] .
[0124] Where X represents sample data containing both clean and undenoised regions, and m is a binary noise mask; noisy regions are marked as 1, and clean regions are marked as 0. The expression is a logical NOT, where d represents the noise region features output by the decoder of the diffusion denoising model, and f represents the final fused magnetotelluric data signal. This formula, through the weighting effect of a mask, achieves precise fusion by preserving the original information in clean areas and replacing noisy areas with the denoised results, thus preventing interference with clean areas from a fundamental mechanism.
[0125] In this embodiment, a two-stage training strategy is adopted for the TimeDART diffusion model, namely the noise classification stage and the denoising stage.
[0126] The diffusion denoising model training employs a dual loss method that integrates noise prediction loss and reconstruction loss. The noise prediction loss constrains the pixel-level error between the model's predicted noise and the actual noise. The reconstruction loss includes statistical consistency loss and boundary smoothing loss. Statistical consistency loss constrains the consistency between the mean and standard deviation of the target noise region features after denoising, while boundary smoothing loss constrains the smoothness of the transition between the noise region and the clean region.
[0127] The first stage focuses on training a noise classifier to learn how to identify noisy regions in the signal. This embodiment uses binary cross-entropy loss to evaluate the difference between the predicted noise probability and the true noise label, representing the loss of the noise classifier. The definition is as follows:
[0128] .
[0129] in, The binary cross-entropy loss is a core metric for evaluating classification performance, and its mathematical expression is:
[0130] .
[0131] Where N represents the number of samples in the training batch. This is a pseudo-label for the i-th magnetotelluric signal sample. The output is the probability that the i-th sample belongs to the noise category. For regularization terms; These are the weighting coefficients.
[0132] Binary cross-entropy loss guides the model to learn more accurate noise recognition boundaries by quantifying the difference between the predicted probability distribution and the true label; while As a regularization term, its design goal is to guide the model to generate differentiated prediction results for different input magnetotelluric signal samples, effectively avoiding the model from falling into a homogeneous prediction degradation state due to overfitting or learning bias, thereby improving the model's generalization ability to complex noise scenes. It should be understood that in other feasible embodiments, adjusting the loss function of the noise classifier with reference to existing technologies is also feasible, as long as the classification model training can be achieved.
[0133] In the second stage, the focus is on training the diffusion denoiser, which learns to recover clean patch sequences from noisy patch sequences / target noise patch sequences. The model learns the complete inverse process of "noise addition - denoising" on clean regions. When applying the inference, this capability is transferred to noisy regions of real magnetotelluric data to achieve targeted denoising.
[0134] During the training phase of the diffusion denoising model, it is preferable to use a dual loss function framework to fuse the noise prediction loss. With reconstruction loss This approach achieves the dual goals of accurate noise removal during training and consistent reconstruction of intra-sample features through weighted combination. The total loss function is defined as: .in, and These are adjustable weight hyperparameters that control the contribution of the two types of losses, initially set to 0.5 for both, and then tuned based on test results. The following provides a detailed explanation of each loss module.
[0135] Noise prediction loss This is the core, fundamental loss of the diffusion model. Its goal is to enable the model to accurately predict the noise added during the diffusion process, ensuring the model's ability to identify and remove noise. Let the number of pixels in the noise region after diffusion in step S21 be... t is the diffusion step number, and the noise predicted by the diffusion denoising model is... The actual noise added during the diffusion process is Then the noise prediction loss Calculated using mean square error:
[0136] .
[0137] in, This is the denoising prediction output of the diffusion denoiser model for the noisy region. This loss constrains the pixel-level error between the model's predicted noise and the actual noise, ensuring the model can reconstruct the inverse process of diffusion and accurately remove artificially added diffusion noise. After training iterations, the model gradually learns its noise removal capabilities. In other feasible embodiments, the object remains unchanged, but the mean squared error is not necessarily used.
[0138] Reconstruction loss This is the core constraint for achieving reconstruction driven by non-noise regions within the sample data. By aligning the denoised features of the target noisy region with the features of the clean region within the same sample, it avoids the model generating denoised results without constraints. This loss consists of two sub-modules: statistical property consistency loss and boundary smoothing loss.
[0139] Statistical consistency loss By constraining the consistency of the mean and standard deviation along each feature dimension, this approach aims to ensure that the statistical feature distribution of the denoised target noise region remains consistent with that of the clean region within the sample data. This guarantees the feature consistency of the reconstruction result and ensures that the denoised noise region of the guided model matches the clean region within the sample in terms of core statistical features such as trend level and fluctuation amplitude, thus avoiding global trend shifts or abnormal fluctuations in the reconstruction result. It is defined as follows:
[0140] .
[0141] in, , Let represent the average values of the noisy region and the clean region of the d-th feature target, respectively. , Let represent the variances of the target noise region and the clean region of dimension d, respectively; where feature d represents core statistical features such as trend level and fluctuation amplitude. The calculation process is as follows:
[0142] Based on the d-th feature dimension of the time series data, first extract the time step feature set of the clean region within the sample. :
[0143] .
[0144] in, For all time steps of the d-th feature dimension, is a binary mask for the clean region, where 1 represents the clean time step and v represents the d-th feature of a single time step;
[0145] Then, calculate the statistical characteristics of the clean region:
[0146] ,
[0147] .
[0148] in, denoted as the number of time steps for the clean region in the d-th feature dimension.
[0149] Next, the time-step feature set of the denoised target noise region is extracted. :
[0150] .
[0151] in, The denoised output for the target noise region in the d-th feature dimension. This is a binary mask for the noisy region. The statistical characteristics of the denoised region are calculated in the same way as above.
[0152] Boundary smoothing loss The aim is to constrain the smoothness of the boundary transition between the target noise region and the clean region, and to eliminate abrupt changes in the temporal trend of the reconstruction results. Let the start and end time steps of the temporal boundary coordinates of the target noise region be decomposed into... and The final output of the model is The boundary smoothing loss is calculated as follows:
[0153] .
[0154] Where T is the total time step length of the time series sample; This represents the value of the output sequence at time step i. If it has multiple feature dimensions, it can be calculated dimension by dimension and then summed. .
[0155] Thus, the statistical consistency loss is achieved. With boundary smoothing loss The reconstruction loss is obtained through weighted combination. , .
[0156] The aforementioned dual-loss framework, through the design of basic noise prediction and in-sample feature constraints, achieves a balance between accuracy and consistency in temporal diffusion denoising of magnetotelluric data. The noise prediction loss ensures that the model grasps the inverse process of diffusion, enabling accurate identification and removal of diffusion noise, thus providing basic denoising capabilities for temporal reconstruction. The reconstruction loss uses clean regions within the sample as reference templates, employing statistical feature alignment trends, fluctuation matching, and temporal boundary smoothing constraints to allow the model to transfer the temporal feature patterns of clean regions to the reconstruction process of noisy regions. The weighted combination of these two types of losses ultimately achieves the goal of both removing noise and ensuring consistency between the reconstruction results and the temporal features of clean regions within the sample, resulting in denoised outputs with higher realism and temporal continuity.
[0157] It should be understood that this embodiment, for the diffusion denoiser, simultaneously incorporates the noise prediction loss. and reconstruction loss Model training involves simultaneously inputting the segmented target noise patch sequence and the noisy patch sequence from step S21 into the decoder, calculating the loss based on the prediction results, and iteratively training. In other feasible embodiments, the noise prediction loss can be... and reconstruction loss Split and step-by-step training, i.e., based on the noise prediction loss corresponding to the noisy patch sequence. First, perform model pre-training; then, based on the reconstruction loss corresponding to the target noise patch sequence. Perform model fine-tuning.
[0158] In some embodiments, the trained TimeDART diffusion model can be directly used for signal denoising of the magnetotelluric data to be denoised. That is, by inputting the TimeDART diffusion model, directional noise is added to the target noise region, and then the clean signal is spliced together to obtain a complete clean time series signal. In some embodiments, for the magnetotelluric data to be denoised, self-supervised model training is first achieved using S1 and S2, and then the denoised signal is output.
[0159] In some embodiments, when using a trained TimeDART diffusion model to process the magnetotelluric data to be denoised, time-frequency analysis and / or VMD are preferably introduced to optimize the noise localization of the noise classifier.
[0160] The technical approach to noise localization by introducing time-frequency analysis to optimize the noise classifier is as follows:
[0161] A1. Extract the narrow bright band intervals in the time-frequency spectrum of the initial magnetotelluric data to be denoised through time-frequency analysis, and obtain the first marker mask corresponding to the narrow bright band intervals.
[0162] A2. Perform a logical AND operation between the first marker mask and the binary noise mask to update the noise edge.
[0163] The first marker mask can not only be directly used to identify noise regions, but its core value lies in performing a logical AND operation with the noise edges (binarized noise mask) identified by the TimeDART model. This enhances the true noise edge features, achieves precise calibration of noise edge positions, and ultimately completes end-to-end processing from multi-channel time-domain signal input to high-precision noise edge mask output. In this embodiment, the first marker mask is a three-dimensional Boolean mask. In other feasible embodiments, other types of masks can be selected, as long as they can be logically ANDed with the binary noise mask.
[0164] Noise in magnetotelluric data exhibits complex multi-domain coupling characteristics, manifesting as abrupt amplitude changes in the time domain and abnormal energy accumulation in the frequency domain. In the time-spectrum graph, a clear high-energy accumulation region, known as a narrow bright band, is observed. Therefore, this embodiment, for the input five-channel magnetotelluric data (EX, EY, HX, HY, HZ) to be denoised, obtains the time-frequency energy spectrum through continuous wavelet transform (CWT), then detects the narrow bright band region, and finally outputs the first marker mask corresponding to the extracted region. The criteria for checking the narrow bright band region can refer to existing rules and techniques in the field, and this invention does not impose specific limitations on them. In some embodiments, it is also preferable to perform multiple rounds of optimization on the narrow bright band time interval extracted based on the time-frequency energy spectrum. This process uses adaptive binarization segmentation, supporting fixed thresholds and segmented quantile thresholds, with a default 94 quantile. Specifically, the time-frequency energy spectrum is binarized to obtain a preliminary energy region mask. Then, energy regions that meet the continuous distribution requirement in the frequency domain are selected based on the minimum bandwidth, generating a single-channel Boolean mask for the marked bright band time points. Based on this, continuous time intervals are extracted from the time point mask. First, invalid short intervals are filtered out according to the minimum duration, and then adjacent intervals are merged according to the maximum connection gap, finally obtaining the effective time interval of the narrow bright band in seconds.
[0165] Specifically, after normalizing the single-channel signal of the magnetotelluric data, continuous wavelet transform (CWT) calculation is performed, as follows:
[0166] 1. Based on frequency range Calculate the corresponding scale sequence:
[0167] .
[0168] In the formula, is the wavelet transform scaling factor, which characterizes the degree of scaling of the wavelet in the time domain; The center frequency of the selected wavelet basis is denoted as f; f is the target analysis frequency, which is taken within a specified frequency range. [Inside]; fs is the sampling frequency of the original signal.
[0169] 2. Perform continuous wavelet transform on the single-channel signal of the magnetotelluric data:
[0170] .
[0171] In the formula, W(a,t) are the continuous wavelet transform coefficients, which are complex values and contain the amplitude and phase information of the signal in the time and frequency domains; CWT(⋅) represents the continuous wavelet transform operator; x(t) is the original time-domain signal to be analyzed; t is the time variable; and a is the scaling factor.
[0172] 3. Calculate the amplitude and introduce a small constant to avoid singularities:
[0173] .
[0174] In the formula, For very small positive numbers, such as This is to prevent singular values from occurring in subsequent logarithmic operations when the modulus is 0.
[0175] 4. Convert to dB unit time-frequency energy spectrum:
[0176] .
[0177] In the formula, E(a,t) is the time-frequency energy spectrum in decibels (dB).
[0178] 5. Construct time and frequency axes, and sort them to form a time-frequency energy distribution map.
[0179] In some embodiments, VMD is introduced to optimize the noise classifier for noise localization. The technical approach is as follows:
[0180] B1. Perform Variational Mode Decomposition (VMD) on the initial magnetotelluric data to be denoised, extract low-frequency strips, and construct an envelope of equal width that is highly consistent with the main trend of the initial magnetotelluric data, including an upper envelope and a lower envelope.
[0181] Among them, by reconstructing the low-frequency IMF, the trend envelope of the signal can be constructed. This envelope can fully characterize the normal fluctuation range of the signal and provide a constraint benchmark for the geometric boundary of noise.
[0182] B2. Based on the noise edge boundary determined by the current noise mask, move the low-frequency stripe of the interval corresponding to every two adjacent noise edge boundaries. The moving distance is determined according to the signal amplitude corresponding to the noise edge boundary.
[0183] B3. Based on the signal coverage of the low-frequency strip in the corresponding interval after the shift, perform adaptive expansion of the noise interval to achieve complete noise masking.
[0184] If the signal coverage exceeds a preset threshold, the entire range is considered a noise region, and the noise mask is completed to update the noise mask. If the coverage does not exceed the preset threshold, the noise edge is considered a discrete noise point and is not expanded, remaining unchanged.
[0185] This invention employs a dual strategy of "geometric constraint-morphological recognition" based on VMD envelopes to complete the mid-region of square waves missed by TimeDART and time-frequency analysis. This strategy introduces geometric and morphological priors from a structural domain perspective, overcoming the limitations of time-domain and time-frequency domain models and achieving complete identification of complex structured noise. This step constructs an efficient processing framework of "outlier screening-trend envelope construction-noise region optimization" for the precisely located noise region mask. This framework aims to output a highly complete and accurate optimized noise mask.
[0186] The specific process of noise identification and denoising in magnetotelluric data is as follows: Figure 3 As shown, in conjunction with see Figure 4 The specific performance of magnetotelluric data in the noise identification process. Figure 4 In (a), the blue dashed line represents the noise boundary identified by the TimeDART diffusion model in the time domain, and the orange dashed line represents the noise boundary identified by CWT in the time-frequency domain; performing a logical AND operation on the two types of boundaries yields... Figure 4 The refined noise boundary is shown in green shading in (b). The above operations have not yet achieved complete extraction of continuous noise regions and cannot be directly used as information reference for noise reduction. Long-term time-series signals often contain multiple discrete noise boundaries and isolated noise points, making it difficult to directly determine the corresponding pairing relationships between boundaries and thus impossible to directly connect noise regions. Therefore, based on the already obtained accurate noise boundaries, the ability of VMD to extract the signal baseline is used to obtain the following: Figure 4 The original signal baseline, shown by the gray dashed line in (c), is used to construct the baseline strip, which is the blue shaded area in the figure. Combining the structural domain characteristics of continuous noise, precise intervals of continuous noise with significant structural domain characteristics are identified through strip translation and coverage comparison. Simultaneously, the discrete noise boundary is expanded to obtain the final result. Figure 4 The complete noise range shown in (d) provides accurate information for subsequent noise reduction.
[0187] Example 2
[0188] The present invention also discloses a magnetotelluric signal denoising system based on a time-frequency joint and self-supervised diffusion model to implement the above method, including a data preprocessing module, a TimeDART diffusion module and a sequence splicing module.
[0189] The data preprocessing module segments the magnetotelluric (MT) sequence temporally. The TimeDART diffusion module incorporates a TimeDART diffusion model, inputting the segmented MT sequences into this model for training and denoising. The TimeDART diffusion model includes a noise classifier and a diffusion denoiser. The noise classifier outputs a noise mask and deep semantic features, which serve as the key features K and value features V of the cross-attention submodule in the decoder of the diffusion denoiser. The diffusion denoiser contains at least a diffusion noise layer and a decoder. The diffusion noise layer obtains a clean mask by inverting the noise mask, then forward-noises the MT sequences corresponding to the clean mask region, resulting in a noisy sequence. The target noise sequence is obtained based on the MT sequences of the target noise region corresponding to the noise mask. Both the noisy sequence and the target noise sequence are then input into the decoder for self-supervised training of the diffusion denoiser model. The sequence splicing module uses the denoised signal of the target noise region obtained from the trained TimeDART diffusion model and splices it sequentially with the MT sequences of the clean region to obtain the denoised MT signal.
[0190] The present invention also discloses a computer device, including one or more processors; a memory storing one or more computer programs; wherein the processor calls the computer programs to implement the steps of the magnetotelluric signal denoising method of the self-supervised diffusion model described above in the present invention.
[0191] The computer device can be a server or a terminal. It includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores brainwave music generation data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for enhancing the micro-defects on a metal surface. The processors involved in the various embodiments provided by this invention can be general-purpose processors, central processing units, graphics processors, digital signal processors, programmable logic controllers, data processing logic units, etc., and are not limited to these.
[0192] It should be noted that the data involved in this invention (including but not limited to data used for analysis, data stored, data displayed, etc.) are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with relevant regulations.
[0193] The present invention also discloses a computer-readable storage medium storing a computer program, which is called by a processor to implement the steps of the magnetotelluric signal denoising method of the self-supervised diffusion model described above.
[0194] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided by this invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0195] The following section uses magnetotelluric data measured at a certain measuring point to construct simulation data for model training and noise reduction analysis. The specific process is as follows:
[0196] To further verify the denoising effect of the model, the experiment systematically processed the noisy dataset. The computer hardware environment for executing the algorithm in this embodiment was: CPU ≥ 8 cores, GPU ≥ 1 (with ≥ 16GB of VRAM), and RAM ≥ 32GB. The software environment consisted of: Windows 10 / 11 or Linux (Ubuntu 18.04 and above), Python version ≥ 3.8, and dependencies including numpy, pytorch ≥ 1.10, scipy, matplotlib, pywt (wavelet transform library), and vmdpy (VMD decomposition library); development tools were VS Code (Visual Studio Code) with a Python interpreter, or Anaconda's Spyder (with pre-installed core dependencies).
[0197] Figure 5 This paper presents a comparison between the original and noisy signals in a magnetotelluric (MT) dataset, clearly demonstrating the diverse types of noise, including impulse noise, square wave noise, and Gaussian noise. To address these complex noise scenarios, this paper performs denoising processing on multiple datasets and evaluates the processing effectiveness of the MT signals by calculating the apparent resistivity and phase curves.
[0198] Figure 6 The comparison results before and after denoising are presented over the entire time range, where the blue line represents the original magnetotelluric data signal and the orange line represents the denoised signal. Overall, the denoised signals are restored to near the baseline of the original magnetotelluric data, indicating that noise was effectively suppressed. Figure 7 for Figure 6 The magnified view clearly shows the removal of various types of noise: impulse noise, square wave noise, and Gaussian noise have all been effectively eliminated. The reconstructed magnetotelluric data signal is smoother overall, meeting the quality requirements of high signal-to-noise ratio.
[0199] Figures 8a to 8d The apparent resistivity and phase curves of the measurement point under noisy conditions are compared with those after TimeDART denoising. The curves of the noisy signal are extremely messy, making it difficult to extract useful information; after TimeDART processing, the apparent resistivity and phase curves in both the xy and yx directions tend to be smooth, with regular curve shapes and good continuity. This indicates that the present invention can effectively eliminate human noise of various intensities and properties in MT signals without introducing new noise interference, and the processing results are reliable.
[0200] In summary, this method not only effectively preserves the effective low-frequency signal during the denoising process, but also recovers the main characteristics of the signal well, resulting in a significant improvement in signal quality.
[0201] The above embodiments are merely illustrative examples to clearly illustrate the present invention and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all embodiments here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. A method for denoising magnetotelluric signals using a self-supervised diffusion model, characterized in that, Includes the following steps: S1. Data preprocessing: Time-series segmentation of the magnetotelluric sequence; S2, TimeDART diffusion model processing: The segmented magnetotelluric sequence is input into the TimeDART diffusion model for model training and noise reduction. The TimeDART diffusion model includes a noise classifier and a diffusion denoiser. The noise classifier outputs a noise mask and deep semantic features. The deep semantic features serve as the key feature K and value feature V of the cross-attention submodule of the decoder in the diffusion denoiser. The diffusion denoising device includes at least a diffusion noise-adding layer and a decoder. The diffusion noise-adding layer is based on obtaining a clean mask by inverting the noise mask, and then forward-adding noise to the magnetotelluric sequence of the region corresponding to the clean mask to obtain a noise-adding sequence. Based on the magnetotelluric sequence of the target noise region corresponding to the noise mask, a target noise sequence is obtained. Then, both the noise-adding sequence and the target noise sequence are input into the decoder for self-supervised training of the diffusion denoising device model. S3. Using the trained TimeDART diffusion model, the denoised signal of the target noise area is obtained, and then sequentially spliced with the magnetotelluric sequence of the clean area.
2. The method according to claim 1, characterized in that: The decoder is a deep network composed of stacked multi-layer denoising patch decoding blocks. Each decoding block contains a mask self-attention submodule, a cross-attention submodule, and a feedforward network. Each submodule is followed by a residual connection layer and a layer normalization layer. The mathematical model of the cross-attention submodule is as follows: ; Where Q represents the output from the mask self-attention submodule in the current layer of the decoding block, that is, the query feature after the noisy patch sequence / target noise patch sequence has undergone self-attention processing; K is the dimension of the feature, and T is the matrix transpose symbol. This is the output of the cross-attention submodule.
3. The method according to claim 1, characterized in that: The process of the diffusion noise-adding layer forward-noising the magnetotelluric sequence of the region corresponding to the clean mask to obtain the noisy sequence is represented as follows: ; in, This is the magnetotelluric sequence for the region corresponding to the clean mask. Let t be the noisy sequence at time step t. This is normalized Gaussian noise; The signal is preserved as coefficients, and the following conditions are met: ; Where t is the current diffusion time step, T1 is the total number of diffusion steps, and s is the preset minimum offset.
4. The method according to claim 1, characterized in that: The model training process of the diffusion denoiser includes at least noise prediction loss and reconstruction loss in its loss function. The noise prediction loss is, for the noisy sequence, a measure of the error between the predicted noise of the diffusion denoiser model and the actual noise added during the diffusion process. The reconstruction loss includes statistical characteristic consistency loss and boundary smoothing loss for the target noise region; the statistical characteristic consistency loss characterizes the difference between the statistical characteristic distribution of the target noise region and the statistical characteristic distribution of the clean region; the boundary smoothing loss characterizes the smoothness of the boundary transition between the target noise region and the clean region.
5. The method according to claim 1, characterized in that: The noise classifier adopts an encoder architecture based on the TimeDART network, which includes a series of modules connected in sequence, such as a channel independent processing module, a patch segmentation module, an embedding layer, a position encoding layer, a Transformer encoder, and a projection head. The input magnetotelluric sequence is multi-channel data, and the independent channel processing module performs dimensional transformation to process the magnetotelluric data of different channels independently. The positional encoding layer uses cosine positional encoding and is designed for parity of the encoding dimension index.
6. The method according to claim 1, characterized in that: The method further includes: introducing time-frequency analysis to optimize noise localization of the noise mask in the noise classifier, specifically: A1. Extract the narrow bright band interval of the initial magnetotelluric data to be denoised in the time-frequency spectrum through time-frequency analysis, and obtain the first marker mask corresponding to the narrow bright band interval; A2. Perform a logical AND operation between the first marker mask and the binarized noise mask to update the noise edge boundary.
7. The method according to claim 1, characterized in that: The method further includes: introducing noise localization of the noise mask in the VMD-optimized noise classifier, specifically: B1. Perform variational mode decomposition (VMD) on the initial magnetotelluric data to be denoised, and extract low-frequency strips, thus constructing an envelope of equal width strips that is highly consistent with the main trend of the initial magnetotelluric data. B2. Based on the noise edge boundary determined by the current noise mask, move the low-frequency strips of the interval corresponding to every two adjacent noise edge boundaries. The moving distance is determined according to the signal amplitude corresponding to the noise edge boundary. B3. Based on the signal coverage of the low-frequency strip in the corresponding interval after the shift, perform adaptive expansion of the noise interval to achieve complete noise mask. If the signal coverage exceeds a preset threshold, the entire range is considered a noise region, and the noise mask is completed to update the noise mask. If the coverage does not exceed the preset threshold, the noise edge is considered a discrete noise point and is not expanded, remaining unchanged.
8. A system based on the method of any one of claims 1-7, characterized in that: include: The data preprocessing module performs time-series segmentation of the magnetotelluric sequence; The TimeDART diffusion module incorporates a built-in TimeDART diffusion model. Segmented magnetotelluric sequences are input into the TimeDART diffusion model for model training and denoising. The TimeDART diffusion model includes a noise classifier and a diffusion denoising module. The noise classifier outputs a noise mask and deep semantic features. The deep semantic features serve as the key feature K and value feature V of the cross-attention submodule in the decoder of the diffusion denoising module. The diffusion denoising module includes at least a diffusion noise layer and a decoder. The diffusion noise layer obtains a clean mask by inverting the noise mask, then forward-noises the magnetotelluric sequence corresponding to the clean mask region to obtain a noisy sequence. A target noise sequence is obtained based on the magnetotelluric sequence of the target noise region corresponding to the noise mask. Both the noisy sequence and the target noise sequence are then input into the decoder for self-supervised training of the diffusion denoising module model. The sequence splicing module uses the trained TimeDART diffusion model to obtain the denoised signal of the target noise region, and splices it sequentially with the magnetotelluric sequence of the clean region to obtain the denoised magnetotelluric signal.
9. A computer device, characterized in that: include: One or more processors; A memory that stores one or more computer programs; The processor invokes a computer program to achieve the following: The steps of the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer program is stored and is invoked by the processor to implement: The steps of the method according to any one of claims 1-7.