Brain-like model-based BCG classification prediction method
Through the BCG classification prediction method based on brain-like model, the static convolution layer, channel attention layer and fully connected classification module are used, combined with the LIFNode brain activation layer, the problem of low real-time delay and accuracy in BCG signal classification is solved. Achieve high-precision heart shot type classification and rapid diagnosis.
Patent Information
- Application Number
- CN202411226534.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2024-12-27
AI Technical Summary
In the prior art, there are problems of real-time delay and low accuracy in the classification of heart beat type based on BCG signals.
Using the BCG classification prediction method based on brain-like model, the BCG signal is collected and preprocessed in real time, and the combination of static convolutional layer, channel attention layer and fully connected classification module is used to build a pulse neural network model with the LIFNode brain activation layer. , make classified predictions of heart shot types.
It realizes contactless heart rate monitoring, improves the accuracy and real-time nature of heart beat type classification, reduces monitoring delay, is suitable for long-term continuous monitoring, and has wide application prospects in clinical diagnosis and personalized treatment.
Smart Images

Figure CN119202827A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical signal intelligent processing, and in particular to a BCG (Ballistocardiogram, heart attack signal) classification prediction method based on a brain-like model. Background Art
[0002] Heart rate diseases, such as atrial premature beats and ventricular premature beats, are common diagnostic objects in cardiology. The BCG signal is a mechanical signal that records the mechanical movement of the heart. It reflects the contraction and relaxation of the heart by measuring the chest vibration generated when the heart beats. BCG can provide information about cardiac contractility, heart rate, heart volume, etc., which is of great significance for evaluating the impact of cardiac function and heart disease. By applying BCG, doctors can understand the patient's heart condition in more detail, develop targeted and personalized treatment plans, improve treatment effects, and reduce the risk of heart attacks and complications.
[0003] Unlike ECG (Electrocardiogram) signals, which must be obtained through contact with the skin through electrodes and conductive media (such as gel), BCG measures the mechanical signals generated by chest vibration when the heart beats. BCG detection does not require direct contact with human skin and can be monitored for a long time without disturbing the subject. Accurate classification of BCG signals is crucial for early diagnosis of heart rate diseases, formulation of treatment plans, and prevention of cardiac events. As a signal reflecting the mechanical activity of the heart, BCG provides indirect information on the functional state of the heart. However, due to the complexity of BCG signals, traditional heartbeat type classification methods face the challenges of real-time delays and low accuracy. Summary of the invention
[0004] In view of the above analysis, an embodiment of the present invention aims to provide a BCG classification prediction method based on a brain-like model to solve the technical problems of real-time delay and low accuracy in the existing methods of classifying heart beat types based on BCG signals.
[0005] The present invention provides a BCG classification prediction method based on a brain-like model, comprising the following steps:
[0006] Step S1, real-time acquisition of BCG signals at consecutive moments and preprocessing to obtain preprocessed BCG signals;
[0007] Step S2, input the preprocessed BCG signal into the trained brain-like classification model for identification to obtain the predicted heartbeat type; wherein the brain-like classification model is constructed based on a pulse neural network, and sequentially includes a static convolution layer, a channel attention layer and a fully connected classification module; the static convolution layer is used for feature extraction and channel expansion; the channel attention layer is used for feature selection and enhancement; the fully connected classification module is used for the final classification prediction.
[0008] Furthermore, the pre-processed BCG signal is input into a trained brain-like classification model for identification to obtain a predicted heartbeat type, including:
[0009] The preprocessed BCG signal is sequentially input into the one-dimensional convolution layer Conv1d, the LIFNode brain-like activation layer and the pooling layer of the static convolution layer; the one-dimensional convolution layer Conv1d is used for channel expansion and feature extraction, and the input feature map is sequentially convolved by Conv1d and activated by LIFNode brain-like, and the number of channels is expanded and the sequence length is reduced in dimension; the pooling layer downsamples the feature map with expanded channels and reduced sequence length and outputs it, which is set to X;
[0010] Input X into the channel attention layer to obtain a three-dimensional tensor feature map;
[0011] The three-dimensional tensor feature map is input into the fully connected classification module, which includes a Flatten flattening layer and a linear layer. The input three-dimensional tensor feature map is expanded into a two-dimensional tensor by the Flatten function, and then passes through the linear layer to obtain the classification prediction probability of the heartbeat type.
[0012] Further, the channel attention layer includes a channel weight branch and a transfer input branch;
[0013] The channel weight branch is combined with the custom convolution function through the AdaptiveMaxPool1d function to output the channel attention value, which is set to A;
[0014] The input transfer branch first performs a multiplication operation of X and A, then passes through a convolution layer and a pooling layer for down-sampling, and then outputs a feature map of a three-dimensional tensor.
[0015] Furthermore, training a brain-like classification model includes:
[0016] Constructing a first training data set including preprocessed ECG and corresponding BCG;
[0017] Using the first training data set to train the ECG-BCG mapping model until the loss function converges to obtain a trained ECG-BCG mapping model;
[0018] Based on the trained ECG-BCG mapping model, construct a second training data set for the brain-like classification model; wherein the second training data set includes the heartbeat types of BCG and corresponding ECG;
[0019] The brain-like classification model is trained using the second training data set, and a trained brain-like classification model is obtained after reaching a maximum number of iteration rounds.
[0020] Furthermore, an ECG-BCG mapping model is constructed based on the encoding-decoding structure of the U-shaped convolutional network, including an encoder module and a decoder module;
[0021] The encoder module is used to downsample the received pre-processed ECG to extract local features and output a feature map matrix representing the local features;
[0022] The decoder module restores the spatial dimension through the transposed convolution layer, and fuses the local features extracted by the encoder module with the global features sampled by the decoder module through skip connections, restores them to the original dimensional space, and outputs the BCG corresponding to the preprocessed ECG;
[0023] Among them, the feature map matrix is represented as a three-dimensional tensor, and the three dimensions are batch size, number of channels, and sequence length.
[0024] Furthermore, the encoder module is a downsampling structure, comprising five downsampling layers, wherein:
[0025] The first downsampling layer includes a convolutional layer with a stride of 1, layer normalization, and PReLU activation. The convolutional layer increases the number of channels of the input feature map from 1 to 32 and outputs it to the second downsampling layer.
[0026] The second to fifth downsampling layers include two convolutional layers with a stride of 1 and a maximum pooling layer. Each convolutional layer is followed by layer normalization and PReLU activation. The first convolutional layer doubles the number of channels of the feature map input to the current layer. The second convolutional layer keeps the number of channels unchanged and halves the sequence length dimension of the feature map input to the current layer through the maximum pooling layer, thus outputting the feature map with the changed number of channels and sequence length dimensions.
[0027] Among them, layer normalization is used to accelerate convergence, and PReLU activation introduces nonlinearity to enhance the sensitivity of the encoder module to subtle changes in local features.
[0028] Furthermore, the decoder module is an upsampling structure, including six upsampling layers, as follows:
[0029] The first upsampling layer includes two convolutional layers with a stride of 1 and a transposed convolutional layer. Each convolutional layer with a stride of 1 is followed by layer normalization and PReLU activation. The two convolutional operations with a stride of 1 keep the number of channels unchanged. The transposed convolutional layer is used to halve the number of channels and double the sequence length to achieve spatial expansion and upsampling of features.
[0030] The second to fourth upsampling layers include two convolution layers with a step size of 1 and a transposed convolution layer in sequence. Each convolution layer with a step size of 1 is followed by layer normalization and PReLU activation. The first convolution layer with a step size of 1 first halves the number of channels of the feature map input to the current layer, the second convolution layer with a step size of 1 keeps the number of channels unchanged, and then uses a transposed convolution layer to halve the number of channels and double the sequence length; the input of the second upsampling layer and the output of the fourth downsampling layer, the input of the third upsampling layer and the output of the third downsampling layer, and the input of the fourth upsampling layer and the output of the second downsampling layer are sequentially skip-connected to fuse the downsampled local features and the upsampled global features; the second to fourth upsampling layers respectively output the feature maps with changed channel numbers and sequence lengths to the next layer for upsampling;
[0031] The fifth upsampling layer includes two convolutional layers with a stride of 1 and a transposed convolutional layer. Each convolutional layer with a stride of 1 is followed by layer normalization and PReLU activation. The first convolutional layer with a stride of 1 reduces the number of channels by half to refine the feature representation. The second convolutional layer with a stride of 1 keeps the number of channels unchanged to further extract and fuse the downsampled and upsampled features.
[0032] The sixth upsampling layer uses a single convolutional layer to reduce the number of channels from 16 to 1, maps the decoded feature map back to the dimension of the feature map input to the encoder module, and outputs the BCG mapped by the ECG.
[0033] Further, the original signal sequences of ECG and corresponding BCG data are obtained from the first public data set and preprocessed to obtain the first training data set, including:
[0034] Taking the first R peak of the original signal sequence of the ECG as the starting point, and the J peak corresponding to the timestamp of the first R peak in the original signal sequence of the BCG as the starting point, non-overlapping segmentation is performed with preset sequence lengths respectively;
[0035] The data points before the first R peak in ECG and the first J peak corresponding to BCG, as well as the data points that are less than the preset sequence length after segmentation, are discarded;
[0036] Normalize the amplitudes of the segmented ECG and BCG;
[0037] The normalized ECG and the corresponding BCG constitute each sample in the first training data set;
[0038] Among them, the first public data set is the BED-BASEDBALLISTOCARDIOGRAPHYDATASET published by NIH; in which ECG and BCG correspond one to one based on timestamps.
[0039] Further, loading the first training data set into the ECG-BCG mapping model for training;
[0040] A fixed learning rate is adopted, an MSE mean square error loss function is used for forward propagation, and an Adam optimizer is used for back propagation, and the ECG-BCG mapping model parameters are continuously adjusted to minimize the loss function until the loss function converges to obtain a trained ECG-BCG mapping model;
[0041] Acquire ECG data from a second public data set and perform preprocessing, input the trained ECG-BCG mapping model, obtain corresponding BCG data, and use the corresponding ECG heartbeat type in the second public data set as a label to form the second training data set;
[0042] Loading the second training data set into the brain-like classification model for training until a maximum number of iterations is reached;
[0043] The second public data set is an electrocardiogram (ECG) signal data set published by MIT-BIH, including ECG signals and corresponding heart beat types.
[0044] Furthermore, the calculation mechanism of the LIFNode brain-like activation layer is:
[0045]
[0046] Where T is the preset brain-like time step, V[T] and V[T-1] are the brain-like neuron membrane potentials at brain-like time steps T and T-1, respectively, Y[T] is the feature map output by Conv1d convolution, τ m is the preset membrane time constant, V reset is the reset potential;
[0047] If V[T] reaches the preset discharge threshold V threshold , the membrane potential is reset to zero, and V[T] is input into the substitute function of the step function for back propagation; the substitute function is as follows:
[0048]
[0049] Otherwise, if V[T] does not reach the preset discharge threshold V threshold , the membrane potential of brain-like neurons remains V[T].
[0050] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0051] 1. Use piezoelectric cable sensors to collect BCG signals, realize non-contact heart rate monitoring, non-invasively collect BCG signals in real time, improve patient comfort, and be suitable for long-term continuous monitoring;
[0052] 2. The brain-like model based on spiking neural network is adopted. Through the combination of static convolution layer, channel attention layer and fully connected classification module, the ability to extract and classify BCG signal features is enhanced, and the accuracy of heartbeat type classification is improved. Through LIFNode brain-like activation module and channel attention mechanism, the accuracy of heartbeat type classification is improved;
[0053] 3. Through the optimized brain-like classification model structure and classification method, the delay in real-time monitoring is reduced, making the classification and prediction of BCG signals faster, which helps to achieve rapid diagnosis and response and reduce real-time delay;
[0054] 4. This application effectively integrates and utilizes public data sets to construct a comprehensive and accurately labeled training data set. Through the training of ECG-BCG mapping model and brain-like classification model, this application better utilizes the mechanical information contained in BCG and can more effectively detect cardiac mechanical movement. The heart-brain classification model has broad application prospects in clinical diagnosis, long-term monitoring and personalized treatment.
[0055] In the present invention, the above-mentioned technical solutions can also be combined with each other to achieve more preferred combination solutions. Other features and advantages of the present invention will be described in the subsequent description, and some advantages can become obvious from the description, or can be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The drawings are only for the purpose of illustrating particular embodiments and are not to be considered limiting of the present invention. Like reference symbols denote like components throughout the drawings.
[0057] Figure 1 This is a flow chart of a BCG classification prediction method based on a brain-like model;
[0058] Figure 2 The RR peak of ECG and the JJ peak of BCG collected simultaneously have a fixed time delay;
[0059] Figure 3 Schematic diagram of the trained brain-like classification model for preprocessed BCG signal input;
[0060] Figure 4The structure diagram of the ECG-BCG mapping model based on the encoding-encoding structure of the U-shaped convolutional network;
[0061] Figure 5 This is a structural diagram of the brain-like classification model based on pulse neural network. DETAILED DESCRIPTION
[0062] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0063] The BCG signal provides a direct measurement of the mechanical activity of the heart, including cardiac contractility and load, which ECG cannot provide. In order to solve the problems of real-time delay and low accuracy in the classification of heart beat types based on BCG signals in the above-mentioned prior art, the present invention proposes a BCG classification prediction method based on a brain-like model.
[0064] First, the pre-processed BCG signal is input into the trained brain-like classification model to instantly predict the heartbeat type, solving the real-time delay problem of the existing technology;
[0065] Secondly, the use of the trained brain-like classification model in this application can easily achieve more accurate heartbeat classification and obtain more accurate heartbeat type classification results.
[0066] A specific embodiment of the present invention discloses a BCG classification prediction method based on a brain-like model, such as Figure 1 As shown, the following steps are included:
[0067] Step S1, collecting real-time BCG signals at consecutive moments and preprocessing them to obtain preprocessed BCG signals;
[0068] Step S2: Input the pre-processed BCG signal into the trained brain-like classification model for identification to obtain the predicted heartbeat type; wherein the brain-like classification model is constructed based on a spiking neural network, and includes a static convolution layer, a channel attention layer, and a fully connected classification module in sequence; the static convolution layer is used for feature extraction and channel expansion; the channel attention layer is used for feature selection and enhancement; and the fully connected classification module is used for the final classification prediction. Figure 5 shown.
[0069] Step S1, specifically.
[0070] Real-time BCG signals at continuous moments are collected and preprocessed to obtain preprocessed BCG signals.
[0071] Exemplarily, a piezoelectric cable sensor is used to acquire the BCG signal.
[0072] Compared with ECG signal acquisition which requires skin contact electrodes, piezoelectric cable sensors are non-invasive in acquiring BCG signals and can be placed on different parts of the body or on the bed, integrated into wearable devices or smart clothing, or pressed under the feet of the person being tested's chair.
[0073] Piezoelectric cable sensors are suitable for long-term continuous monitoring and may be more comfortable for patients who need to continuously monitor their heart rate without contact. Piezoelectric sensors can be integrated into wearable devices or smart clothing for portable BCG signal acquisition.
[0074] Piezoelectric cable sensors are lower cost than ECG equipment and are simpler to use.
[0075] The obtained BCG original signal sequence is preprocessed as follows:
[0076] (1) A BCG signal sequence acquired by the sensor in real time is discarded, the data points before the first J peak are split without overlap from the first J peak according to the preset sequence length, and the sequence is saved in a two-dimensional tensor format, expressed as [number of samples, sequence length];
[0077] Exemplarily, the preset sequence length is 304 data points, and non-overlap segmentation is performed with 304 data points as the interval length. For example, the two-dimensional tensor is represented as [16, 304], where 16 is the number of samples and 304 is the sample sequence length.
[0078] (2) After segmentation, the data points that are less than the preset sequence length are discarded;
[0079] (3) Normalizing the amplitude of the segmented BCG signal;
[0080] Normalization subtracts the mean (i.e., the mean amplitude of the BCG signal) from each data point and then divides by the standard deviation, thereby converting the data into a format with mean and unit variance. This facilitates subsequent data processing and analysis.
[0081]
[0082] Among them, the current value is the amplitude of the BCG signal tensor after non-overlapping segmentation; the average value is the sum of the amplitudes of all data points in the 304-point signal data set divided by the number of data points; and the standard deviation is also the standard deviation of the values of the 304 points.
[0083] from Figure 2 It can be seen that if normalization is not performed, the vertical axis amplitude of BCG is different and it is not easy to calculate in subsequent steps. After normalization, all BCGs after non-overlapping segmentation are between [0, 1], which simplifies the subsequent brain-like classification model processing operations.
[0084] Step S1 preprocesses the BCG signal sequence collected in real time, including non-overlapping segmentation, discarding the part that is less than the preset length, and amplitude normalization, and converts it into a data format suitable for input into the brain-like classification model to improve the accuracy of heartbeat type classification and the real-time performance of model processing.
[0085] Step S2 includes steps S21-S22.
[0086] Step S21, inputting the pre-processed BCG signal into the trained brain-like classification model for identification to obtain the predicted heartbeat type, including:
[0087] The preprocessed BCG signal is sequentially input into the one-dimensional convolution layer Conv1d, the LIFNode brain-like activation layer and the pooling layer of the static convolution layer; the one-dimensional convolution layer Conv1d is used for channel expansion and feature extraction, and the input feature map is sequentially convolved by Conv1d and activated by LIFNode brain-like, and the number of channels is expanded and the sequence length is reduced in dimension; the pooling layer downsamples the feature map with expanded channels and reduced sequence length and outputs it, which is set to X;
[0088] Input X into the channel attention layer to obtain a three-dimensional tensor feature map;
[0089] The three-dimensional tensor feature map is input into the fully connected classification module, which includes a Flatten flattening layer and a linear layer. The input three-dimensional tensor feature map is expanded into a two-dimensional tensor by the Flatten function, and then passes through the linear layer to obtain the classification prediction probability of the heartbeat type.
[0090] The predicted heartbeat type is obtained based on the classification prediction probability.
[0091] The number of channels is expanded from 1 to 4, and the sequence length is reduced from 304 to 284.
[0092] like Figure 3 As shown, the preprocessed BCG signal is input into the trained brain-like classification model to obtain the predicted heartbeat type. For the trained brain-like classification model, wherein the channel attention layer includes a channel weight branch and a transfer input branch;
[0093] The channel weight branch is combined with the custom convolution function through the AdaptiveMaxPool1d function to output the channel attention value, which is set to A;
[0094] The input transfer branch first performs a multiplication operation of X and A, then passes through a convolution layer and a pooling layer for down-sampling, and then outputs a feature map of a three-dimensional tensor.
[0095] Among them, the custom convolution combination structure includes convolution (number of channels 4→1) + ReLU activation function + convolution (number of channels 1→4) + Sigmoid activation, a total of four layers.
[0096] The first convolution reduces the number of channels from 4 to 1, which helps to compress features, reduce redundancy, and extract the most important feature information. This feature compression process can be a dimensionality reduction operation, which helps to reduce the complexity of the model; the second convolution expands the number of channels from 1 back to 4, which is a feature expansion or dimensionality increase operation, which helps to restore or enhance the expressiveness of the features. It helps the model capture more detailed feature details.
[0097] The classification prediction probability is obtained based on the trained brain-like classification model, and then the predicted heartbeat classification is obtained.
[0098] The predicted heartbeat type is encoded using one-hot encoding as follows:
[0099] 00001 is normal;
[0100] 00010 is S-type heart rate disease, including atrial premature beats, abnormal atrial premature beats, junctional premature beats, and supraventricular premature beats;
[0101] 00100 is a class V heart rate disease including ventricular premature beats and ventricular escape beats;
[0102] 01000 is a class F heart rate disorder including ventricular fusion beats;
[0103] 10000 is Q-type heart rate disease including paced beats, paced fusion beats, and unclassified beats;
[0104] Among them, S, V, F, and Q are four types of heart rate diseases.
[0105] Step S22, training a brain-like classification model, including steps S221-S224.
[0106] Training brain-like classification models, including:
[0107] Constructing a first training data set including preprocessed ECG and corresponding BCG;
[0108] Using the first training data set to train the ECG-BCG mapping model until the loss function converges to obtain a trained ECG-BCG mapping model;
[0109] Based on the trained ECG-BCG mapping model, construct a second training data set for the brain-like classification model; wherein the second training data set includes the heartbeat types of BCG and corresponding ECG;
[0110] The brain-like classification model is trained using the second training data set, and a trained brain-like classification model is obtained after reaching a maximum number of iteration rounds.
[0111] Step S221, obtaining the original signal sequence of ECG and corresponding BCG data from the first public data set and preprocessing to obtain the first training data set, including:
[0112] Taking the first R peak of the original signal sequence of the ECG as the starting point, and the J peak corresponding to the timestamp of the first R peak in the original signal sequence of the BCG as the starting point, non-overlapping segmentation is performed with preset sequence lengths respectively;
[0113] The data points before the first R peak in ECG and the first J peak corresponding to BCG, as well as the data points that are less than the preset sequence length after segmentation, are discarded;
[0114] Normalize the amplitudes of the segmented ECG and BCG;
[0115] The normalized ECG and the corresponding BCG constitute each sample in the first training data set;
[0116] The first public data set is the BED-BASED BALLISTOCARDIOGRAPHYDATASET published by NIH, in which ECG and BCG correspond one to one based on timestamps.
[0117] For the ECG original signal sequence, find the first R peak of the signal from the beginning of the signal in sequence as the starting point.
[0118] (1) obtaining an original signal sequence including ECG and BCG synchronized therewith from the first public data set. The original signal sequence includes ECG and BCG synchronized therewith, and performing data preprocessing;
[0119] like Figure 2 As shown, the BCG and ECG signals are collected simultaneously.
[0120] Exemplarily, the original signal sequence is ECG and the corresponding BCG in mat format.
[0121] The first public data set used in the present invention comes from NIH. The name of the public signal data set is: BED-BASEDBALLISTOCARDIOGRAPHY DATASET. The length of the public original signal sequence, ECG and BCG, is 107616 data points.
[0122] In the public signal dataset, the ECG and BCG original signal sequences correspond one to one, one ECG corresponds to one BCG. There are 354 groups of samples, with a total of 708 original signal sequence data.
[0123] (2) Preprocess the ECG and corresponding BCG of the original signal sequence to construct the first training data set.
[0124] (a) Perform non-overlapping segmentation on the ECG and corresponding BCG original signal sequences.
[0125] Use a loop function to split the ECG and the corresponding BCG in the original signal sequence without overlapping, starting from the first R peak of ECG and the J peak of BCG corresponding to the first R peak of ECG, with every 304 data points as the interval length, and save it in a two-dimensional tensor format, expressed as [number of samples, sequence length].
[0126] The length of ECG and BCG in the original signal sequence is 107616 data points, and 354 data are obtained by non-overlapping segmentation at intervals of 304 data points. Each data segment after segmentation contains 304 data points.
[0127] For example, the loop function uses a for loop; it is saved in a numpy tensor format based on Python 3.8, with a size of [354, 304];
[0128] According to matrix storage, BCG and ECG are both stored as 354 signals with a length of 304 data points, represented as [354,304].
[0129] For the same patient, ECG and BCG are collected at the same time and correspond one to one based on the timestamp.
[0130] (b) The BCG and ECG signal data after non-overlapping segmentation are normalized to remove the original bias of the data values:
[0131] Normalization is performed using formula (2), which subtracts the mean value (i.e., the amplitude mean of the signal) from each data point and then divides it by the standard deviation, thereby converting the data into a format with a mean value and unit variance. This is helpful for subsequent data processing and analysis.
[0132] from Figure 2 It can be seen that if normalization is not performed, the vertical axis amplitudes of BCG and ECG are different, which makes it difficult to calculate in the subsequent steps. After normalization, all ECGs and corresponding BCGs after non-overlapping segmentation are between [0, 1], which simplifies the subsequent steps.
[0133] (c) Add a channel to the normalized two-dimensional signal tensor and expand it into a three-dimensional tensor to construct the first training data set.
[0134] Exemplarily, the processed two-dimensional signal tensor is shaped as [number of samples, sequence length] using the reshape function based on Python 3.8, and is expanded into a three-dimensional tensor, expressed as [number of samples, number of channels, sequence length], that is, expanded from [354, 304] to [354, 1, 304], adding a channel to prepare for the subsequent ECG-BCG mapping function and the channel dimension transformation of the brain-like classification model, to adapt to and cooperate with the subsequent ECG-ECG network structure, and to be compatible with the subsequent ECG-BCG mapping model;
[0135] After preprocessing, each signal sample data is a preprocessed ECG, and the corresponding preprocessed BCG is used as a sample to form a first training data set, which has a total of 354 samples.
[0136] (d) randomly sampling the first training data set and dividing it into a training set, a validation set, and a test set according to a preset ratio;
[0137] Exemplarily, for the sample data set obtained, 354 samples are randomly divided according to a preset ratio of 8:1:1, so that 283 samples form a training set, 36 samples form a validation set, and 35 samples form a test set;
[0138] Step S222: construct an ECG-BCG mapping model, and train the mapping model based on the first training data set to obtain a trained ECG-BCG mapping model.
[0139] (1) Construct an ECG-BCG mapping model.
[0140] (1.1) Construct an ECG-BCG mapping model based on the encoding-decoding structure of the U-shaped convolutional network. The model structure diagram is as follows: Figure 4 shown.
[0141] An ECG-BCG mapping model is constructed based on the encoding-decoding structure of a U-shaped convolutional network, including an encoder module and a decoder module;
[0142] The encoder module is used to downsample the received pre-processed ECG to extract local features and output a feature map matrix representing the local features;
[0143] The decoder module restores the spatial dimension through the transposed convolution layer, and fuses the local features extracted by the encoder module with the global features sampled by the decoder module through skip connections, restores them to the original dimensional space, and outputs the BCG corresponding to the preprocessed ECG;
[0144] Among them, the feature map matrix is represented as a three-dimensional tensor, and the three dimensions are batch size, number of channels, and sequence length.
[0145] The encoder module is used to extract local features of the input feature map, and the decoder module is used to fuse the local features extracted by the encoder module downsampling with the global features extracted by its own upsampling. The specific parameters of each layer of the ECG-BCG mapping model are shown in Table 1.
[0146] Table 1: ECG-BCG mapping model structure parameter table
[0147]
[0148]
[0149] like Figure 4 As shown:
[0150] The encoder module includes the first to fifth downsampling layers:
[0151] In each layer, the dimension of the number of samples remains unchanged.
[0152] (a) The first downsampling layer: the input feature map dimension is [16, 1, 304], and the output feature map dimension is [16, 32, 304]; the first downsampling layer is a single convolutional layer, the sample number dimension and sequence length dimension do not change, and the number of channels defined in the convolution changes from 1 to 32.
[0153] (b) Second downsampling layer: The input is the output feature map dimension of the first downsampling layer [16, 32, 304], and the output feature map dimension is [16, 64, 152]; the channel number dimension is multiplied by 2 to get 64 channels;
[0154] After convolution, the sequence length S l The change of dimension is shown in formula (2):
[0155]
[0156] Among them, input_shape is the sequence length of the input feature map of this layer, kernel_size is the convolution kernel size, p is the padding, and strikes is the step size.
[0157] The sequence length of the second downsampling layer input is 304. After convolution, the sequence length dimension is calculated using formula (2) as follows:
[0158]
[0159] In the maximum pooling layer, the sequence length dimension is ÷2; the final sequence length dimension is 304÷2=152;
[0160] The final output feature map dimension of the second downsampling layer is [16, 64, 152].
[0161] (c) The third downsampling layer: the input is the output feature map dimension of the second downsampling layer [16, 64, 152], and the output feature map dimension is [16, 128, 76];
[0162] The number of channels is multiplied by 2 to get 128. The sequence length is calculated using formula (2) to get 152, and then the maximum pooling layer sequence length is divided by 2. The final sequence length is 152 ÷ 2 = 76. The final output feature map dimension of the third downsampling layer is [16, 128, 76].
[0163] (d) The fourth downsampling layer: the input is the output feature map dimension of the third downsampling layer [16, 128, 76], and the output feature map dimension is [16, 256, 38];
[0164] The channel number dimension is multiplied by 2 to get the number of channels to be 256;
[0165] The sequence length dimension is calculated using formula (2) to get 76, and then the maximum pooling layer sequence length dimension is divided by 2; the final sequence length dimension is 76÷2=38;
[0166] The final output feature map dimension of the fourth downsampling layer is [16, 256, 38].
[0167] (e) Fifth downsampling layer: The input feature map dimension of the fourth downsampling layer is [16, 256, 38], and the output feature map dimension is [16, 512, 19].
[0168] The number of channels is multiplied by 2 to get 512. The sequence length is calculated using formula (2) to get 38, and then the maximum pooling layer sequence length is divided by 2. The final sequence length is 38 ÷ 2 = 19. The fifth downsampling layer outputs a feature map with a dimension of [16, 512, 19].
[0169] The decoder module includes the first to sixth upsampling layers:
[0170] (a) The first upsampling layer: The input is the output feature map dimension of the fifth downsampling layer [16,512,19], and the output feature map dimension is [16,256,38].
[0171] The channel number dimension is divided by 2 when it is transferred to the convolutional layer to get 256 channels;
[0172] The sequence length dimension is calculated using formula (2) to get 19, and then the sequence length of the transposed convolution layer is multiplied by 2, and the final sequence length dimension is 38;
[0173] The final output feature map dimension of the first upsampling layer is [16, 256, 38].
[0174] (b) The second upsampling layer: The input is the output feature map dimension of the fourth downsampling layer [16, 256, 38] and the output feature map dimension of the first upsampling layer [16, 256, 38]. The jump cascade is performed to obtain the feature map dimension [16, 512, 38], and the output feature map dimension is [16, 128, 76].
[0175] [16,256,38] and [16,256,38] are skipped and cascaded to obtain [16,512,38], which is used as the input of the second upsampling layer;
[0176] After the convolution channel number is divided by 2, the transposed convolution layer divides the channel number by 2 again, resulting in a channel number of 128;
[0177] The sequence length dimension is calculated using formula (2) to be 38, and then the sequence length dimension is multiplied by 2 after the transposed convolution layer to obtain 76; the final output feature map dimension of the second upsampling layer is [16, 128, 76].
[0178] (c) The third upsampling layer: The input is the output feature map dimension of the third downsampling layer [16, 128, 76] and the output feature map dimension of the second upsampling layer [16, 128, 76]. The feature map dimension is [16, 256, 76] after skip concatenation. The output feature map dimension is [16, 64, 152].
[0179] [16,128,76] and [16,128,76] are skipped and cascaded to obtain [16,256,76], which is used as the input of the third upsampling layer;
[0180] After the convolution channel number is divided by 2, the transposed convolution layer divides the channel number by 2 again, resulting in 64 channels;
[0181] The sequence length dimension is calculated using formula (2) to be 76, and then the sequence length dimension is multiplied by 2 after the transposed convolution layer to obtain 152; the final output feature map dimension of the third upsampling layer is [16, 64, 152].
[0182] (d) The fourth upsampling layer: The input is the output feature map dimension of the second downsampling layer [16, 64, 152] and the output feature map dimension of the third upsampling layer [16, 64, 152]. The feature map dimension is [16, 128, 152] after skip concatenation. The output feature map dimension is [16, 32, 304].
[0183] [16, 64, 152] and [16, 64, 152] are skipped and cascaded to obtain [16, 128, 152], which is used as the input of the third upsampling layer;
[0184] After the convolution channel number is divided by 2, the transposed convolution layer divides the channel number by 2 again, resulting in a channel number of 32;
[0185] The sequence length dimension is calculated using formula (2) to be 152, and then the sequence length dimension of the transposed convolution layer is multiplied by 2 to obtain 304;
[0186] The final output feature map dimension of the fourth upsampling layer is [16, 32, 304].
[0187] (e) Fifth upsampling layer: the input is the output feature map dimension of the fourth upsampling layer [16, 32, 304], and the output feature map dimension is [16, 16, 304];
[0188] After the number of convolution channels is divided by 2, we get 16;
[0189] The final output feature map dimension of the fifth upsampling layer is [16, 16, 304].
[0190] (f) Sixth upsampling layer: The input is the output feature map dimension of the fifth upsampling layer [16, 16, 304], and the output feature map dimension is [16, 1, 304].
[0191] The sixth upsampling layer is a single convolutional layer, and the number of channels is reduced from 16 to 1.
[0192] In the present invention, convolution can change the number of channels. There are multiple changes in the number of channel dimensions in the present invention, namely: 1 dimension is increased to 32, the number of channels remains unchanged, the number of channels is multiplied by 2, the number of channels is divided by 2, and 16 is reduced to 1.
[0193] (1.2) Construct an encoder module for extracting local features, which stacks 5 layers of convolutional neural network layers.
[0194] The encoder module is a downsampling structure, including five downsampling layers, where:
[0195] The first downsampling layer includes a convolutional layer with a stride of 1, layer normalization, and PReLU activation. The convolutional layer increases the number of channels of the input feature map from 1 to 32 and outputs it to the second downsampling layer.
[0196] The second to fifth downsampling layers include two convolutional layers with a stride of 1 and a maximum pooling layer. Each convolutional layer is followed by layer normalization and PReLU activation. The first convolutional layer doubles the number of channels of the feature map input to the current layer. The second convolutional layer keeps the number of channels unchanged and halves the sequence length dimension of the feature map input to the current layer through the maximum pooling layer, thus outputting the feature map with the changed number of channels and sequence length dimensions.
[0197] Among them, layer normalization is used to accelerate convergence, and PReLU activation introduces nonlinearity to enhance the sensitivity of the encoder module to subtle changes in local features.
[0198] As shown in Table 1, the first downsampling layer includes a convolution combination, which includes a convolution layer, layer normalization, and PReLU activation. The input sample feature map dimension [16, 1, 304] undergoes one convolution operation, one layer normalization, and one PReLU activation operation, and the output feature map dimension is [16, 32, 304], which is used as the input of the second downsampling layer.
[0199] The second downsampling layer includes two convolution combinations and a maximum pooling layer in sequence. The convolution kernel size is 31×1 (the step size is 1 and the padding is 15). The dimension of the output signal feature map of the second downsampling layer is [16, 64, 152].
[0200] From the second to the fifth downsampling layers, the input feature map first undergoes two one-dimensional convolution combination operations to extract features, and the convolution kernel size is 31×1 (step size is 1, padding is 15), and then it is input to the maximum pooling layer (pooling window size is 2×2) for downsampling;
[0201] Exemplarily, the data batch size of the input ECG-BCG mapping model is 16, that is, B=16, the sequence length is 304 data points, that is, L=304, the input feature map dimensions of the first to fifth downsampling layers of the encoder module are [16, 1, 304], [16, 32, 304], [16, 64, 152], [16, 128, 76], [16, 256, 38], and the dimension of the output feature map of the fifth layer of the final encoding is [16, 512, 19];
[0202] In [16,1,304], 16 is the batch size, 1 is the number of channels, and 304 is the signal sequence length, which is the number of data points.
[0203] In this step, the first to fifth downsampling layers extract the local features of the signal more accurately, mainly using convolution operations to extract the local features of the ECG and the corresponding BCG.
[0204] The first to fifth downsampling layers extract local features of the signal, mainly through the following aspects:
[0205] ① Convolution kernel size: The convolution kernel size used by the encoder module is 31×1, which means that the convolution operation is only performed within a very small local window of ECG or BCG, which can capture local signal changes and features;
[0206] ② Convolutional layer stacking: The encoder is composed of multiple convolutional layers, each layer further refines the feature extraction based on the previous layer; each convolutional layer focuses on extracting the features of a local area of the input signal;
[0207] ③ Step size and padding: The step size in the convolution operation is 1 and the padding is 15, which means that the convolution kernel only slides one unit on the input signal. At the same time, padding ensures that the convolution operation can cover the boundary area of the input signal, enhancing the ability to extract local features;
[0208] ④ Downsampling: Downsampling through the maximum pooling layer reduces the dimension of the feature map while increasing the number of channels; this operation helps reduce the spatial redundancy of the data while retaining important local features;
[0209] ⑤ Change in feature map dimension: The dimension of the encoder's output feature map gradually decreases, indicating that the model gradually refines from large-scale local features to smaller-scale local features in the process of feature extraction;
[0210] ⑥PReLU activation function: The use of PReLU activation function provides nonlinear transformation for the extraction of local features and enhances the model's ability to express local features;
[0211] The encoder module can effectively extract local features from the cardiac impact signal and the corresponding ECG, providing a basis for subsequent ECG-BCG mapping and abnormal heart beat classification, which is crucial for understanding the mechanical activity of the heart and diagnosing cardiac pathology.
[0212] (1.3) Construct a decoder module that integrates local features and global features, and stack 6 layers of convolutional neural network layers in sequence.
[0213] The decoder module is an upsampling structure, including six upsampling layers, as follows:
[0214] The first upsampling layer includes two convolutional layers with a stride of 1 and a transposed convolutional layer. Each convolutional layer with a stride of 1 is followed by layer normalization and PReLU activation. The two convolutional operations with a stride of 1 keep the number of channels unchanged. The transposed convolutional layer is used to halve the number of channels and double the sequence length to achieve spatial expansion and upsampling of features.
[0215] The second to fourth upsampling layers include two convolution layers with a step size of 1 and a transposed convolution layer in sequence. Each convolution layer with a step size of 1 is followed by layer normalization and PReLU activation. The first convolution layer with a step size of 1 first halves the number of channels of the feature map input to the current layer, the second convolution layer with a step size of 1 keeps the number of channels unchanged, and then uses a transposed convolution layer to halve the number of channels and double the sequence length; the input of the second upsampling layer and the output of the fourth downsampling layer, the input of the third upsampling layer and the output of the third downsampling layer, and the input of the fourth upsampling layer and the output of the second downsampling layer are sequentially skip-connected to fuse the downsampled local features and the upsampled global features; the second to fourth upsampling layers respectively output the feature maps with changed channel numbers and sequence lengths to the next layer for upsampling;
[0216] The fifth upsampling layer includes two convolutional layers with a stride of 1 and a transposed convolutional layer. Each convolutional layer with a stride of 1 is followed by layer normalization and PReLU activation. The first convolutional layer with a stride of 1 reduces the number of channels by half to refine the feature representation. The second convolutional layer with a stride of 1 keeps the number of channels unchanged to further extract and fuse the downsampled and upsampled features.
[0217] The sixth upsampling layer uses a single convolutional layer to reduce the number of channels from 16 to 1, maps the decoded feature map back to the dimension of the feature map input to the encoder module, and outputs the BCG mapped by the ECG.
[0218] The first upsampling layer is a deconvolution layer, which includes two convolution combinations and a transposed convolution layer in sequence. The output feature map of the fifth encoding layer is used as the input feature map of the first decoding layer. After two one-dimensional convolution combination operations, the convolution kernel size is 31×1 (the step size is 1 and the padding is 15), and then the transposed convolution layer operation is performed to obtain the first upsampling result.
[0219] The local feature map dimension [16,512,19] output by the fifth downsampling layer is input to the first upsampling layer. The first upsampling layer outputs the feature map dimension [16,256,38] of the first upsampling result as the input of the second upsampling layer.
[0220] The second to fourth upsampling layers are feature fusion deconvolution layers;
[0221] The second to fourth upsampling layers include two convolution combinations and one transposed convolution layer respectively; the convolution kernel of the first convolution combination is 31×1, the step size is 1, the padding is 15, and the channel is ÷ 2 (the number of channels is half of the first decoding layer); the convolution layer of the second convolution combination is consistent with the first convolution combination; the number of channels of the transposed convolution layer is half of the number of channels of the convolution combination, and the dimension is 2 times.
[0222] The fifth upsampling layer is composed of two convolution combinations. The output feature map of the fourth upsampling layer is used as the input of the fifth upsampling layer. The convolution kernel of the first convolution combination is 31×1, the step size is 1, the padding is 15, and the number of channels is half of the number of channels of the fourth upsampling layer. The convolution parameters of the second convolution combination are exactly the same as those of the first convolution combination.
[0223] The sixth upsampling layer is a single convolutional layer with a convolution kernel size of 31×1 (step size of 1, padding of 15), and the number of channels is changed from 16 to 1. The multi-dimensional features are restored to a feature map sequence output with the same length as the encoder module input. The output feature map sequence is the preprocessed BCG corresponding to the ECG mapping;
[0224] The dimensions of the input feature maps of each of the six upsampling layers of the decoder module are [16,512,19], [16,256,38], [16,128,76], [16,64,152], [16,32,304], [16,16,304], respectively. After a single convolution in the last upsampling layer, the dimension of the feature map of the final output ECG is [16,1,304].
[0225] Through the layer-by-layer upsampling and transposed convolution operations of the decoder module, the local features extracted in the encoder are directly fused with the global features in the decoder using skip connections. Finally, the decoder maps the local features of the encoder back to the original signal space dimensions and outputs the preprocessed BCG corresponding to the ECG.
[0226] (2) Using the first training data set to train the ECG-BCG mapping model until the loss function converges to obtain a trained ECG-BCG mapping model.
[0227] Loading the first training data set into the ECG-BCG mapping model for training;
[0228] A fixed learning rate is adopted, an MSE mean square error loss function is used for forward propagation, and an Adam optimizer is used for back propagation, and the ECG-BCG mapping model parameters are continuously adjusted to minimize the loss function until the loss function converges to obtain a trained ECG-BCG mapping model.
[0229] (a) Construct the loss function, determine the optimizer and hyperparameters, input the training set and validation set, and train the ECG-BCG model parameters;
[0230] (b) Use the MSE mean square error loss function for forward propagation, as shown in formula (3)
[0231]
[0232] N is the total number of points contained in each heart beat signal sequence after non-overlapping segmentation, that is, the length of the signal sequence, which is 304 in this embodiment. i is the amplitude-normalized cardiac impulse signal value, It is the heart attack signal value obtained after ECG-BCG mapping.
[0233] (c) The Adam optimizer is used for back propagation, and the initial learning rate is set to 1e -4 , that is, 0.0001, a fixed learning rate is used, the batch size is set to 16, and the weight decay is set to 1e -5 , that is, 0.00001, and the preset maximum training round is 150;
[0234] Exemplarily, the software framework used in the present invention to train the ECG-BCG mapping model is PyTorch 1.7.1 based on Python 3.8 language, the operating system is Ubuntu 20.0.4, the CUDA version is 11.3, and the hardware computing platform is a server equipped with an Nvidia RTXA40 graphics card;
[0235] (d) Train the network model and optimize the hyperparameters using the back propagation algorithm on the training set and validation set until the loss function converges and the training is completed;
[0236] First, use the training set to train for 10 rounds, and then use the validation set to verify for 1 round; then use the training set to train for 10 rounds, and then use the validation set to verify for 1 round;
[0237] Until the loss function converges, the validation set is used for validation to obtain the trained ECG-BCG mapping model, and the model weight parameters are saved. The weight parameters of the trained mapping model are loaded into the constructed ECG-BCG mapping model.
[0238] Step S223, specifically.
[0239] Acquire ECG data from a second public data set and perform preprocessing, input the trained ECG-BCG mapping model, obtain corresponding BCG data, and use the corresponding ECG heartbeat type in the second public data set as a label to form the second training data set;
[0240] Loading the second training data set into the brain-like classification model for training until a maximum number of iterations is reached;
[0241] The second public data set is an electrocardiogram (ECG) signal data set published by MIT-BIH, including ECG signals and corresponding heart beat types.
[0242] ECG signals and corresponding heart beat types are obtained from a second public dataset.
[0243] (1) Obtain ECG in raw format and corresponding labels (i.e., heartbeat type) and perform data preprocessing;
[0244] Exemplarily, an ECG in .dat format and its corresponding heartbeat type are obtained, where the heartbeat type is the type of abnormal heart rate disease.
[0245] In this embodiment, the second public data set comes from the ECG signal data set published by MIT-BIH, and the length of the initial signal sequence is 650,000;
[0246] Each ECG sequence data in the public dataset corresponds to the type of abnormal heart rate disease. The ECG data in the public dataset corresponds to the heartbeat type, and the heartbeat type is marked by the doctor.
[0247] Using a loop function, the ECG is segmented into a sequence set of 304 data points in length without overlap based on the position of the first R peak of the ECG.
[0248] Exemplarily, the ECG segments after non-overlapping segmentation are saved as a numpy two-dimensional tensor format based on Python 3.8, and the feature map size is [2138, 304]. The ECG data after non-overlapping segmentation are normalized.
[0249] (2) After normalizing the ECG after non-overlapping segmentation, input the trained ECG-BCG mapping model to obtain BCG of the same scale, map the BCG and the corresponding ECG heartbeat type as samples of the second training data set, and form the second training data set; divided into training set, validation set and test set according to the preset ratio. This step effectively expands the number of BCG samples.
[0250] Step S224, specifically.
[0251] (1) Construct a brain-like classification model based on pulse neural network.
[0252] like Figure 5 As shown, the brain-like classification model is built based on a spiking neural network, which includes a static convolution layer, a channel attention layer, and a fully connected classification module in sequence;
[0253] The static convolution layer includes a one-dimensional convolution layer Conv1d, a LIFNode brain-like activation layer and a pooling layer; the one-dimensional convolution layer Conv1d is used for channel expansion and feature extraction. After the input feature map is convolved by Conv1d and activated by LIFNode brain-like, the number of channels is expanded from 1 to 4, and the sequence length is reduced from 304 to 284; then the pooling layer downsamples the feature map with expanded channels and reduced sequence length and outputs it, which is set to X;
[0254] The channel attention layer includes a channel weight branch and a transfer input branch;
[0255] The channel weight branch is combined with the AdaptiveMaxPool1d function and the custom convolution to output the attention values of different channels, which are set to A;
[0256] The transfer input branch first performs a multiplication operation X×A, then passes through a convolution layer and a pooling layer for downsampling, and then outputs a feature map of a three-dimensional tensor to the fully connected classification module for classification;
[0257] The fully connected classification module includes a Flatten layer and a linear layer. The feature map of the input three-dimensional tensor is expanded into a two-dimensional tensor through the Flatten function, and then passes through the linear layer to obtain the classification prediction probability of the heartbeat type; the heartbeat classification result is obtained based on the classification prediction probability.
[0258] After the linear layer, the output result is the classification prediction probability result at a certain moment, and the entire brain-like classification model network runs the brain-like classification model training process from 0 to T at the preset brain-like time step T (T is an integer);
[0259] From 0 to T-1 times; each time the linear layer outputs a classification prediction probability result; then the average of the classification prediction probabilities of T brain-like time steps is taken, and the average is used as the classification prediction probability of the heartbeat type.
[0260] Table 2: Structural parameters of brain-like classification model
[0261]
[0262] like Figure 5 As shown:
[0263] (a) The first layer of the static convolution layer is a one-dimensional convolution layer Conv1d. The input data is the output feature map [16, 1, 304] of the sixth upsampling layer. The input data is channel-expanded after convolution. The convolution kernel size is 21×1, the step size is 1, and the padding is 10. It is expanded from 1 to 4, and the sequence length dimension is reduced from 304 to 284. The output feature map dimension is [16, 4, 284];
[0264] After passing through the LIFNode brain-like activation function layer, it is downsampled through a one-dimensional pooling layer with a pooling window size of 2×1 and a sequence length dimension divided by 2; the final output feature map dimension of the static convolution layer is [16, 4, 142].
[0265] For example, assuming that the data batch size of the input model is 16, that is, B=16, and the sequence length is 300, that is, L=300, the input feature map dimensions of each static convolution layer are [16, 1, 304], [2, 4, 284], and the final output feature map dimensions after the pooling layer are [16, 4, 142];
[0266] The LIFNode brain-like activation layer, also known as the brain-like activation module, has a calculation mechanism as shown in formula (4):
[0267]
[0268] Where T is the preset brain-like time step, V[T] and V[T-1] are the brain-like neuron membrane potentials at brain-like time steps T and T-1, respectively, Y[T] is the feature map output by Conv1d convolution, τ m is the preset membrane time constant, V reset is the reset potential;
[0269] If V[T] reaches the preset discharge threshold V threshold , the membrane potential is reset to zero, and V[T] is input into the substitute function of the step function for back propagation; the substitute function is shown in formula (5):
[0270]
[0271] Otherwise, if V[T] does not reach the preset discharge threshold V threshold , the membrane potential of brain-like neurons remains V[T].
[0272] When T = 0, brain-like neurons do not discharge but only charge;
[0273] When T>0, brain-like neurons both discharge and charge.
[0274] Exemplarily, the membrane time constant τ m The preset value is 2, which resets the potential V reset The preset value is 0, the discharge threshold V threshold The default is 1.0.
[0275] For the membrane potential V[T], the actual discharge process can be expressed as a discrete step function, as shown in formula (6):
[0276] H(V(T)-V threshold )Formula (6)
[0277] Among them, H is the Heavidide step function. The step function is not differentiable. In order to calculate the back-propagation gradient, an alternative function σ(V[T]) is introduced;
[0278] The arctan function in the substitution function σ(V[T]) provides a smooth approximation when V[T] is close to the preset discharge threshold V threshold , the output of the substitution function is close to 1 or 0, and the substitution function is differentiable near the preset discharge threshold.
[0279] During the calculation of the LIFNode brain-like activation layer, the dimension of the input feature map remains unchanged.
[0280] LIFNode is the size of the brain-like activation layer output.
[0281] LIFNode is a computational model that simulates the firing and resting mechanisms of biological neurons. It reflects the working mechanism of real neurons to a certain extent and has brain-like characteristics.
[0282] The LIFNode activation function module is used to increase the model's sensitivity to the temporal dynamics of ECG signals and improve the model's ability to recognize cardiac activity patterns. The design of the LIFNode brain-like activation layer can avoid the neuron saturation problem that may occur in traditional activation functions (such as Sigmoid or Tanh), thereby maintaining the activity of the network during training. Using the inverse tangent function as a substitute for the step function provides a derivable path for backpropagation, allowing the network to be trained using optimization algorithms such as gradient descent.
[0283] (b) The channel attention layer contains two branches: the channel weight branch and the transfer input branch.
[0284] ① The first branch is the channel weight branch. The input data is the output of the static convolution layer. It is first combined with the AdaptiveMaxPool1d function and the convolution to obtain a feature map with a dimension of [16, 4, 142], which is set to A.
[0285] Among them, the convolution combination is a custom convolution combination structure, which includes convolution (channel number 4→1) + ReLU activation function + convolution (channel number 1→4) + Sigmoid activation, a total of four layers. The custom convolution combination does not change the number of channels, and the final number is still [16,4,142].
[0286] The custom convolution combination can be seen as an implementation of an attention mechanism. Through this structure, the network can learn the importance or weight of different channels, thereby focusing on features that are more important to the current task;
[0287] Convolution (channel number 4 → 1): compress the 4-channel information of each position into 1 channel, which can be regarded as a selection process, and the network autonomously learns which channels are important;
[0288] Use formula (2) to calculate the sequence length dimension
[0289] ReLU activation function: introduces nonlinearity, enabling the model to learn and simulate more complex feature transformations;
[0290] Convolution (channel number 1→4): The compressed information is expanded back to 4 channels, but the weight of each channel has been adjusted at this time;
[0291] Sigmoid activation: ensures that the output is between 0 and 1, which can be regarded as a normalization of the channel weight;
[0292] The custom convolution combination does not change the data dimension. The number of output channels is the same as the number of input channels, which maintains the channel number dimension of the original data and facilitates fusion with the original data or the output of other branches.
[0293] The final output feature map dimension of the channel weight branch is [16, 4, 142].
[0294] ②The second branch is the input transfer branch, which includes weight multiplication, convolution layer and pooling layer in sequence.
[0295] The original input and the extracted weights are multiplied by X×A;
[0296] The result of the operation is then passed through a convolution layer with a convolution kernel size of 21×1 (step size of 1, padding of 10) and a pooling layer for downsampling (pooling window size of 2×1), and the output is [16, 8, 61], which is input to the fully connected classification module for classification;
[0297] The output feature map dimension of the channel weight branch is [16, 4, 142], which is passed as input to the input branch.
[0298] The dimension of the output feature map of the first layer of the input branch remains unchanged, which is still [16, 4, 142];
[0299] In the second layer Conv1d, the number of channels is multiplied by 2, the sequence length dimension is reduced to 122, and the output feature map dimension is [16, 8, 122];
[0300] In the third pooling layer, the number of channels remains unchanged, the sequence length dimension is halved, and the output feature map dimension is [16, 8, 61].
[0301] (c) The fully connected classification module includes a Flatten layer function and a linear layer. The input [16,8,61] is first flattened into one dimension [16,488] by the Flatten function, and then enters the linear layer to obtain [16,5] to obtain the heartbeat classification probability. The heartbeat classification result is obtained based on the heartbeat classification probability.
[0302] (2) Use the second training data set to train a brain-like classification model.
[0303] The second training data set is loaded into the brain-like classification model for training until a maximum number of iterations is reached.
[0304] Construct the loss function, determine the optimizer and hyperparameters, input the training set and validation set, train the network model parameters; use the MSE mean square error loss function for forward propagation:
[0305] The Adam optimizer is used for back propagation, and the initial learning rate is set to 1e-4 , i.e. 0.0001, a fixed learning rate is used, the batch size is set to 16, the time step of the spiking neural network is 7, the time constant is 2, the pulse voltage threshold is 1, the reset potential after discharge is 0, and the total maximum training iteration round is set to 150;
[0306] The training is performed until the maximum iteration round to obtain a trained brain-like classification model, and the parameters of the brain-like classification model when the classification category accuracy in the verification set is the highest are saved as the parameters of the trained brain-like classification model.
[0307] Exemplarily, the software framework used for the experimental training network of the present invention is PyTorch1.7.1 based on Python3.6 language, the operating system is Ubuntu 20.0.4, the CUDA version is 11.3, and the hardware computing platform is a server equipped with an NvidiaRTXA40 graphics card;
[0308] The constructed brain-like classification model is loaded with the trained weight parameters, and the pre-processed BCG signal to be tested is input to obtain the predicted heartbeat type. The heartbeat type result is one of the five predicted heartbeat types described above.
[0309] In summary, the BCG classification prediction method based on the brain-like model in the embodiment of the present invention has the following beneficial effects:
[0310] 1. Use piezoelectric cable sensors to collect BCG signals, realize non-contact heart rate monitoring, non-invasively collect BCG signals in real time, improve patient comfort, and be suitable for long-term continuous monitoring;
[0311] 2. The brain-like model based on spiking neural network is adopted. Through the combination of static convolution layer, channel attention layer and fully connected classification module, the extraction and classification capabilities of BCG signal features are enhanced, and the accuracy of heartbeat type classification is improved. Through LIFNode brain-like activation module and channel attention mechanism, the accuracy of heartbeat type classification is improved;
[0312] 3. Through the optimized brain-like classification model structure and classification method, the delay in real-time monitoring is reduced, making the classification and prediction of BCG signals faster, which helps to achieve rapid diagnosis and response and reduce real-time delay;
[0313] 4. This application effectively integrates and utilizes public data sets to construct a comprehensive and accurately labeled training data set. Through the training of ECG-BCG mapping model and brain-like classification model, this application better utilizes the mechanical information contained in BCG and can more effectively detect cardiac mechanical movement. The heart-brain classification model has broad application prospects in clinical diagnosis, long-term monitoring and personalized treatment.
[0314] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A BCG classification prediction method based on a brain-like model, characterized in that: The steps include: Step S1, real-time acquisition of BCG signals at consecutive moments and preprocessing to obtain preprocessed BCG signals; Step S2, input the preprocessed BCG signal into the trained brain-like classification model for identification to obtain the predicted heartbeat type; wherein the brain-like classification model is constructed based on a pulse neural network, and sequentially includes a static convolution layer, a channel attention layer and a fully connected classification module; the static convolution layer is used for feature extraction and channel expansion; the channel attention layer is used for feature selection and enhancement; the fully connected classification module is used for the final classification prediction.
2. The method according to claim 1, characterized in that: The pre-processed BCG signal is input into the trained brain-like classification model for identification to obtain the predicted heartbeat type, including: The preprocessed BCG signal is sequentially input into the one-dimensional convolution layer Conv1d, the LIFNode brain-like activation layer and the pooling layer of the static convolution layer; the one-dimensional convolution layer Conv1d is used for channel expansion and feature extraction, and the input feature map is sequentially convolved by Conv1d and activated by LIFNode brain-like, and the number of channels is expanded and the sequence length is reduced in dimension; the pooling layer downsamples the feature map with expanded channels and reduced sequence length and outputs it, which is set to X; Input X into the channel attention layer to obtain a three-dimensional tensor feature map; The three-dimensional tensor feature map is input into the fully connected classification module, which includes a Flatten flattening layer and a linear layer. The input three-dimensional tensor feature map is expanded into a two-dimensional tensor by the Flatten function, and then passes through the linear layer to obtain the classification prediction probability of the heartbeat type.
3. The method according to claim 2, characterized in that: The channel attention layer includes a channel weight branch and a transfer input branch; The channel weight branch is combined with the custom convolution function through the AdaptiveMaxPool1d function to output the channel attention value, which is set to A; The input transfer branch first performs a multiplication operation of X and A, then passes through a convolution layer and a pooling layer for down-sampling, and then outputs a feature map of a three-dimensional tensor.
4. The method according to claim 1, characterized in that: Training brain-like classification models, including: Constructing a first training data set including preprocessed ECG and corresponding BCG; Using the first training data set to train the ECG-BCG mapping model until the loss function converges to obtain a trained ECG-BCG mapping model; Based on the trained ECG-BCG mapping model, construct a second training data set for the brain-like classification model; wherein the second training data set includes the heartbeat types of BCG and corresponding ECG; The brain-like classification model is trained using the second training data set, and a trained brain-like classification model is obtained after reaching a maximum number of iteration rounds.
5. The method according to claim 4, characterized in that: An ECG-BCG mapping model is constructed based on the encoding-decoding structure of a U-shaped convolutional network, including an encoder module and a decoder module; The encoder module is used to downsample the received pre-processed ECG to extract local features and output a feature map matrix representing the local features; The decoder module restores the spatial dimension through the transposed convolution layer, and fuses the local features extracted by the encoder module with the global features sampled by the decoder module through skip connections, restores them to the original dimensional space, and outputs the BCG corresponding to the preprocessed ECG; Among them, the feature map matrix is represented as a three-dimensional tensor, and the three dimensions are batch size, number of channels, and sequence length.
6. The method according to claim 5, characterized in that: The encoder module is a downsampling structure, including five downsampling layers, where: The first downsampling layer includes a convolutional layer with a stride of 1, layer normalization, and PReLU activation. The convolutional layer increases the number of channels of the input feature map from 1 to 32 and outputs it to the second downsampling layer. The second to fifth downsampling layers include two convolutional layers with a stride of 1 and a maximum pooling layer. Each convolutional layer is followed by layer normalization and PReLU activation. The first convolutional layer doubles the number of channels of the feature map input to the current layer. The second convolutional layer keeps the number of channels unchanged and halves the sequence length dimension of the feature map input to the current layer through the maximum pooling layer, thus outputting the feature map with the changed number of channels and sequence length dimensions. Among them, layer normalization is used to accelerate convergence, and PReLU activation introduces nonlinearity to enhance the sensitivity of the encoder module to subtle changes in local features.
7. The method according to claim 6, characterized in that: The decoder module is an upsampling structure, including six upsampling layers, as follows: The first upsampling layer includes two convolutional layers with a stride of 1 and a transposed convolutional layer. Each convolutional layer with a stride of 1 is followed by layer normalization and PReLU activation. The two convolutional operations with a stride of 1 keep the number of channels unchanged. The transposed convolutional layer is used to halve the number of channels and double the sequence length to achieve spatial expansion and upsampling of features. The second to fourth upsampling layers include two convolution layers with a stride of 1 and a transposed convolution layer in sequence. Each convolution layer with a stride of 1 is followed by layer normalization and PReLU activation. The first convolution layer with a stride of 1 first halves the number of channels of the feature map of the current layer input, the second convolution layer with a stride of 1 keeps the number of channels unchanged, and then uses a transposed convolution layer to halve the number of channels and double the sequence length; the input of the second upsampling layer and the output of the fourth downsampling layer, the input of the third upsampling layer and the output of the third downsampling layer, and the input of the fourth upsampling layer and the output of the second downsampling layer are sequentially skip-connected to fuse the downsampled local features and the upsampled global features; The second to fourth upsampling layers output the feature maps with changed channel numbers and sequence lengths to the next layer for upsampling; The fifth upsampling layer includes two convolutional layers with a stride of 1 and a transposed convolutional layer. Each convolutional layer with a stride of 1 is followed by layer normalization and PReLU activation. The first convolutional layer with a stride of 1 reduces the number of channels by half to refine the feature representation. The second convolutional layer with a stride of 1 keeps the number of channels unchanged to further extract and fuse the downsampled and upsampled features. The sixth upsampling layer uses a single convolutional layer to reduce the number of channels from 16 to 1, maps the decoded feature map back to the dimension of the feature map input to the encoder module, and outputs the BCG mapped by the ECG.
8. The method according to claim 7, characterized in that: The first training data set is obtained by preprocessing the original signal sequences of ECG and corresponding BCG data from the first public data set, including: Taking the first R peak of the original signal sequence of the ECG as the starting point, and the J peak corresponding to the timestamp of the first R peak in the original signal sequence of the BCG as the starting point, non-overlapping segmentation is performed with preset sequence lengths respectively; The data points before the first R peak in ECG and the first J peak corresponding to BCG, as well as the data points that are less than the preset sequence length after segmentation, are discarded; Normalize the amplitudes of the segmented ECG and BCG; The normalized ECG and the corresponding BCG constitute each sample in the first training data set; Among them, the first public dataset is the BED-BASED BALLISTOCARDIOGRAPHY DATASET; ECG and BCG correspond one to one based on timestamps.
9. The method according to claim 8, characterized in that: Loading the first training data set into the ECG-BCG mapping model for training; A fixed learning rate is adopted, an MSE mean square error loss function is used for forward propagation, and an Adam optimizer is used for back propagation, and the ECG-BCG mapping model parameters are continuously adjusted to minimize the loss function until the loss function converges to obtain a trained ECG-BCG mapping model; Acquire ECG data from a second public data set and perform preprocessing, input the trained ECG-BCG mapping model, obtain corresponding BCG data, and use the corresponding ECG heartbeat type in the second public data set as a label to form the second training data set; Loading the second training data set into the brain-like classification model for training until a maximum number of iterations is reached; The second public data set is an electrocardiogram (ECG) signal data set published by MIT-BIH, including ECG signals and corresponding heart beat types.
10. The method according to claim 2, characterized in that: The calculation mechanism of the LIFNode brain-like activation layer is: Where T is the preset brain-like time step, V[T] and V[T-1] are the brain-like neuron membrane potentials at brain-like time steps T and T-1, respectively, Y[T] is the feature map output by Conv1d convolution, τ m is the preset membrane time constant, V reset is the reset potential; If V[T] reaches the preset discharge threshold V threshold , the membrane potential is reset to zero, and V[T] is input into the substitute function of the step function for back propagation; the substitute function is as follows: Otherwise, if V[T] does not reach the preset discharge threshold V threshold , the membrane potential of brain-like neurons remains V[T].
