Electrical impedance cancer detection method based on self-attention mechanism
By adopting the self-attention mechanism of the electrical impedance cancer detection method in electrical impedance signal analysis, combining the frequency domain network and time domain model to extract features, and perform feature fusion and enhancement, the problem of insufficient signal processing efficiency and classification accuracy in the prior art is solved, and more efficient and reliable cancer detection is achieved.
Patent Information
- Application Number
- CN202510471573.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-04-15
AI Technical Summary
The existing electrical impedance signal analysis methods have many challenges in signal processing efficiency, feature extraction accuracy and classification accuracy, making it difficult to effectively detect cancer.
The electrical impedance cancer detection method based on the self-attention mechanism is adopted, and the frequency-domain characteristics and high-dimensional characteristics of the signal are extracted by the frequency-domain network and time-domain models, and the feature enhancement is performed through feature fusion and self-attention mechanism, and finally the full connection layer and the classified output layer are transmitted to the cancer risk prediction.
It significantly improves the accuracy and reliability of cancer detection, improves signal quality and feature extraction efficiency, and enhances classification performance and model adaptability.
Smart Images

Figure CN119969996A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cancer detection, and in particular to an electrical impedance cancer detection method based on a self-attention mechanism. Background Art
[0002] Electrical impedance tomography is a non-invasive and biocompatible medical detection technology that indirectly reflects the physical and physiological properties of biological tissues by measuring the impedance characteristics of human tissues to an applied weak current. In clinical applications, electrical impedance tomography is widely used in early cancer detection, lung health monitoring, and breast disease screening. However, existing electrical impedance signal analysis methods face many challenges in terms of signal processing efficiency, feature extraction accuracy, and classification accuracy, which restricts the further development of the technology.
[0003] To solve the above problems, it is urgent to develop an innovative network structure that combines the advantages of frequency domain and time domain feature extraction, and design efficient signal preprocessing and feature fusion mechanisms. By adopting advanced deep learning techniques such as self-attention mechanism and multi-scale feature fusion method, the sensitivity and specificity of cancer detection can be significantly improved.
[0004] In the prior art, a Chinese patent with publication number CN112754456A discloses "a three-dimensional electrical impedance imaging system based on deep learning". This method is based on a three-dimensional electrical impedance imaging system based on deep learning and can be used for human breast imaging. Through a certain excitation acquisition method, the three-dimensional surface impedance information of the hemispherical measurement area can be obtained. However, this method mainly relies on the impedance information of the three-dimensional surface and cannot make full use of other types of features.
[0005] Therefore, it is urgent to design an impedance cancer detection method based on the self-attention mechanism to solve the problems existing in the above-mentioned prior art. Summary of the invention
[0006] In response to the above defects or improvement needs of the prior art, the present invention provides an electrical impedance cancer detection method based on a self-attention mechanism. After obtaining the electrical impedance signal, it is preprocessed to remove noise and interference, and the frequency domain features of the signal are extracted using a frequency domain network. At the same time, a periodic decomposition module and frequency domain enhancement are used in the time domain model to model the time series features. The self-attention mechanism is used to enhance the fused features, and finally the features are passed to the fully connected layer and the classification output layer, thereby improving the accuracy and reliability of cancer detection.
[0007] To achieve the above object, according to one aspect of the present invention, a method for electrical impedance cancer detection based on a self-attention mechanism is provided, the method comprising the following steps: S1: acquiring the electrical impedance signal and sending it to the input layer for preprocessing to remove noise and interference, wherein the preprocessing includes denoising, detrending and normalization processing; 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, convolution layer and pooling layer, and the time domain model includes periodic decomposition module, convolution operation and global convolution layer; S3: Inputting the frequency domain features extracted by the frequency domain network and the high-dimensional features extracted by the time domain model into a feature fusion layer for fusion to obtain fused features; S4: Use the self-attention mechanism to process the fused features, and finally pass them to the fully connected layer and the classification output layer to predict cancer risk and output the detection results.
[0008] As an embodiment of the present application, the step S1 specifically includes: S11: The original signal is collected through a specific device with a sampling frequency of ; S12: Use a low-pass filter to eliminate high-frequency noise. The formula is as follows:
[0009]
[0010] in, is the frequency response function of the filter, is the sampling frequency, is the filter cutoff frequency, is the filtered signal, is the original electrical impedance signal, is the impulse response function of the filter, Represents the convolution operation; S13: After signal denoising, detrending is performed to remove the low-frequency trend components in the signal by sliding average. The formula is as follows:
[0011] in, is the filtered signal, is the sliding window length, It's a signal At the point in time The value of It is a signal after detrending; S14: Then perform signal normalization processing to adjust the signal value range to a unified standard interval [0,1]. The formula is as follows:
[0012] in, It is the signal after detrending. It's a signal The minimum value in It's a signal The maximum value in is the normalized signal, whose range is scaled to [0,1].
[0013] As an embodiment of the present application, the first branch in step S2 is input into the frequency domain network to extract the frequency domain features of the signal, which specifically includes: S211: First, the pre-processed time domain signal is converted to the frequency domain by discrete Fourier transform. The Fourier transform formula is as follows:
[0014] in, is the preprocessed time domain signal, It is a frequency domain signal, that is, each frequency point The amplitude of is the number of sampling points of the signal, is an imaginary unit; S212: Then, the obtained frequency domain signal Convert it into a spectrum graph, and extract features from the spectrum graph through a convolution layer. The convolution layer learns the local frequency characteristics of the signal through the convolution kernel. The formula for the convolution operation is as follows:
[0015]
[0016] in, is the convolution kernel, which is used to extract the local features of the spectrum graph. 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 convolutional layer, express Activation function is used to introduce nonlinearity and improve the representation ability of the network. represents the input vector; S213: Secondly, the frequency domain features of the convolutional layer output are further processed using the maximum pooling through the pooling layer. The pooling operation is used to reduce the size of the feature map, thereby reducing the amount of calculation and preventing overfitting. The pooling formula is:
[0017] in, 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, It is the frequency domain feature after pooling; S214: Multiple stacking of convolutional layers and pooling layers is performed, and the final output frequency domain feature is , and its calculation formula is:
[0018] in, is the frequency domain feature of the final output, Indicates passing Frequency domain features after stacking.
[0019] As an embodiment of the present application, the second branch in step S2 inputs the high-dimensional features of the signal extracted into the time domain model specifically includes: S221: Decompose the input time domain signal into multiple periodic components through the periodic decomposition module, and decompose it into multiple periodic components based on frequency, amplitude and phase. The decomposition formula is as follows:
[0020] in, is the original time domain signal, It is The amplitude of the periodic component, It is The frequency of the periodic component, It is The phase of the periodic component, The signal is decomposed into A periodic component is used to extract the periodic information in the signal; S222: After time domain decomposition, convolution operation is used in combination with frequency domain enhancement to extract local frequency domain features. Local frequency domain features are used to help capture the frequency features of different time points in the signal and are enhanced through the convolution layer. The convolution operation formula is as follows:
[0021] in, is the local frequency domain feature, which means the frequency domain feature extracted by the convolution layer. represents the weight used to extract frequency domain information, is the input signal, is the bias term, which is used to control the offset of the convolutional layer output. represents the convolution operation, The activation function is used to introduce nonlinearity, thereby improving the representation ability of the network; S223: All periodic features are combined through the global convolution layer to form a global feature to better capture the overall characteristics of the signal. The global enhanced feature modeling formula is as follows:
[0022] in, represents the output after combining all local frequency domain features through the global convolution layer, Indicates The weight of the period feature, For the Periodic features represent the features extracted by local frequency domain convolution. Each periodic feature is weighted and combined through the global convolution layer to generate the global frequency domain feature. ; S224: The local frequency domain features and global frequency domain characteristics are combined together as the output of the network, and the characteristic output formula is as follows:
[0023] in, It represents the combination of local frequency domain features and global frequency domain characteristics The final output features, the final output features It is a high-dimensional feature that contains local and global information of the signal.
[0024] As an embodiment of the present application, step S3 specifically includes: S31: The frequency domain features output by the frequency domain network And the high-dimensional features output by the time domain model Perform feature alignment and align the frequency domain features and high-dimensional features Convert to the same dimension ,in, , is the batch size, is the frequency domain feature dimension, , is the time domain feature dimension, through the linear transformation formula:
[0025] in, , , , , Represents the features after linear transformation; S32: The features after linear transformation and The feature fusion layer is used to perform weighted summation of the two features and assign weights to each branch. and , and its calculation formula is as follows:
[0026] in, and , Represents the features after fusion.
[0027] As an embodiment of the present application, step S4 specifically includes: S41: The fused features are processed 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 the classification output layer to obtain the final detection result.
[0028] As an embodiment of the present application, the step S41 specifically includes: S411: Add position coding to the fused features to inject sequence information. The position coding formula is as follows:
[0029]
[0030] in, is the position index of the sequence, is the feature dimension index, Represents the dimension of the position vector, adding the position encoding to the fused features In the formula, the following is true:
[0031] in, represents the features after fusion, Indicates position encoding information, Represents the characteristics of the output; S412: Capturing the correlation of different positions in the sequence through multi-head self-attention mechanism, linear transformation generation , the formula is as follows:
[0032] in, is the science parameter, Indicates a query, Indicates the key, Indicates the value, represents the features output from step S411; S413: Use scaled dot product attention to calculate the attention weight, the formula is as follows:
[0033] in, represents the correlation at each position in the sequence, is the scaling factor; S414: The outputs of the attention heads are concatenated and transformed through a linear layer. The formula is as follows:
[0034] in, , is the output weight matrix, Represents the attention calculation output; S415: The features of each position are transformed nonlinearly through a feedforward neural network, and the formula is as follows:
[0035] in, , is the weight matrix, , is the bias term, It is a two-layer fully connected network; S416: Use residual connection and normalization to stabilize training. The residual connection formula is as follows:
[0036]
[0037] in, is the input feature, represents the output of the attention mechanism, For layer normalization, the features of each time step are normalized to have a mean of 0 and a standard deviation of 1. , Represents the result after residual connection and normalization. The final output feature formula is as follows:
[0038] in, is the final output feature, representing the sequence feature, represents the batch size, represents the sequence length, Represents the feature dimension.
[0039] As an embodiment of the present application, the step S42 specifically includes: 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:
[0040] in, is the final output feature, with the shape of , represents the sequence dimension, is the generated global feature; S422: Sequence Dimension Take the maximum value, the formula is as follows:
[0041] in, Indicates that the aggregated features are The maximum value of feature dimensions, Indicates the maximum value operation. Take the maximum value of each feature dimension in each time step; S423: Then perform attention pooling, the formula is as follows:
[0042]
[0043] Among them, the weight Indicates The importance of time steps, is a learnable parameter, with the same shape as the feature dimension, , Assign weights to each time step through a linear transformation.
[0044] As an embodiment of the present application, step S43 specifically includes: S431: Generate global features Input to the fully connected layer for nonlinear mapping: The formula for the first fully connected layer is as follows:
[0045] in, , , is the dimension of the hidden layer; The formula for the second fully connected layer is as follows:
[0046] in, , , is the feature dimension of the classification output; S432: Use a linear classifier to process the output features of the second layer of full connection. The formula is as follows:
[0047] in, is the output feature of the second fully connected layer, is the classifier weight matrix, is the bias term, is the raw output of the classifier; S433: The final classification output layer uses a The function maps features to category probability distribution, and its formula is as follows:
[0048] in, Is the sample belonging to the category The probability of is the sample pair category The score, represents the index of the category, is an exponential function that maps scores to positive values.
[0049] The beneficial effects of the present invention are: (1) After acquiring the electrical impedance signal, the present invention preprocesses it to remove noise and interference, uses the frequency domain network to extract the frequency domain features of the signal, and uses the time domain model to extract the high-dimensional features of the signal. The frequency domain features and the high-dimensional features are sent to the feature fusion layer for feature fusion, and then the self-attention mechanism is used to enhance the features after fusion. Finally, the features are sent to the fully connected layer and the classification output layer to further improve the accuracy and reliability of cancer detection.
[0050] (2) The present invention uses a low-pass filter to remove high-frequency noise, effectively removes environmental interference and equipment noise, makes the signal smoother and more stable, and combines detrending processing to eliminate baseline drift, avoids the interference of long-term drift on feature extraction, thereby retaining key change information in a short period of time, greatly improving the quality and stability of the signal, and providing a reliable data basis for subsequent feature extraction. The signal range is standardized through normalization operation, avoiding the influence of different signal amplitude differences on model performance, ensuring the signal quality and feature extraction efficiency, and improving the adaptability of the system.
[0051] (3) The present invention first converts the preprocessed time domain signal into a frequency domain signal in a frequency domain network, and effectively extracts the local frequency mode from the frequency domain signal, which can effectively capture the spectral characteristics of the electrical impedance signal, reveal its energy distribution and characteristic patterns in different frequency bands, and use the feature learning ability of the convolutional layer to capture important frequency features related to classification. At the same time, the feature map is compressed through the maximum pooling layer to retain key information, reduce redundant data, reduce computational complexity and prevent overfitting, thereby extracting more refined and efficient frequency domain features, providing more accurate input for subsequent feature fusion and classification, helping the model to more efficiently capture frequency features related to cancer detection, and improving feature expression capabilities and classification performance; (4) The present invention can effectively extract the periodic features in the signal by first decomposing the time domain signal into multiple periodic components based on frequency, amplitude and phase through a periodic decomposition module in the time domain model, and capture the complex dynamic changes in the time series features by combining local frequency domain enhancement, helping the model to capture the frequency features at different time points, and enhancing these local features through the convolution layer to improve the representation ability of the signal; then, the local features are further weighted and combined through the global convolution layer to generate global features, thereby ensuring that the overall characteristics of the signal are captured. Finally, through the fusion of local and global features, the generated high-dimensional features can provide a more comprehensive signal representation, enhance the ability to recognize signal features in subsequent classification tasks, and improve the classification performance.
[0052] (5) The present invention dynamically adjusts the weight distribution of frequency domain and time domain features through the self-attention mechanism to achieve feature complementarity and enhancement, significantly improving the input feature quality of the classifier. The module's deep modeling can accurately distinguish cancer from non-cancerous signals, ensuring high accuracy and sensitivity of classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A schematic flow chart of an electrical impedance cancer detection method based on a self-attention mechanism provided in an embodiment of the present invention; Figure 2 A schematic diagram of the overall framework structure of an electrical impedance cancer detection method based on a self-attention mechanism provided in an embodiment of the present invention; Figure 3 A schematic diagram of a self-attention mechanism model of an electrical impedance cancer detection method based on a self-attention mechanism provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0055] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0056] In the present invention, unless otherwise clearly specified and limited, the terms "connection", "fixation", etc. should be understood in a broad sense. For example, "fixation" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0057] 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 used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the meaning of "and / or" appearing in the full text includes three parallel schemes. Taking "A and / or B" as an example, it includes scheme A, or scheme B, or a scheme that satisfies both A and B. In addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on the ability of ordinary technicians in the field to implement. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0058] Reference Figure 1-Figure 3 In a first aspect, the present invention provides an electrical impedance cancer detection method based on a self-attention mechanism, the method comprising the following steps: S1: acquiring the electrical impedance signal and sending it to the input layer for preprocessing to remove noise and interference, wherein the preprocessing includes denoising, detrending and normalization processing; 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, convolution layer and pooling layer, and the time domain model includes periodic decomposition module, convolution operation and global convolution layer; S3: Inputting the frequency domain features extracted by the frequency domain network and the high-dimensional features extracted by the time domain model into a feature fusion layer for fusion to obtain fused features; S4: Use the self-attention mechanism to process the fused features, and finally pass them to the fully connected layer and the classification output layer to predict cancer risk and output the detection results.
[0059] Specifically, the present invention can effectively remove noise, interference and trend non-target signals by acquiring the electrical impedance signal and sending it to the input layer for preprocessing, ensuring the stable quality of the input signal and laying the 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 pattern of the key frequency band, while reducing data redundancy and retaining the core feature expression; by designing a time domain model to extract high-dimensional features, the potential periodic laws and local change characteristics of time series data can be further explored to enhance the global expression ability; then the frequency domain features and the time series features are fused to obtain the fused features; finally, the fused features are accurately modeled and weighted through the self-attention mechanism to maximize the representation ability of the key features, and the fully connected layer and the classification output layer are combined to achieve efficient cancer detection, significantly improving the diagnostic accuracy and reliability.
[0060] As an embodiment of the present application, the step S1 specifically includes: S11: The original signal is collected through a specific device with a sampling frequency of ; S12: Use a low-pass filter to eliminate high-frequency noise. The formula is as follows:
[0061]
[0062] in, is the frequency response function of the filter, is the sampling frequency, is the filter cutoff frequency, which sets the maximum frequency that the filter allows to pass. The filtered signal is obtained by convolution. is the original electrical impedance signal, is the impulse response function of the filter, Represents the convolution operation; S13: After signal denoising, detrending is performed to remove the low-frequency trend components in the signal by sliding average. The formula is as follows:
[0063] in, is the filtered signal, is the sliding window length, It's a signal At the point in time The value of It is a signal after detrending; S14: Then perform signal normalization processing to adjust the signal value range to a unified standard interval [0,1]. The formula is as follows:
[0064] in, It is the signal after detrending. It's a signal The minimum value in It's a signal The maximum value in It is a normalized signal whose range is scaled to [0,1]. After normalization, each data point of the signal is in the interval [0,1], which helps to unify the amplitude range of the signal.
[0065] Specifically, the present invention can eliminate high-frequency noise through a low-pass filter, effectively remove environmental interference and equipment noise, and make the signal smoother and more stable; then remove the low-frequency trend component in the signal through sliding average through detrending processing, avoid the interference of long-term drift on feature extraction, thereby retaining key change information in a short time; then signal normalization unifies the data to the standardized range [0,1], eliminates dimensional differences, improves the comparability of different features, and provides consistent input data for subsequent model processing. These preprocessing operations jointly ensure the quality of the signal and the efficiency of feature extraction, and are the key basic steps of the entire detection process.
[0066] As an embodiment of the present application, the first branch in step S2 is input into the frequency domain network to extract the frequency domain features of the signal, which specifically includes: S211: First, the pre-processed time domain signal is converted to the frequency domain by discrete Fourier transform. The Fourier transform formula is as follows:
[0067] in, is the preprocessed time domain signal, It is a frequency domain signal, that is, each frequency point The amplitude of is the number of sampling points of the signal, is an imaginary unit; through a transformation, the time domain signal is converted into a frequency domain signal ,These frequency domain features represent the strength of the signal at different frequencies, and the frequency domain representation can help the model identify frequency features related to target classification.
[0068] 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 have a significant contribution to target classification, while suppressing the interference of irrelevant frequency components on the model. This frequency domain representation provides a more targeted input for the subsequent feature extraction network, which helps the model to more efficiently capture the frequency features related to cancer detection, and improve the feature expression capability and classification performance.
[0069] S212: Then, the obtained frequency domain signal Convert it into a spectrum graph and extract features through a convolutional network. The convolutional network includes a convolutional layer and a pooling layer. The spectrum graph is extracted through the convolutional layer. The convolutional layer learns the local frequency characteristics of the signal through the convolution kernel. The formula of the convolution operation is as follows:
[0070]
[0071] in, is the convolution kernel, which is used to extract the local features of the spectrum graph. 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 convolutional layer, express Activation function is used to introduce nonlinearity 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 in gradient propagation during training.
[0072] S213: Secondly, after the convolution operation extracts the frequency domain features, the frequency domain features output by the convolution layer are further processed using the maximum pooling through the pooling layer. The pooling operation is used to reduce the size of the feature map, thereby reducing the amount of calculation and preventing overfitting. The pooling formula is:
[0073] in, 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, It is the frequency domain feature after pooling; S214: In order to extract more complex and advanced features, multiple convolutional layers and pooling layers are stacked, and the final output frequency domain features are: , and its calculation formula is:
[0074] in, is the frequency domain feature of the final output, Indicates passing Frequency domain features after stacking.
[0075] Specifically, the present invention can effectively extract local frequency patterns from frequency domain signals, and use the feature learning ability of the convolutional layer to capture important frequency features related to classification. At the same time, the feature map is compressed through the maximum pooling layer to retain key information, reduce redundant data, reduce computational complexity and prevent overfitting, thereby extracting more refined and efficient frequency domain features, providing more accurate input for subsequent feature fusion and classification.
[0076] As an embodiment of the present application, the second branch in step S2 inputs the high-dimensional features of the signal extracted into the time domain model specifically includes: S221: Decompose the input time domain signal into multiple periodic components through the periodic decomposition module, and decompose it into multiple periodic components based on frequency, amplitude and phase. The decomposition formula is as follows:
[0077] in, is the original time domain signal, It is The amplitude of the periodic component, It is The frequency of the periodic component, It is The phase of the periodic component, The signal is decomposed into A periodic component is used to extract the periodic information in the signal; Specifically, the present invention can effectively extract the periodic features in the signal by decomposing the time domain signal into multiple periodic components based on frequency, amplitude and phase. This decomposition method can more intuitively capture the periodic structure and dynamic change characteristics in the signal, help enhance the model's ability to understand complex time series data, and provide a more accurate periodic feature representation for subsequent feature modeling and classification, thereby improving the accuracy and robustness of classification.
[0078] S222: After time domain decomposition, convolution operation is used in combination with frequency domain enhancement to extract local frequency domain features. Local frequency domain features are used to help capture the frequency features of different time points in the signal and are enhanced through the convolution layer. The convolution operation formula is as follows:
[0079] in, is the local frequency domain feature, which means the frequency domain feature extracted by the convolution layer. represents the weight used to extract frequency domain information, is the input signal, is the bias term, which is used to control the offset of the convolutional layer output. represents the convolution operation, The activation function is used to introduce nonlinearity, thereby improving the representation ability of the network; S223: After extracting the local frequency domain features, all periodic features are combined through the global convolution layer to form global frequency domain features in order to better capture the overall characteristics of the signal. The global enhanced feature modeling formula is as follows:
[0080] in, represents the output after combining all local frequency domain features through the global convolution layer, Indicates The weight of the period feature, For the Periodic features represent the features extracted by local frequency domain convolution. Each periodic feature is weighted and combined through the global convolution layer to generate the global frequency domain feature. ; S224: After local feature extraction and global enhancement, the local frequency domain features and global frequency domain characteristics are combined together as the output of the network, and the characteristic output formula is as follows:
[0081] in, It represents the combination of local frequency domain features and global frequency domain characteristics The final output features, the final output features It is a high-dimensional feature that contains local and global information of the signal.
[0082] Specifically, the present invention decomposes the time domain signal 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; the use of convolution operation combined with frequency domain enhancement can extract local frequency domain features in the signal, help the model capture the frequency features at different time points, and enhance these local frequency domain features through the convolution layer to improve the representation ability of the signal; the global convolution layer further weights and combines the local frequency domain features to generate global frequency domain features, thereby ensuring that the overall characteristics of the signal are captured; 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 ability to recognize signal features in subsequent classification tasks, and improve classification performance.
[0083] As an embodiment of the present application, step S3 specifically includes: S31: The frequency domain features output by the frequency domain network And the high-dimensional features output by the time domain model Perform feature alignment. Since the feature dimensions of the two branches are different, the frequency domain features and high-dimensional features Convert to the same dimension ,in, , is the batch size, is the frequency domain feature dimension, , is the time domain feature dimension, through the linear transformation formula:
[0084] in, , , , , Represents the features after linear transformation; S32: The features after linear transformation and The feature fusion layer is used to perform weighted summation of the two features and assign weights to each branch. and , and its calculation formula is as follows:
[0085] in, and , Represents the features after fusion.
[0086] As an embodiment of the present application, step S4 specifically includes: S41: The fused features are processed 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 the classification output layer to obtain the final detection result.
[0087] like Figure 3 As shown, as an embodiment of the present application, the step S41 specifically includes: S411: Add position coding to the fused features to inject sequence information. The position coding formula is as follows:
[0088]
[0089] in, is the position index of the sequence, is the feature dimension index, Represents the dimension of the position vector, adding the position encoding to the fused features In the formula, the following is true:
[0090] in, represents the features after fusion, Indicates position encoding information, Represents the characteristics of the output; S412: Capturing the correlation of different positions in the sequence through multi-head self-attention mechanism, linear transformation generation , the formula is as follows:
[0091] in, is the science parameter, Indicates a query, Indicates the key, Indicates the value, represents the features output from step S411; S413: Use scaled dot product attention to calculate the attention weight, the formula is as follows:
[0092] in, represents the correlation at each position in the sequence, is the scaling factor to prevent the value from being too large; S414: The outputs of the attention heads are concatenated and transformed through a linear layer. The formula is as follows:
[0093] in, , is the output weight matrix, Represents the attention calculation output; S415: The features of each position are transformed nonlinearly through a feedforward neural network, and the formula is as follows:
[0094] in, , is the weight matrix, , is the bias term, It is a two-layer fully connected network using The function alleviates the overfitting problem; S416: After the feedforward neural network, residual connection and normalization are used to stabilize the training. The residual connection formula is as follows:
[0095]
[0096] in, is the input feature, represents the output of the attention mechanism, For layer normalization, the features of each time step are normalized to have a mean of 0 and a standard deviation of 1. , Represents the result after residual connection and normalization. The final output feature formula is as follows:
[0097] in, is the final output, representing the sequence characteristics, represents the batch size, represents the sequence length, Represents the feature dimension.
[0098] Specifically, the present invention can inject sequence information and retain the timing characteristics of the input signal by introducing position encoding, thereby ensuring that the model can process the sequential information of the timing data; the multi-head self-attention mechanism can capture the correlation between different positions in the signal, and by calculating the attention weight, the model can dynamically focus on the most important part of the input signal, thereby improving the accuracy and efficiency of feature learning; after splicing the outputs of multiple attention heads, the expression of information is further optimized through the transformation of the linear layer; then, nonlinear transformation is performed through a feedforward neural network to improve the representation ability of the model, so that it can process complex signal relationships; finally, 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 conversion and final classification task.
[0099] As an embodiment of the present application, the step S42 specifically includes: S421: Output features of the previous step Aggregate or select to generate a global feature representation, and perform global average pooling on it. The formula is as follows:
[0100] in, is the final output feature, with the shape of , represents the sequence dimension, is the output dimension; S422: Sequence Dimension Take the maximum value, the formula is as follows:
[0101] in, Indicates that the aggregated features are The maximum value of feature dimensions, Indicates the maximum value operation. Take the maximum value of each feature dimension in each time step; S423: Then perform attention pooling, the formula is as follows:
[0102]
[0103] Among them, the weight Indicates The importance of time steps, is a learnable parameter, with the same shape as the feature dimension, , Assign weights to each time step through a linear transformation.
[0104] Specifically, the present invention can compress the features of the sequence dimension into a global feature representation of a fixed dimension by aggregating or selecting the output of the self-attention mechanism; 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 of the sequence on the performance of the model; using learnable weights to perform weighted averaging on the sequence, so that the model can dynamically adjust the focus according to the importance of different time points, and this weighting mechanism enhances the model's ability to capture key features; the weights calculated by the attention mechanism can automatically adjust the contribution of each position according to the different features of the input signal, further improving the expressiveness of the features and the performance of the model; ultimately, these global features will be used for classification tasks, improving the model's comprehensive understanding and accurate classification of signals.
[0105] As an embodiment of the present application, step S43 specifically includes: S431: Generate global features Input to the fully connected layer for nonlinear mapping: The formula for the first fully connected layer is as follows:
[0106] in, , , is the dimension of the hidden layer; The formula for the second fully connected layer is as follows:
[0107] in, , , is the feature dimension of the classification output; S432: Use a linear classifier to process the output features of the second layer of full connection. The formula is as follows:
[0108] in, is the output feature of the second fully connected layer, is the classifier weight matrix, is the bias term, is the raw output of the classifier; S433: The final classification output layer uses a The function maps features to category probability distribution, and its formula is as follows:
[0109] in, Is the sample belonging to the category The probability of is the sample pair category The score, represents the index of the category, is an exponential function that maps scores to positive values.
[0110] Specifically, the present invention can further integrate and nonlinearly map high-dimensional features by inputting the aggregated global features into the fully connected layer and the classification output layer, and use the fully connected layer to assign weights to different features to extract global information. At the same time, the features are mapped into probability distributions through the fully connected layer to clarify the possibility of each category, thereby achieving accurate classification and detection of electrical impedance signals and effectively improving the accuracy and robustness of cancer detection.
[0111] The above descriptions are only some preferred embodiments of the present disclosure and an explanation of the technical principles used. 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 a 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 above features are replaced with (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure.
Claims
1. An electrical impedance cancer detection method based on self-attention mechanism, characterized in that: The method comprises the following steps: S1: acquiring the electrical impedance signal and sending it to the input layer for preprocessing to remove noise and interference, wherein the preprocessing includes denoising, detrending and normalization processing; 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, convolution layer and pooling layer, and the time domain model includes periodic decomposition module, convolution operation and global convolution layer; S3: Inputting the frequency domain features extracted by the frequency domain network and the high-dimensional features extracted by the time domain model into a feature fusion layer for fusion to obtain fused features; S4: Use the self-attention mechanism to process the fused features, and finally pass them to the fully connected layer and the classification output layer to predict cancer risk and output the detection results.
2. The electrical impedance cancer detection method based on self-attention mechanism as claimed in claim 1, characterized in that: The step S1 specifically includes: S11: The original signal is collected through a specific device with a sampling frequency of ; S12: Use a low-pass filter to eliminate high-frequency noise. The formula is as follows: in, is the frequency response function of the filter, is the sampling frequency, is the filter cutoff frequency, is the filtered signal, is the original electrical impedance signal, is the impulse response function of the filter, Represents the convolution operation; S13: After signal denoising, detrending is performed to remove the low-frequency trend components in the signal by sliding average. The formula is as follows: in, is the filtered signal, is the sliding window length, It's a signal At the point in time The value of It is a signal after detrending; S14: Then perform signal normalization processing to adjust the signal value range to a unified standard interval [0,1]. The formula is as follows: in, It is the signal after detrending. It's a signal The minimum value in It's a signal The maximum value in is the normalized signal, whose range is scaled to [0,1].
3. The electrical impedance cancer detection method based on self-attention mechanism as claimed in claim 1, characterized in that: The first branch in step S2 is input into the frequency domain network to extract the frequency domain features of the signal, which specifically includes: S211: First, the pre-processed time domain signal is converted to the frequency domain by discrete Fourier transform. The Fourier transform formula is as follows: in, is the preprocessed time domain signal, It is a frequency domain signal, that is, each frequency point The amplitude of is the number of sampling points of the signal, is an imaginary unit; S212: Then, the obtained frequency domain signal Convert it into a spectrum graph, and extract features from the spectrum graph through a convolution layer. The convolution layer learns the local frequency characteristics of the signal through the convolution kernel. The formula for the convolution operation is as follows: in, is the convolution kernel, which is used to extract the local features of the spectrum graph. 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 convolutional layer, express Activation function is used to introduce nonlinearity and improve the representation ability of the network. represents the input vector; S213: Secondly, the frequency domain features of the convolutional layer output are further processed using the maximum pooling through the pooling layer. The pooling operation is used to reduce the size of the feature map, thereby reducing the amount of calculation and preventing overfitting. The pooling formula is: in, 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, It is the frequency domain feature after pooling; S214: Multiple stacking of convolutional layers and pooling layers is performed, and the final output frequency domain feature is , and its calculation formula is: in, is the frequency domain feature of the final output, Indicates passing Frequency domain features after stacking.
4. The electrical impedance cancer detection method based on self-attention mechanism as claimed in claim 3, characterized in that: The second branch in step S2 is input into the time domain model to extract the high-dimensional features of the signal, specifically including: S221: Decompose the input time domain signal into multiple periodic components through the periodic decomposition module, and decompose it into multiple periodic components based on frequency, amplitude and phase. The decomposition formula is as follows: in, is the original time domain signal, It is The amplitude of the periodic component, It is The frequency of the periodic component, It is The phase of the periodic component, The signal is decomposed into A periodic component is used to extract the periodic information in the signal; S222: After time domain decomposition, convolution operation is used in combination with frequency domain enhancement to extract local frequency domain features. Local frequency domain features are used to help capture the frequency features of different time points in the signal and are enhanced through the convolution layer. The convolution operation formula is as follows: in, is the local frequency domain feature, which means the frequency domain feature extracted by the convolution layer. represents the weight used to extract frequency domain information, is the input signal, is the bias term, which is used to control the offset of the convolutional layer output. represents the convolution operation, The activation function is used to introduce nonlinearity, thereby improving the representation ability of the network; S223: All periodic features are combined through the global convolution layer to form global frequency domain features in order to better capture the overall characteristics of the signal. The global enhanced feature modeling formula is as follows: in, represents the output after combining all local frequency domain features through the global convolution layer, Indicates The weight of the period feature, For the Periodic features represent the features extracted by local frequency domain convolution. Each periodic feature is weighted and combined through the global convolution layer to generate the global frequency domain feature. ; S224: The local frequency domain features and global frequency domain characteristics are combined together as the output of the network, and the characteristic output formula is as follows: in, It represents the combination of local frequency domain features and global frequency domain characteristics The final output features, the final output features It is a high-dimensional feature that contains local and global information of the signal.
5. The electrical impedance cancer detection method based on self-attention mechanism as claimed in claim 4, characterized in that: The step S3 specifically includes: S31: The frequency domain features output by the frequency domain network And the high-dimensional features output by the time domain model Perform feature alignment and align the frequency domain features and high-dimensional features Convert to the same dimension ,in, , is the batch size, is the frequency domain feature dimension, , is the time domain feature dimension, through the linear transformation formula: in, , , , , Represents the features after linear transformation; S32: The features after linear transformation and The feature fusion layer is used to perform weighted summation of the two features and assign weights to each branch. and , and its calculation formula is as follows: in, and , Represents the features after fusion.
6. The electrical impedance cancer detection method based on self-attention mechanism as claimed in claim 5, characterized in that: The step S4 specifically includes: S41: The fused features are processed 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 the classification output layer to obtain the final detection result.
7. The electrical impedance cancer detection method based on self-attention mechanism as claimed in claim 6, characterized in that: The step S41 specifically includes: S411: Add position coding to the fused features to inject sequence information. The position coding formula is as follows: in, is the position index of the sequence, is the feature dimension index, Represents the dimension of the position vector, adding the position encoding to the fused features In the formula, the following is true: in, represents the features after fusion, Indicates position encoding information, Represents the characteristics of the output; S412: Capturing the correlation of different positions in the sequence through multi-head self-attention mechanism, linear transformation generation , the formula is as follows: in, is the science parameter, Indicates a query, Indicates the key, Indicates the value, represents the features output from step S411; S413: Use scaled dot product attention to calculate the attention weight, the formula is as follows: in, represents the correlation at each position in the sequence, is the scaling factor; S414: The outputs of the attention heads are concatenated and transformed through a linear layer. The formula is as follows: in, , is the output weight matrix, Represents the attention calculation output; S415: The features of each position are transformed nonlinearly through a feedforward neural network, and the formula is as follows: in, , is the weight matrix, , is the bias term, It is a two-layer fully connected network; S416: Use residual connection and normalization to stabilize training. The expression formula of residual connection and normalization is as follows: in, is the input feature, represents the output of the attention mechanism, For layer normalization, the features of each time step are normalized to have a mean of 0 and a standard deviation of 1. , Represents the result after residual connection and normalization. The final output feature formula is as follows: in, is the final output feature, representing the sequence feature, represents the batch size, represents the sequence length, Represents the feature dimension.
8. The electrical impedance cancer detection method based on self-attention mechanism as claimed in claim 7, characterized in that: The step S42 specifically includes: 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: in, is the final output feature, with the shape of , represents the sequence dimension, is the generated global feature; S422: Sequence Dimension Take the maximum value, the formula is as follows: in, Indicates that the aggregated features are The maximum value of feature dimensions, Indicates the maximum value operation. Take the maximum value of each feature dimension in each time step; S423: Then perform attention pooling, the formula is as follows: Among them, the weight Indicates The importance of time steps, is a learnable parameter, with the same shape as the feature dimension, , Assign weights to each time step through a linear transformation.
9. The electrical impedance cancer detection method based on self-attention mechanism as claimed in claim 8, characterized in that: The step S43 specifically includes: S431: Generate global features Input to the fully connected layer for nonlinear mapping: The formula for the first fully connected layer is as follows: in, , , is the dimension of the hidden layer; The formula for the second fully connected layer is as follows: in, , , is the feature dimension of the classification output; S432: Use a linear classifier to process the output features of the second layer of full connection. The formula is as follows: in, is the output feature of the second fully connected layer, is the classifier weight matrix, is the bias term, is the raw output of the classifier; S433: The final classification output layer uses a The function maps features to category probability distribution, and its formula is as follows: in, Is the sample belonging to the category The probability of is the sample pair category The score, represents the index of the category, is an exponential function that maps scores to positive values.
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
Epileptic seizure identification method and device based on parallel attention mechanism interpretability
CN119961777A
Convolutional neural network based human machine interface system using doppler radar and voice sensor, device for processing sensor data of the human machine interface system, method for operating the sames
KR102322817B1
Cited By
Unsupervised wind power equipment blade fault detection method based on phase perception parallel attention mechanism
CN120830602A
Physiological signal stress analysis method and device based on space-time-frequency cross perception
CN121287157A