A method for electrical impedance cancer detection based on self-attention mechanism
The self-attention mechanism in electric impedance imaging improves cancer detection accuracy by integrating frequency and time domain features, addressing inefficiencies in existing methods and enhancing classification precision.
Patent Information
- Application Number
- CN202510471573.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2045-04-15
AI Technical Summary
The existing electrical impedance signal analysis methods have shortcomings in signal processing efficiency, feature extraction accuracy and classification accuracy, and cannot fully utilize the frequency and time domain characteristics, affecting the sensitivity and specificity of cancer detection.
The electrical impedance cancer detection method based on the self-attention mechanism is adopted, through the combination of frequency domain network and time domain model, the frequency domain characteristics and high-dimensional features are fusion, combined with the self-attention mechanism to enhance the feature, and finally the full connection layer and the classified output layer are introduced for cancer risk prediction.
It significantly improves the accuracy and reliability of cancer detection. By removing noise and interference, accurately capturing spectrum characteristics and periodic characteristics, dynamically adjusting feature weights, and improving classification performance.
Smart Images

Figure CN119969996B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cancer detection, and particularly to an impedance cancer detection method based on a self-attention mechanism. Background Art
[0002] Electrical impedance tomography (EIT) is a non-invasive and biocompatible medical detection technology that indirectly reflects the physical and physiological characteristics of biological tissues by measuring the impedance characteristics of human tissues to externally applied weak currents. In clinical applications, EIT is widely used in early cancer detection, lung health monitoring, breast disease screening, etc. However, existing methods for analyzing electrical impedance signals face many challenges in terms of signal processing efficiency, feature extraction accuracy, and classification accuracy, which restrict the further development of the technology.
[0003] To solve the above problems, there is an urgent need to develop an innovative network structure that combines the advantages of frequency-domain and time-domain feature extraction, and design an efficient signal preprocessing and feature fusion mechanism. By adopting advanced deep learning technologies, such as self-attention mechanisms and multi-scale feature fusion methods, the sensitivity and specificity of cancer detection can be significantly improved.
[0004] In the prior art, Chinese Patent No. CN112754456A discloses "a three-dimensional electrical impedance tomography system based on deep learning". This method is based on a three-dimensional electrical impedance tomography system for deep learning, which can be used for human breast imaging. Through a certain excitation acquisition method, three-dimensional surface impedance information of a hemispherical measurement area can be obtained. However, this method mainly relies on the impedance information of the three-dimensional surface and cannot fully utilize other types of features.
[0005] Therefore, there is an urgent need to design an impedance cancer detection method based on a self-attention mechanism to solve the problems existing in the above prior art. Summary of the Invention
[0006] In view of the above-mentioned deficiencies or improvement requirements of the prior art, the present invention provides an impedance cancer detection method based on a self-attention mechanism. After obtaining the electrical impedance signal, it is preprocessed to remove noise and interference. The frequency-domain network is used to extract the frequency-domain features of the signal. At the same time, a period decomposition module and frequency-domain enhancement are adopted in the time-domain model to model the time-series features. The self-attention mechanism is used to enhance the fused features, and finally, it is passed into the fully connected layer and the classification output layer, improving the accuracy and reliability of cancer detection.
[0007] To achieve the above object, according to one aspect of the present invention, there is provided an impedance cancer detection method based on a self-attention mechanism, the method comprising the following steps:
[0008] S1: Obtain the impedance signal and send it to the input layer for preprocessing to remove noise and interference. The preprocessing includes denoising, detrending, and normalization processing;
[0009] S2: Divide the preprocessed signal into two branches. The first branch is input into the frequency-domain network to extract the frequency-domain features of the signal, and the second branch is input into the time-domain model to extract the high-dimensional features of the signal. The frequency-domain network includes Fourier transform, convolutional layer, and pooling layer. The time-domain model includes a period decomposition module, convolutional operation, and global convolutional layer;
[0010] S3: Input the frequency-domain features extracted by the frequency-domain network and the high-dimensional features extracted by the time-domain model into the feature fusion layer for fusion to obtain the fused features;
[0011] S4: Use the self-attention mechanism to process the fused features, and finally input them into the fully connected layer and the classification output layer for cancer risk prediction, and output the detection result.
[0012] As an embodiment of the present application, the step S1 specifically includes:
[0013] S11: Collect the original signal through a specific device, and the sampling frequency is ;
[0014] S12: Use a low-pass filter to eliminate high-frequency noise. The formula is as follows:
[0015]
[0016]
[0017] Wherein, is the frequency response function of the filter, is the sampling frequency, is the cut-off frequency of the filter, is the filtered signal, is the original impedance signal, is the impulse response function of the filter, represents the convolution operation;
[0018] S13: Perform detrending processing after signal denoising, and remove the low-frequency trend component in the signal through moving average. The formula is as follows:
[0019]
[0020] Wherein, is the filtered signal, is the moving window length, is the signal at the time point value, is the detrended signal;
[0021] S14: Then perform signal normalization to adjust the numerical range of the signal to a unified standard interval [0, 1]. The formula is as follows:
[0022]
[0023] where, is the detrended signal, is the signal the minimum value in, is the signal the maximum value in, is the normalized signal, and its range is scaled to [0, 1].
[0024] As an embodiment of the present application, the specific steps for the first branch in step S2 to input into the frequency domain network to extract the frequency domain features of the signal include:
[0025] S211: First, convert the preprocessed time domain signal to the frequency domain through the discrete Fourier transform. The Fourier transform formula is as follows:
[0026]
[0027] where, is the preprocessed time domain signal, is the frequency domain signal, that is, the amplitude of each frequency point is the number of sampling points of the signal, is the imaginary unit;
[0028] S212: Then, convert the obtained frequency domain signal to a spectrogram, and extract features from the spectrogram through a convolutional layer. The convolutional layer learns the local frequency features of the signal through the convolution kernel. The formula for the convolution operation is as follows:
[0029]
[0030]
[0031] where, is the convolution kernel, used to extract the local features of the spectrogram, is the bias term, controlling the offset of the convolution output, is the input frequency domain signal, represents the convolution operation, is the frequency domain feature output by the convolutional layer, represents the activation function, used to introduce non-linearity and improve the representation ability of the network, represents the input vector;
[0032] S213: Secondly, the frequency-domain features output by the convolutional layer are further processed by the pooling layer using max pooling. The pooling operation is used to reduce the size of the feature map, thereby reducing the computational amount and preventing overfitting. The pooling formula is:
[0033]
[0034] where, is the frequency-domain feature output by the convolutional layer, is the starting position of the pooling window, is the size of the pooling window, is the frequency-domain feature after pooling;
[0035] S214: Perform multiple stacks of the convolutional layer and the pooling layer, and finally the output frequency-domain feature is , and its calculation formula is:
[0036]
[0037] where, is the finally output frequency-domain feature, represents the frequency-domain feature after times of stacking.
[0038] As an embodiment of the present application, the specific steps of extracting the high-dimensional features of the signal by inputting the second branch in step S2 into the time-domain model include:
[0039] S221: Decompose the input time-domain signal into multiple periodic components through the period decomposition module, and decompose it into multiple periodic components based on frequency, amplitude, and phase. The decomposition formula is as follows:
[0040]
[0041] where, is the original time-domain signal, is the amplitude of the th periodic component, is the frequency of the th periodic component, is the phase of the th periodic component, represents that the signal is decomposed into periodic components, and the periodic information in the signal is extracted;
[0042] S222: After time-domain decomposition, convolution operation is used in combination with frequency-domain enhancement to extract local frequency-domain features. The local frequency-domain features are used to help capture the frequency features at different time points in the signal and are enhanced through the convolution layer. The convolution operation formula is as follows:
[0043]
[0044] Among them, is the local frequency-domain feature, representing the frequency-domain feature extracted through the convolution layer, represents the weight used to extract the frequency-domain information, is the input signal, is the bias term, used to control the offset of the convolution layer output, represents the convolution operation, The activation function is used to introduce non-linearity, thereby improving the representation ability of the network;
[0045] S223: Combine all periodic features through the global convolution layer to form global features, so as to better capture the overall features of the signal. The global enhancement feature modeling formula is as follows:
[0046]
[0047] Among them, represents the output after combining all local frequency-domain features through the global convolution layer, represents the th weight of the periodic feature, is the th periodic feature, representing the feature extracted through local frequency-domain convolution. Each periodic feature is weighted and combined through the global convolution layer to generate the global frequency-domain feature ;
[0048] S224: The local frequency-domain feature and the global frequency-domain feature are combined together as the output of the network. The feature output formula is as follows:
[0049]
[0050] Among them, represents the final output feature combined with the local frequency-domain feature and the global frequency-domain feature . The finally output feature is a high-dimensional feature, containing the local and global information of the signal.
[0051] As an embodiment of the present application, the step S3 specifically includes:
[0052] S31: Align the frequency-domain features output by the frequency-domain network and the high-dimensional features output by the time-domain model for feature alignment, and convert the frequency-domain features and the high-dimensional features to the same dimension , where , is the batch size, is the frequency-domain feature dimension, , is the time-domain feature dimension. Through the linear transformation formula:
[0053]
[0054] where , , , , represents the features after linear transformation;
[0055] S32: Feed the features and after linear transformation into the feature fusion layer, and perform weighted summation on the two through the feature fusion method of feature weighted summation to assign weights and to each branch. The calculation formula is as follows:
[0056]
[0057] where and , represents the features after fusion.
[0058] As an embodiment of the present application, the step S4 specifically includes:
[0059] S41: Process the features after fusion through the self-attention mechanism to obtain enhanced features;
[0060] S42: Generate global features by aggregating or selecting the enhanced features;
[0061] S43: Input the generated global features into the fully connected layer and the classification output layer to obtain the final detection result.
[0062] As an embodiment of the present application, the step S41 specifically includes:
[0063] S411: Add positional encoding to the features after fusion to inject sequence information. The positional encoding formula is as follows:
[0064]
[0065]
[0066] Among them, is the position index of the sequence, is the feature dimension index, represents the dimension of the position vector, and the position encoding is added to the feature after fusion The formula is as follows:
[0067]
[0068] Among them, represents the feature after fusion, represents the position encoding information, represents the output feature;
[0069] S412: Capture the correlations at different positions in the sequence through the multi-head self-attention mechanism, and generate through linear transformation. The formula is as follows:
[0070]
[0071] Among them, is the scientific system parameter, represents the query, represents the key, represents the value, represents the feature output by step S411;
[0072] S413: Calculate the attention weights using scaled dot-product attention. The formula is as follows:
[0073]
[0074] Among them, represents the correlation at each position in the sequence, is the scaling factor;
[0075] S414: Concatenate the outputs of attention heads and perform a transformation through a linear layer. The formula is as follows:
[0076]
[0077] Among them, , is the output weight matrix, represents the output of the attention calculation;
[0078] S415: Non-linearly transform the feature at each position through a feed-forward neural network. The formula is as follows:
[0079]
[0080] Among them, , is the weight matrix, , are the bias terms, is a two-layer fully connected network;
[0081] S416: Use residual connection and normalization to stabilize training. The residual connection formula is as follows:
[0082]
[0083]
[0084] Among them, is the input feature, represents the output of the attention mechanism, is layer normalization, which normalizes the features at each time step so that its mean is 0 and the standard deviation is 1. , represent the results after residual connection and normalization. The final output feature formula is as follows:
[0085]
[0086] Among them, is the final output feature, representing the sequence feature, represents the batch size, represents the sequence length, represents the feature dimension.
[0087] As an embodiment of the present application, the step S42 specifically includes:
[0088] S421: Aggregate or select the output features of the previous step to generate a global feature representation, and perform global average pooling on it. The formula is as follows:
[0089]
[0090] Among them, is the final output feature, with a shape of , represents the sequence dimension, is the generated global feature;
[0091] S422: Take the maximum value of the sequence dimension . The formula is as follows:
[0092]
[0093] Among them, represents the maximum value of the aggregation feature in the th feature dimension, represents the maximum value operation, taking the maximum value for each feature dimension in time steps;
[0094] S423: Then perform attention pooling, and its formula is as follows:
[0095]
[0096]
[0097] Among them, the weight represents the importance of the th time step, is a learnable parameter, and its shape is consistent with the feature dimension. , assigns weights to each time step through a linear transformation.
[0098] As an embodiment of the present application, the step S43 specifically includes:
[0099] S431: Input the generated global feature into the fully connected layer for non-linear mapping:
[0100] The formula of the first fully connected layer is as follows:
[0101]
[0102] Among them, , , is the dimension of the hidden layer;
[0103] The formula of the second fully connected layer is as follows:
[0104]
[0105] Among them, , , is the feature dimension of the classification output;
[0106] S432: Use a linear classifier to process the output features of the second fully connected layer, and its formula is as follows:
[0107]
[0108] Among them, is the output feature of the second fully connected layer, is the classifier weight matrix, is the bias term, is the original output of the classifier;
[0109] S433: The final classification output layer uses a function to map the features to a categorical probability distribution, and its formula is as follows:
[0110]
[0111] where, is the probability that the sample belongs to category , is the score of the sample for category , represents the index of the category, is the exponential function used to map the score to a positive value.
[0112] The beneficial effects of the present invention are as follows:
[0113] (1) After obtaining the impedance signal, the present invention preprocesses it to remove noise and interference, extracts the frequency-domain features of the signal using a frequency-domain network, and at the same time extracts the high-dimensional features of the signal using a time-domain model. The frequency-domain features and high-dimensional features are sent to a feature fusion layer for feature fusion, and then the self-attention mechanism is used to enhance the features of the fused features. Finally, they are fed into a fully connected layer and a classification output layer to further improve the accuracy and reliability of cancer detection.
[0114] (2) By using a low-pass filter to remove high-frequency noise, the present invention effectively removes environmental interference and equipment noise, makes the signal smoother and more stable, and combines detrending processing to eliminate baseline drift, avoiding interference with feature extraction caused by long-term drift, thereby retaining key change information within a short time, greatly improving the quality and stability of the signal, providing a reliable data basis for subsequent feature extraction, standardizing the signal range through normalization operations, avoiding the impact of different signal amplitude differences on the model performance, ensuring the quality of the signal and the extraction efficiency of features, and improving the adaptability of the system.
[0115] (3) In the frequency-domain network, the present invention first converts the preprocessed time-domain signal into a frequency-domain signal, effectively extracts local frequency patterns from the frequency-domain signal, can effectively capture the spectral characteristics of the impedance signal, reveal its energy distribution and characteristic patterns in different frequency bands, and uses the feature learning ability of the convolutional layer to capture important frequency features related to classification. At the same time, through the max-pooling layer, the feature map is compressed to retain key information, reduce redundant data, reduce computational complexity and prevent overfitting, thereby extracting more refined and efficient frequency-domain features, providing a more accurate input for subsequent feature fusion and classification, helping the model to more efficiently capture frequency features related to cancer detection, and improving the feature expression ability and classification performance;
[0116] (4) In the time-domain model of the present invention, the time-domain signal is first decomposed into multiple periodic components based on frequency, amplitude, and phase through a periodic decomposition module, which can effectively extract the periodic features in the signal. Combining local frequency-domain enhancement to capture the complex dynamic changes in the timing features, helping the model capture the frequency features at different time points, and enhancing these local features through a convolutional layer to improve the signal representation ability. Then, through the global convolutional layer, the local features are further weighted and combined to generate global features, thereby ensuring the capture of the overall features of the signal. Finally, through the fusion of local and global features, the generated high-dimensional features can provide a more comprehensive signal representation, enhancing the ability to identify signal features in subsequent classification tasks and improving the classification performance.
[0117] (5) The present invention dynamically adjusts the weight distribution of frequency-domain and time-domain features through a self-attention mechanism to achieve feature complementarity and enhancement, significantly improving the quality of the input features of the classifier. The self-attention mechanism combines with the module depth modeling to accurately distinguish cancer and non-cancer signals, ensuring high accuracy and high sensitivity in classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0118] Figure 1 It is a schematic flow chart of a method for impedance cancer detection based on a self-attention mechanism provided in an embodiment of the present invention;
[0119] Figure 2 It is a schematic diagram of the overall framework structure of a method for impedance cancer detection based on a self-attention mechanism provided in an embodiment of the present invention;
[0120] Figure 3 It is a schematic diagram of the self-attention mechanism model of a method for impedance cancer detection based on a self-attention mechanism provided in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0121] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0122] It should be noted that all directional indications (such as up, down, left, right, front, back...) in the embodiments of the present invention are only used to explain the relative positional relationship and movement conditions between components in a specific posture (as shown in the drawings). If the specific posture changes, the directional indications will also change accordingly.
[0123] In the present invention, unless otherwise clearly specified or limited, terms such as "connection" and "fixation" shall be understood in a broad sense. For example, "fixation" can be a fixed connection, a detachable connection, or integrated; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and it can be the communication inside two components or the interaction relationship between two components, unless otherwise clearly limited. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific situations.
[0124] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one such feature. In addition, the meaning of "and / or" appearing throughout the text includes three parallel solutions. Taking "A and / or B" as an example, it includes solution A, solution B, or the solution where A and B are satisfied simultaneously. In addition, the technical solutions between various embodiments can be combined with each other, but it must be based on the ability of those of ordinary skill in the art to implement. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0125] Referring to Figures 1-3 , the first aspect of the present invention provides a method for impedance cancer detection based on the self-attention mechanism, and the method includes the following steps:
[0126] S1: Obtain the impedance signal and send it to the input layer for preprocessing to remove noise and interference. The preprocessing includes denoising, detrending, and normalization processing;
[0127] S2: Divide the preprocessed signal into two branches. The first branch is input into the frequency-domain network to extract the frequency-domain features of the signal, and the second branch is input into the time-domain model to extract the high-dimensional features of the signal. The frequency-domain network includes Fourier transform, convolutional layer, and pooling layer, and the time-domain model includes a period decomposition module, convolutional operation, and global convolutional layer;
[0128] S3: Input the frequency-domain features extracted by the frequency-domain network and the high-dimensional features extracted by the time-domain model into the feature fusion layer for fusion to obtain the fused features;
[0129] S4: Use the self-attention mechanism to process the fused features, and finally input them into the fully connected layer and the classification output layer for cancer risk prediction to output the detection result.
[0130] Specifically, by acquiring impedance signals and preprocessing them in the input layer, the present invention can effectively remove noise, interference, and trend non-target signals, ensuring the stability of the input signal quality and laying a foundation for subsequent feature extraction. By designing a frequency-domain network to extract frequency-domain features, the spectral characteristics of the signal can be accurately captured, revealing the energy distribution and patterns in key frequency bands, while reducing data redundancy and retaining the core feature representation. By designing a time-domain model to extract high-dimensional features, the potential periodic patterns and local change features in time-series data can be further explored, enhancing the global representation ability. Then, the frequency-domain features and time-series features are fused to obtain the fused features. Finally, through the self-attention mechanism, the fused features are accurately modeled and weighted, maximizing the representation ability of key features, and combining with the fully connected layer and the classification output layer to achieve efficient cancer detection, significantly improving the diagnostic accuracy and reliability.
[0131] As an embodiment of the present application, step S1 specifically includes:
[0132] S11: Acquire the original signal through a specific device, and the sampling frequency is ;
[0133] S12: Use a low-pass filter to eliminate high-frequency noise, and the formula is as follows:
[0134]
[0135]
[0136] Wherein, is the frequency response function of the filter, is the sampling frequency, is the cut-off frequency of the filter, which sets the maximum frequency allowed to pass through the filter, is the filtered signal obtained through convolution, is the original impedance signal, is the impulse response function of the filter, represents the convolution operation;
[0137] S13: After signal denoising, perform detrending processing, and remove the low-frequency trend component in the signal through moving average, and the formula is as follows:
[0138]
[0139] Wherein, is the filtered signal, is the length of the moving window, is the signal at the time point value, is the detrended signal;
[0140] S14: Then perform signal normalization to adjust the numerical range of the signal to a unified standard interval [0, 1]. The formula is as follows:
[0141]
[0142] where, is the detrended signal, is the signal the minimum value in, is the signal the maximum value in, is the normalized signal, whose range is scaled to [0, 1]. After normalization, each data point of the signal is within the interval [0, 1], which helps to unify the amplitude range of the signal.
[0143] Specifically, the present invention can eliminate high-frequency noise through a low-pass filter, effectively remove environmental interference and equipment noise, making the signal smoother and more stable; then through detrending processing, the low-frequency trend components in the signal are removed by moving average, avoiding the interference of long-term drift on feature extraction, so as to retain the key change information within a short time; then signal normalization unifies the data to the standardized range [0, 1], eliminates the dimension difference, improves the comparability of different features, and provides consistent input data for subsequent model processing. These preprocessing operations together ensure the quality of the signal and the extraction efficiency of features, and are the key basic steps of the entire detection process.
[0144] As an embodiment of the present application, the specific steps for the first branch input in step S2 to extract the frequency-domain features of the signal into the frequency-domain network include:
[0145] S211: First, convert the preprocessed time-domain signal to the frequency domain through discrete Fourier transform. The Fourier transform formula is as follows:
[0146]
[0147] where, is the preprocessed time-domain signal, is the frequency-domain signal, that is, the amplitude of each frequency point , is the number of sampling points of the signal, is the imaginary unit; through a transformation, the time-domain signal is converted into the frequency-domain signal , and these frequency-domain features represent the intensity of the signal at different frequencies. The frequency-domain representation can help the model identify the frequency features related to target classification.
[0148] Specifically, the present invention converts the preprocessed time-domain signal into a frequency-domain signal, which can reveal the energy distribution and characteristics of the signal at different frequencies. The frequency-domain features can effectively separate specific frequency components that contribute significantly to target classification, while suppressing the interference of irrelevant frequency components to the model. This frequency-domain representation provides a more targeted input for the subsequent feature extraction network, helping the model to more efficiently capture the frequency features related to cancer detection and enhancing the feature expression ability and classification performance.
[0149] S212: Then, the obtained frequency-domain signal is converted into a spectrogram, and feature extraction is performed through a convolutional network, which includes a convolutional layer and a pooling layer; the convolutional layer extracts features from the spectrogram. The convolutional layer learns the local frequency features of the signal through a convolutional kernel. The formula for the convolutional operation is as follows:
[0150]
[0151]
[0152] Where is the convolutional kernel, which is used to extract the local features of the spectrogram, is the bias term, which controls the offset of the convolutional output, is the input frequency-domain signal, represents the convolutional operation, is the frequency-domain feature output by the convolutional layer, represents the activation function, which is used to introduce non-linearity and improve the representation ability of the network, represents the input vector. Specifically, the function ensures that negative values are masked while keeping positive values unchanged, which helps the gradient propagation during the training process.
[0153] S213: Secondly, after the convolutional operation extracts the frequency-domain features, the frequency-domain features output by the convolutional layer are further processed through the pooling layer using max pooling. The pooling operation is used to reduce the size of the feature map, thereby reducing the computational amount and preventing overfitting. The pooling formula is:
[0154]
[0155] Where is the frequency-domain feature output by the convolutional layer, is the starting position of the pooling window, is the size of the pooling window, is the frequency-domain feature after pooling;
[0156] S214: In order to extract more complex and advanced features, the convolutional layer and the pooling layer are stacked multiple times, and the final output frequency-domain feature is , and its calculation formula is:
[0157]
[0158] Wherein, is the finally output frequency-domain feature, represents the frequency-domain feature after times of stacking.
[0159] Specifically, the present invention can effectively extract local frequency patterns from frequency-domain signals, capture important frequency features related to classification by using the feature learning ability of the convolutional layer, and at the same time compress the feature map through the max-pooling layer, retain key information, reduce redundant data, reduce computational complexity and prevent overfitting, so as to extract more refined and efficient frequency-domain features, providing a more accurate input for subsequent feature fusion and classification.
[0160] As an embodiment of the present application, the specific process of the second branch inputting into the time-domain model in step S2 to extract high-dimensional features of the signal includes:
[0161] S221: Decompose the input time-domain signal into multiple periodic components through a period decomposition module, and decompose it into multiple periodic components based on frequency, amplitude and phase. The decomposition formula is as follows:
[0162]
[0163] Wherein, is the original time-domain signal, is the amplitude of the th periodic component, is the frequency of the th periodic component, is the phase of the th periodic component, represents that the signal is decomposed into periodic components, and the periodic information in the signal is extracted;
[0164] Specifically, by decomposing the time-domain signal into multiple periodic components based on frequency, amplitude and phase, the present invention can effectively extract the periodic features in the signal. This decomposition method can more intuitively capture the periodic structure and dynamic change features in the signal, help to enhance the model's understanding ability of complex time series data, and at the same time provide a more accurate periodic feature representation for subsequent feature modeling and classification, improving the accuracy and robustness of classification.
[0165] S222: After time-domain decomposition, convolution operation is used in combination with frequency-domain enhancement to extract local frequency-domain features, which are used to help capture the frequency features at different time points in the signal and are enhanced through the convolutional layer. The convolution operation formula is as follows:
[0166]
[0167] Among them, is the local frequency-domain feature, representing the frequency-domain feature extracted through the convolutional layer, represents the weight used to extract the frequency-domain information, is the input signal, is the bias term, used to control the offset of the output of the convolutional layer, represents the convolution operation, The activation function is used to introduce non-linearity, thereby improving the representation ability of the network;
[0168] S223: After local frequency-domain feature extraction, all periodic features are combined through the global convolutional layer to form global frequency-domain features, so as to better capture the overall features of the signal. The global enhancement feature modeling formula is as follows:
[0169]
[0170] Among them, represents the output after combining all local frequency-domain features through the global convolutional layer, represents the weight of the th periodic feature, is the th periodic feature, representing the feature extracted through local frequency-domain convolution. Each periodic feature is weighted and combined through the global convolutional layer to generate the global frequency-domain feature ;
[0171] S224: After local feature extraction and global enhancement, the local frequency-domain feature and the global frequency-domain feature are combined together as the output of the network. The feature output formula is as follows:
[0172]
[0173] Among them, represents the final output feature that combines the local frequency-domain feature and the global frequency-domain feature . The finally output feature is a high-dimensional feature, containing the local and global information of the signal.
[0174] Specifically, the present invention decomposes the time-domain signal into multiple periodic components based on frequency, amplitude, and phase through a period decomposition module, which can effectively extract the periodic features in the signal; uses convolution operations combined with frequency-domain enhancement to extract the local frequency-domain features in the signal, helps the model capture the frequency features at different time points, and enhances these local frequency-domain features through the convolutional layer to improve the representation ability of the signal; the global convolutional layer further combines the local frequency-domain features with weights to generate global frequency-domain features, thereby ensuring the capture of the overall features of the signal; finally, through the fusion of local and global frequency-domain features, the generated high-dimensional features can provide a more comprehensive signal representation, enhance the identification ability of signal features in subsequent classification tasks, and improve the classification performance.
[0175] As an embodiment of the present application, step S3 specifically includes:
[0176] S31: Align the frequency-domain features output by the frequency-domain network and the high-dimensional features output by the time-domain model . Since the feature dimensions of the two branches are different, convert the frequency-domain features and the high-dimensional features to the same dimension , where , is the batch size, is the frequency-domain feature dimension, , is the time-domain feature dimension. Through the linear transformation formula:
[0177]
[0178] where , , , , represent the features after linear transformation;
[0179] S32: Send the features and after linear transformation into the feature fusion layer, and perform weighted summation on the two through the feature fusion method of feature weighted summation to assign weights and to each branch. The calculation formula is as follows:
[0180]
[0181] where and , represents the fused features.
[0182] As an embodiment of the present application, step S4 specifically includes:
[0183] S41: Process the fused features through the self-attention mechanism to obtain enhanced features;
[0184] S42: Generate global features by aggregating or selecting the enhanced features;
[0185] S43: Input the generated global features into the fully connected layer and the classification output layer to obtain the final detection result.
[0186] As Figure 3 shown, as an embodiment of the present application, step S41 specifically includes:
[0187] S411: Add positional encoding to the fused features to inject sequence information. The positional encoding formula is as follows:
[0188]
[0189]
[0190] Wherein, is the position index of the sequence, is the feature dimension index, represents the dimension of the position vector. Add the positional encoding to the fused feature as follows:
[0191]
[0192] Wherein, represents the fused feature, represents the positional encoding information, represents the output feature;
[0193] S412: Capture the correlations at different positions in the sequence through the multi-head self-attention mechanism and generate through linear transformation. The formula is as follows:
[0194]
[0195] Wherein, is the scientific system parameter, represents the query, represents the key, represents the value, represents the feature output by step S411;
[0196] S413: Calculate the attention weights using scaled dot-product attention. The formula is as follows:
[0197]
[0198] Among them, represents the correlation at each position in the sequence, is the scaling factor to prevent the value from being too large;
[0199] S414: Concatenate the outputs of attention heads and transform through a linear layer. The formula is as follows:
[0200]
[0201] Among them, , is the output weight matrix, represents the output of the attention calculation;
[0202] S415: The features at each position are non-linearly transformed through a feed-forward neural network. The formula is as follows:
[0203]
[0204] Among them, , is the weight matrix, , are the bias terms, is a two-layer fully connected network, using function to alleviate the occurrence of overfitting problems;
[0205] S416: After the feed-forward neural network, use residual connection and normalization to stabilize the training. The residual connection formula is as follows:
[0206]
[0207]
[0208] Among them, is the input feature, represents the output of the attention mechanism, is layer normalization, which normalizes the features at each time step so that the mean is 0 and the standard deviation is 1. , represent the results after residual connection and normalization. The final output feature formula is as follows:
[0209]
[0210] Among them, is the final output, representing the sequence features, represents the batch size, represents the sequence length, Indicates the feature dimension.
[0211] Specifically, by introducing positional encoding, the present invention can inject sequence information, retain the temporal characteristics of the input signal, and ensure that the model can process the sequential information of temporal data; the multi-head self-attention mechanism can capture the correlations at different positions in the signal. By calculating the attention weights, the model can dynamically focus on the most important parts of the input signal, thereby improving the accuracy and efficiency of feature learning; after concatenating the outputs of multiple attention heads, the information expression is further optimized through the transformation of the linear layer; then, through the feed-forward neural network for non-linear transformation, the representation ability of the model is improved, enabling it to process complex signal relationships; finally, the residual connection and normalization operations ensure the stability of network training, and the output is used as the input of the fully connected layer and the classification output layer to complete the feature transformation and the final classification task.
[0212] As an embodiment of the present application, the step S42 specifically includes:
[0213] S421: Aggregate or select the output features of the previous step to generate a global feature representation, and perform global average pooling on it. The formula is as follows:
[0214]
[0215] where, is the final output feature, with a shape of , represents the sequence dimension, is the output dimension;
[0216] S422: Take the maximum value of the sequence dimension . The formula is as follows:
[0217]
[0218] where, represents the maximum value of the aggregated feature in the th feature dimension, represents the maximum value operation, taking the maximum value for each feature dimension in the time steps;
[0219] S423: Then perform attention pooling. The formula is as follows:
[0220]
[0221]
[0222] where the weight represents the importance of the th time step, is a learnable parameter, with a shape consistent with the feature dimension, and assigns weights to each time step through a linear transformation.
[0223] Specifically, by aggregating or selecting the output of the self-attention mechanism, the present invention can compress the features in the sequence dimension into a global feature representation with a fixed dimension; taking the average or maximum value of the sequence dimension L can extract the most representative global information from the entire sequence, avoiding the influence of redundant information in the sequence on the model performance; using learnable weights to perform weighted averaging on the sequence enables the model to dynamically adjust the focus of attention according to the importance of different time points, and this weighting mechanism enhances the model's ability to capture key features; the weights calculated through the attention mechanism can automatically adjust the contribution of each position according to different features of the input signal, further improving the expressive ability of the features and the performance of the model; finally, these global features will be used for classification tasks, improving the model's comprehensive understanding and accurate classification of signals.
[0224] As an embodiment of the present application, the step S43 specifically includes:
[0225] S431: Input the generated global features into the fully connected layer for non-linear mapping:
[0226] The formula for the first fully connected layer is as follows:
[0227]
[0228] where, , , is the dimension of the hidden layer;
[0229] The formula for the second fully connected layer is as follows:
[0230]
[0231] where, , , is the feature dimension of the classification output;
[0232] S432: Use a linear classifier to process the output features of the second fully connected layer, and its formula is as follows:
[0233]
[0234] where, is the output feature of the second fully connected layer, is the classifier weight matrix, is the bias term, is the original output of the classifier;
[0235] S433: The final classification output layer uses a function to map the features to a categorical probability distribution, and its formula is as follows:
[0236]
[0237] where, is the probability that the sample belongs to category ; is the score of the sample for category ; represents the index of the category, is the exponential function used to map the score to a positive value.
[0238] Specifically, by inputting the aggregated global features into the fully connected layer and the classification output layer, the present invention can further integrate and non-linearly map high-dimensional features, use the fully connected layer to assign weights to different features, extract global information, and at the same time map the features to a probability distribution through the fully connected layer to clarify the possibilities of each category, so as to achieve accurate classification and detection of impedance signals and effectively improve the accuracy and robustness of cancer detection.
[0239] The above description is only some preferred embodiments of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above inventive concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) disclosed in the embodiments of the present disclosure that have similar functions.
Claims
1. A method for impedance cancer detection based on self-attention mechanism, characterized in that The method includes the following steps: S1: Obtain the impedance signal and send it to the input layer for preprocessing to remove noise and interference. The preprocessing includes denoising, detrending, and normalization; S2: Divide the preprocessed signal into two branches. The first branch is input into the frequency-domain network to extract the frequency-domain features of the signal, and the second branch is input into the time-domain model to extract the high-dimensional features of the signal. The frequency-domain network includes Fourier transform, convolutional layer, and pooling layer. The time-domain model includes a period decomposition module, convolutional operation, and global convolutional layer; S3: Input the frequency-domain features extracted by the frequency-domain network and the high-dimensional features extracted by the time-domain model into the feature fusion layer for fusion to obtain the fused features; S4: Use the self-attention mechanism to process the fused features, and finally input them into the fully connected layer and classification output layer for cancer risk prediction to output the detection result; The specific process of the first branch in step S2 inputting into the frequency-domain network to extract the frequency-domain features of the signal includes: S211: First, convert the preprocessed time-domain signal to the frequency domain through discrete Fourier transform. The Fourier transform formula is as follows: Among them, is the time-domain signal after preprocessing, is the frequency-domain signal, that is, the amplitude of each frequency point ; is the number of sampling points of the signal, is the imaginary unit; S212: Then, convert the obtained frequency-domain signal into a spectrogram, and perform feature extraction on the spectrogram through a convolutional layer. The convolutional layer learns the local frequency features of the signal through a convolutional kernel. The formula for the convolution operation is as follows: Among them, is the convolution kernel, which is used to extract the local features of the spectrogram, is the bias term, which controls the offset of the convolution output, is the input frequency-domain signal, represents the convolution operation, is the frequency-domain feature output by the convolution layer, represents the activation function, which is used to introduce non-linearity and improve the representation ability of the network, represents the input vector; S213: Second, further process the frequency-domain features output by the convolutional layer through the pooling layer using max pooling. The pooling operation is used to reduce the size of the feature map, thereby reducing the computational amount and preventing overfitting. The pooling formula is: Among them, is the frequency-domain feature output by the convolutional layer, is the starting position of the pooling window, is the size of the pooling window, is the frequency-domain feature after pooling; S214: Perform multiple stacks of convolutional layers and pooling layers, and finally output the frequency domain feature as , and its calculation formula is: Among them, is the finally output frequency-domain feature, indicating the frequency-domain feature after being stacked times. The specific process of the second branch in step S2 inputting into the time-domain model to extract the high-dimensional features of the signal includes: S221: Decompose the input time-domain signal into multiple periodic components through the period decomposition module, and decompose it into multiple periodic components based on frequency, amplitude, and phase. The decomposition formula is as follows: Among them, is the original time-domain signal, is the amplitude of the th periodic component, is the frequency of the th periodic component, is the phase of the th periodic component, represents that the signal is decomposed into periodic components, and the periodic information in the signal is extracted; S222: After time-domain decomposition, use convolutional operation combined with frequency-domain enhancement to extract local frequency-domain features. The local frequency-domain features are used to help capture the frequency features at different time points of the signal, and enhance them through the convolutional layer. The convolutional operation formula is as follows: Among them, is the local frequency domain feature, representing the frequency domain feature extracted by the convolutional layer, represents the weight for extracting the frequency domain information, is the input signal, is the bias term, used to control the offset of the convolutional layer output, represents the convolution operation, The activation function is used to introduce non-linearity, thereby improving the representation ability of the network; S223: Combine all the periodic features through the global convolutional layer to form global frequency-domain features for better capturing the overall features of the signal. The global enhancement feature modeling formula is as follows: Among them, represents the output after combining all local frequency domain features through the global convolutional layer, represents the weight of the th periodic feature, is the th periodic feature, representing the feature extracted by local frequency domain convolution. The global convolutional layer performs weighted sum and combination on each periodic feature to generate the global frequency domain feature ; S224: The local frequency domain features and the global frequency domain features are combined together as the output of the network, and the feature output formula is as follows: Among them, represents the final output feature that combines local frequency domain features and global frequency domain features The final output feature is a high-dimensional feature that contains local and global information of the signal.
2. The impedance cancer detection method based on the self-attention mechanism according to claim 1, characterized in that, The specific content of step S1 includes: S11: Acquire the original signal through a specific device, and the sampling frequency is ; S12: Use a low-pass filter to eliminate high-frequency noise. The formula is as follows: Among them, is the frequency response function of the filter, is the sampling frequency, is the cut-off frequency of the filter, is the filtered signal, is the original impedance signal, is the impulse response function of the filter, represents the convolution operation; S13: Perform detrending after signal denoising. Remove the low-frequency trend component in the signal through moving average. The formula is as follows: Among them, is the filtered signal, is the sliding window length, is the signal at the time point value, is the detrended signal; S14: Then perform signal normalization to adjust the numerical range of the signal to a unified standard interval [0,1]. The formula is as follows: Among them, is the detrended signal, is the minimum value in the signal is the maximum value in the signal is the normalized signal, whose range is scaled to [0, 1].
3. The impedance cancer detection method based on self-attention mechanism according to claim 1, characterized in that, The specific content of step S3 includes: S31: Align the frequency-domain features output by the frequency-domain network and the high-dimensional features output by the time-domain model to perform feature alignment, and transform the frequency-domain features and the high-dimensional features to the same dimension , where , is the batch size, is the frequency-domain feature dimension, , is the time-domain feature dimension, through the linear transformation formula: Among them, , , , 、 represent the features after linear transformation; S32: The features after linear transformation and are sent to the feature fusion layer, and weighted summation is performed on the two through the feature fusion method of weighted summation of features to assign weights to each branch and , and its calculation formula is as follows: Among them, and , represents the feature after fusion.
4. The impedance cancer detection method based on the self-attention mechanism according to claim 3, wherein The specific content of step S4 includes: S41: Process the fused features through the self-attention mechanism to obtain enhanced features; S42: Generate global features by aggregating or selecting the enhanced features; S43: Input the generated global features into the fully connected layer and classification output layer to obtain the final detection result.
5. The impedance cancer detection method based on the self-attention mechanism according to claim 4, wherein, The specific content of step S41 includes: S411: Add positional encoding to the fused features to inject sequence information. The positional encoding formula is as follows: Among them, is the position index of the sequence, is the feature dimension index, represents the dimension of the position vector, and the position encoding is added to the feature after fusion The formula is as follows: Among them, represents the fused features, represents the positional encoding information, represents the output features; S412: Capture the correlations at different positions in the sequence through the multi-head self-attention mechanism, and generate through linear transformation , and the formula is as follows: Among them, is a scientific parameter, represents a query, represents a key, represents a value, represents the feature output by step S411; S413: Calculate the attention weights using scaled dot-product attention. The formula is as follows: Among them, represents the correlation of each position in the sequence, is the scaling factor; S414: Concatenate the outputs of attention heads and transform through a linear layer, as shown in the following formula: Among them, , is the output weight matrix, represents the output of the attention calculation; S415: The features at each position are non-linearly transformed through a feedforward neural network, and the formula is as follows: Among them, , is the weight matrix, , are the bias terms, is a two-layer fully connected network; S416: Use residual connections and normalization to stabilize the training. The expression formulas for residual connections and normalization are as follows: Among them, is the input feature, represents the output of the attention mechanism, is layer normalization, which normalizes the features at each time step so that their mean is 0 and standard deviation is 1, and represent the result of the residual connection and normalization. The final output feature formula is as follows: Among them, is the final output feature, representing the sequence feature, represents the batch size, represents the sequence length, represents the feature dimension.
6. The impedance cancer detection method based on self-attention mechanism according to claim 5, wherein The specific steps of S42 include: S421: Aggregate or select the output features of the previous step to generate a global feature representation, and perform global average pooling on it. The formula is as follows: Among them, is the final output feature, with a shape of , represents the sequence dimension, and is the generated global feature; S422: For the sequence dimension Take the maximum value, and the formula is as follows: Among them, represents the maximum value of the aggregation feature in the th feature dimension, represents the maximum value operation, which takes the maximum value of each feature dimension in time steps; S423: Then perform attention pooling. The formula is as follows: Among them, the weight represents the importance of the th time step, which is a learnable parameter and has the same shape as the feature dimension, and assigns weights to each time step through linear transformation.
7. The impedance cancer detection method based on self-attention mechanism according to claim 6, characterized in that The specific steps of S43 include: S431: Input the generated global features into the fully connected layer for non-linear mapping: The formula for the first fully connected layer is as follows: Among them, , , are the dimensions of the hidden layer; The formula for the second fully connected layer is as follows: Among them, , , are the feature dimensions of the classification output; S432: Use a linear classifier to process the output features of the second fully connected layer. The formula is as follows: Among them, is the output feature of the second fully connected layer, is the classifier weight matrix, is the bias term, is the original output of the classifier; S433: The final classification output layer uses a function to map the features to the categorical probability distribution, and its formula is as follows: Among them, is the probability that the sample belongs to the category , is the score of the sample for the category , represents the index of the category, is the exponential function used to map the score to a positive value.
Citation Information
Patent Citations
Three-dimensional electrical impedance imaging system based on deep learning
CN112754456A
Respiratory signal estimation method based on time domain and frequency domain fusion analysis of ECG and PPG signals
CN118830828A
Converter station overvoltage identification method and system based on attention mechanism feature fusion
CN118916754A