Heart sound signal classification method based on end-to-end lightweight convolutional neural network
Through a method based on an end-to-end lightweight convolutional neural network, combined with short-time Fourier transform and FPGA hardware acceleration, the problems of low accuracy and low intelligence of heart sound processing in the existing technology are solved, and efficient heart sound signals are achieved. Classification and accuracy improvements.
Patent Information
- Application Number
- CN202211370334.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-03
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-11-03
AI Technical Summary
The existing technology lacks lightweight heart sound processing methods and related hardware equipment, resulting in low heart sound processing accuracy, low intelligence, cumbersome processes, and difficulty in effectively classifying heart sound signals.
A heart sound signal classification method based on an end-to-end lightweight convolutional neural network is adopted. Through preprocessing and feature extraction, the original heart sound signal is downsampled and segmented, and short-time Fourier transform is used to extract features. The data is then randomly divided into The training set, verification set and test set are trained and optimized through multi-dimensional convolutional neural network, and finally deployed on the FPGA platform for hardware acceleration.
It achieves efficient and fast heart sound signal classification, improves classification accuracy, reduces power consumption, makes full use of the high parallelism and high throughput of the FPGA platform, and is suitable for deployment in wearable devices.
Smart Images

Figure CN115581475B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of physiological signal processing and digital integrated circuit chip optimization, and in particular to a heart sound signal classification method based on an end-to-end lightweight convolutional neural network, an FPGA hardware acceleration method, an electronic device and a storage medium. Background Art
[0002] Cardiovascular disease remains the leading cause of morbidity and mortality worldwide, and cardiac auscultation remains the most common and economical non-invasive screening method for heart disease. Heart sounds are a diagnostic signal that doctors have long used. Although auscultation has been widely used, it is still a difficult technique that requires sufficient experience. It is difficult to effectively master auscultation techniques. Automatic auscultation algorithms can simplify the mastery of auscultation and reduce the errors that may be caused by subjective judgment, significantly improving the auscultation level of users who lack auscultation experience.
[0003] However, the prior art lacks lightweight heart sound processing methods and related hardware equipment. Existing heart sound processing methods and related hardware equipment have problems such as low accuracy, low intelligence, and complicated processes. Summary of the invention
[0004] In view of the above problems, the present invention provides a heart sound signal classification method based on an end-to-end lightweight convolutional neural network, an FPGA hardware acceleration method, an electronic device and a storage medium, in order to solve at least one of the above problems.
[0005] According to a first aspect of the present invention, a method for classifying heart sound signals based on an end-to-end lightweight convolutional neural network is provided, comprising:
[0006] Downsampling the original heart sound signal from the database according to the preset signal frequency, and segmenting the downsampled heart sound signal according to the preset duration to obtain a segmented heart sound signal;
[0007] Short-time Fourier transform is used to extract features of the segmented heart sound signal to obtain a multi-dimensional heart sound signal with feature labels;
[0008] According to a preset allocation ratio, the multidimensional heart sound signals with feature labels are randomly divided into a training set, a validation set, and a test set;
[0009] Using a multidimensional convolutional neural network to process a training set, and according to the processing result of the training set, using a loss function and an optimizer to train the parameters of the multidimensional convolutional neural network to obtain a trained multidimensional convolutional neural network, wherein the data dimension processed by the multidimensional convolutional neural network is consistent with the data dimension of the multidimensional heart sound signal with feature labels;
[0010] The trained multidimensional convolutional neural network is used to process the validation set, and the parameters of the trained multidimensional convolutional neural network are adjusted according to the processing result of the validation set to obtain the multidimensional convolutional neural network completed in this round of training;
[0011] According to the preset training rounds, the multidimensional convolutional neural network is cross-optimized and adjusted using the training set and the validation set to obtain a set of trained multidimensional convolutional neural networks;
[0012] The test set is processed by using the trained multidimensional convolutional neural network set, and the test set processing result is input into the preset evaluation index to obtain the score of each trained multidimensional convolutional neural network, and the optimized multidimensional convolutional neural network is obtained according to the score;
[0013] An optimized multi-dimensional convolutional neural network is used to process the heart sound signal from the client, and classification information of the heart sound signal from the client is output.
[0014] According to an embodiment of the present invention, the feature extraction of the segmented processed heart sound signal by using short-time Fourier transform to obtain a multidimensional heart sound signal with feature labels includes:
[0015] Initializing the parameters of the short-time Fourier transform to preset values, wherein the parameters of the short-time Fourier transform include the window length, the step length, and the number of points of the fast Fourier transform;
[0016] Performing fast Fourier transform or discrete Fourier transform on the segmented processed heart sound signal using short-time Fourier transform to obtain frequency domain features of the segmented processed heart sound signal;
[0017] According to the time sequence of the segmented processed heart sound signals, the frequency domain information of the segmented processed heart sound signals is processed to obtain a multi-dimensional heart sound signal with a feature label.
[0018] According to an embodiment of the present invention, the above-mentioned loss function includes a focal loss function, and the optimizer includes an adaptive moment estimation optimizer.
[0019] According to an embodiment of the present invention, the multidimensional convolutional neural network includes a global maximum pooling layer, a fully connected output layer and a multi-layer convolutional layer, wherein each convolutional layer includes a plurality of filters based on a neural unit description domain.
[0020] According to an embodiment of the present invention, the above-mentioned preset evaluation indicators include accuracy, sensitivity and specificity.
[0021] According to an embodiment of the present invention, the above accuracy is determined by formula (1):
[0022]
[0023] The above sensitivity is determined by formula (2):
[0024]
[0025] The above specificity is determined by formula (3):
[0026]
[0027] Among them, Accuracy is the accuracy, which indicates the proportion of all samples in the sample station that are predicted correctly; Sensitivity is the sensitivity, which indicates the proportion of all positive examples that are classified correctly; Specificity is the specificity, which indicates the proportion of all negative examples that are classified correctly; TN is the true negative, which means the prediction is negative and the actual result is negative; FP is the false positive, which means the prediction is positive and the actual result is negative; FN is the false negative, which means the prediction is negative and the actual result is positive.
[0028] According to an embodiment of the present invention, the above-mentioned heart sound signal classification method further includes:
[0029] The parameters of the optimized multi-dimensional convolutional neural network are stored in the BRAM of the FPGA, and the optimized multi-dimensional convolutional neural network and the heart sound signal processed by the short-time Fourier transform are stored in the data buffer through the data bus;
[0030] Inputting the heart sound signal stored in the data buffer into the convolution layer of the multidimensional convolutional neural network through a shift register for convolution processing, and outputting the convolution processing result;
[0031] The convolution processing result is buffered by the dual-port BRAM and stored according to the preset data structure;
[0032] The convolution processing results are used to perform global maximum pooling calculations and fully connected layer calculations to obtain the classification results of the heart sound signal.
[0033] According to a second aspect of the present invention, a heart sound signal classification device based on FPGA is provided, which is used to implement the above-mentioned heart sound signal classification method based on end-to-end lightweight convolutional neural network, and is characterized by comprising:
[0034] On-chip storage buffer processing unit for buffering and storing heart sound signals and optimized multi-dimensional convolutional neural network;
[0035] A convolutional neural network hardware acceleration computing unit, used to process the heart sound signal through a multi-dimensional convolutional neural network to obtain classification information of the heart sound signal;
[0036] A control unit is used to control the flow of heart sound signals and intermediate processing results.
[0037] According to a third aspect of the present invention, there is provided an electronic device, comprising:
[0038] one or more processors;
[0039] a storage device for storing one or more programs,
[0040] When one or more programs are executed by one or more processors, the one or more processors execute a heart sound signal classification method based on an end-to-end lightweight convolutional neural network.
[0041] According to a fourth aspect of the present invention, there is provided a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute a heart sound signal classification method based on an end-to-end lightweight convolutional neural network.
[0042] The above-mentioned heart sound signal classification method based on end-to-end lightweight convolutional neural network provided by the present invention preprocesses and extracts features of the original heart sound signals in the database, and randomly divides the processed original heart sound signals into training sets, verification sets and test sets, and uses the training sets, verification sets and test sets to perform training optimization, verification adjustment and test screening on the lightweight convolutional neural network, and uses the obtained final lightweight convolutional neural network to process the heart sound signals from the client, and outputs the classification information of the client heart sound signals; at the same time, the heart sound signal classification method based on end-to-end lightweight convolutional neural network provided by the present invention can be deployed on FPGA (Field Programmable Gate Array, programmable array logic), so as to give full play to the high parallelism, high throughput and low power consumption characteristics of the FPGA platform, and efficiently and quickly realize the light convolutional neural network reasoning acceleration under low power consumption. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 is a flowchart of a heart sound signal classification method based on an end-to-end lightweight convolutional neural network according to an embodiment of the present invention;
[0044] Figure 2 is a flow chart of obtaining a multi-dimensional heart sound signal with feature labels by using short-time Fourier transform according to an embodiment of the present invention;
[0045] Figure 3 is a structural schematic diagram of a multi-dimensional convolutional neural network hardware acceleration method based on FPGA according to an embodiment of the present invention;
[0046] Figure 4 is a schematic diagram of the system structure of a heart sound signal classification device based on FPGA according to an embodiment of the present invention;
[0047] Figure 5 is a schematic diagram of a multi-dimensional convolutional neural network structure for a heart sound signal classification method according to another embodiment of the present invention;
[0048] Figure 6 is a schematic diagram of the influence of short-time Fourier transform parameters on a heart sound signal classification method according to another embodiment of the present invention;
[0049] Figure 7 A schematic diagram showing the effect of the number of multi-dimensional convolutional neural network filters on a heart sound signal classification method according to another embodiment of the present invention;
[0050] Figure 8 is a schematic diagram showing the influence of the Focal loss parameters on the heart sound signal classification method according to another embodiment of the present invention;
[0051] Fig. 9 is a schematic diagram of the impact of a voting threshold heart sound signal classification method according to another embodiment of the present invention;
[0052] Fig.10 A block diagram of an electronic device suitable for implementing a heart sound signal classification method based on an end-to-end lightweight convolutional neural network according to an embodiment of the present invention is schematically shown. DETAILED DESCRIPTION
[0053] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings.
[0054] The heart sound processing process is roughly divided into four parts: preprocessing of heart sound signals, heart sound segmentation, feature extraction for heart sound classification, and heart sound classification.
[0055] The first part is the preprocessing of heart sound signals, including signal filtering and noise reduction, resampling, and feature extraction of heart sound segmentation. Due to the different algorithm tasks, the features that need to be extracted by heart sound segmentation and heart sound classification algorithms may also be different, so the feature extraction of heart sound segmentation is classified as part of the preprocessing, while the feature extraction of heart sound classification is listed as a separate part. The feature extraction of heart sound segmentation includes time-frequency methods such as Fourier transform, short-time Fourier transform, S transform, wavelet analysis, Wigner-Ville distribution, Choi–Williams distribution, short-time modified Hilbert transform, and Mel spectrum cepstral coefficients, as well as nonlinear features such as high-order statistics, nonlinear fractal complexity, entropy and chaos theory, as well as time domain features such as peak-to-peak interval, peak value, and peak half-width, in addition to empirical mode decomposition, variational mode decomposition, Shannon energy, Hilbert transform, and other methods. A special heart sound segmentation feature is based on the gold standard of heart sound segmentation, that is, the R peak and T wave end positions in the ECG signal correspond to the positions of S1 and S2 respectively. However, this method requires the equipment to synchronously collect ECG signals, and its scope of use is limited.
[0056] The second part is the segmentation of heart sounds. There are generally two types of heart sound segmentation. One is a detailed heart sound segmentation algorithm, which aims to divide the entire heart sound signal into cardiac cycles in the order of the first heart sound, systole, second heart sound, and diastole. This algorithm can not only separate each heartbeat, but also segment different periods within the heartbeat, which is convenient for the next step of the heart sound classification algorithm. The advantage of this approach is that it can be associated with a specific type of heart disease based on the different locations of heart murmurs in the heart sound. The other is that the algorithm based on deep learning can directly perform end-to-end heart sound classification without detailed heart sound segmentation. It only needs to segment the heart sound according to a fixed time length. However, this algorithm currently simply classifies the heart sound as normal or abnormal, and cannot be associated with a specific heart disease. In addition, if this heart sound segmentation method is used, there is no need to extract features for the heart sound segmentation algorithm in the heart sound preprocessing.
[0057] The third part is the feature extraction of heart sound classification, which adopts different processing methods according to the previous steps. The feature extraction method is similar to the feature method used in the heart sound segmentation algorithm. The mainstream methods include time-frequency analysis, wavelet transform, Fourier transform, short-time Fourier transform, empirical mode decomposition, Hilbert transform, Wigner-Ville distribution, etc.
[0058] The fourth part is heart sound classification. The algorithms used in this part are the same as classification tasks in other fields, including support vector machine, hidden Markov model, nearest neighbor method, neural network, decision tree, Bayesian network, naive Bayesian network, Gaussian mixture model, random forest, etc.
[0059] FPGA (Field Programmable Gate Array), as a semi-custom chip in the field of Application Specific Integrated Circuit (ASIC), combines the high performance of ASIC with the flexibility of general-purpose processor chips and can accelerate the calculation of algorithms through hardware circuits. As a programmable logic device, it can not only meet the system requirements of high performance and low power consumption, but also take into account the low overhead requirements of development time and R&D cost, thus realizing the FPGA platform deployment of heart sound classification neural network.
[0060] However, there is no related technical solution in the prior art involving a heart sound signal classification method and a hardware acceleration method of a lightweight convolutional neural network that achieves an optimal solution between accuracy and lightweight and deployment on an FPGA platform.
[0061] In view of the problems existing in the prior art, the present invention provides a heart sound signal classification method based on an end-to-end lightweight convolutional neural network, an FPGA hardware acceleration method, an electronic device and a storage medium. The heart sound signal classification method includes downsampling the heart sound records of varying lengths, and then randomly dividing the original heart sound signals in the database into training sets, verification sets and test sets, and then segmenting the heart sounds according to a certain time length, and the part that is less than the time length is discarded. Subsequently, each small segment of heart sound is feature extracted using a short-time Fourier transform (STFT), and each segment of the signal becomes a two-dimensional matrix after processing. The matrix is sent to a two-dimensional convolutional neural network (CNN) for training and testing, and finally the original heart sound record is finally judged as a normal heart sound or an abnormal heart sound according to a set threshold, and the classification accuracy is obtained. At the same time, the heart sound network is deployed in an FPGA, and the FPGA-based lightweight heart sound processing convolutional neural network includes an on-chip storage buffer processing unit, a CNN hardware acceleration calculation module, and a central control unit. At the same time, the FPGA hardware acceleration method includes deploying the above-mentioned heart sound signal classification method on the FPGA platform to maximize the use of the existing resources of the FPGA platform, give full play to the high parallelism, high throughput and low power consumption characteristics of the FPGA platform, and efficiently and quickly realize convolutional neural network reasoning acceleration under low power consumption.
[0062] Figure 1 4 is a flowchart of a heart sound signal classification method based on an end-to-end lightweight convolutional neural network according to an embodiment of the present invention.
[0063] like Figure 1 As shown, the above-mentioned heart sound signal classification method based on end-to-end lightweight convolutional neural network includes operations S110 to S180.
[0064] In operation S110, the original heart sound signal from the database is downsampled according to a preset signal frequency, and the downsampled heart sound signal is segmented according to a preset duration to obtain a segmented heart sound signal.
[0065] Since the lengths of the original heart sound signals from the database are inconsistent, the original heart sound signals need to be downsampled to a preset signal frequency (eg, 1000 Hz) to reduce the computational complexity of subsequent operations.
[0066] The original heart sound signal after downsampling is segmented to ensure that the duration of each segment of the heart sound signal obtained after segmentation is the preset duration (for example, 3s, the part less than 3s is discarded, and the shortest heart sound is 5s), ensuring that all heart sound records are calculated and no heart sound signal is discarded. For heart sounds with a longer duration, they will be segmented into multiple segments, so that the label of each segment is consistent with the label status of the entire heart sound.
[0067] In operation S120, feature extraction is performed on the segmented heart sound signal using short-time Fourier transform to obtain a multi-dimensional heart sound signal with feature labels.
[0068] In operation S130 , the multidimensional heart sound signals with feature labels are randomly divided into a training set, a validation set, and a test set according to a preset allocation ratio.
[0069] The preset allocation ratio may be 75% for the training set, 15% for the validation set, and 10% for the test set.
[0070] In operation S140, a multidimensional convolutional neural network is used to process a training set, and based on the training set processing results, parameters of the multidimensional convolutional neural network are trained using a loss function and an optimizer to obtain a trained multidimensional convolutional neural network, wherein the data dimension processed by the multidimensional convolutional neural network is consistent with the data dimension of the multidimensional heart sound signal with feature labels.
[0071] In operation S150, the validation set is processed using the trained multidimensional convolutional neural network, and the parameters of the trained multidimensional convolutional neural network are adjusted according to the processing result of the validation set to obtain the multidimensional convolutional neural network that has completed this round of training.
[0072] In operation S160, according to a preset training round, the multidimensional convolutional neural network is cross-optimized and adjusted using the training set and the validation set to obtain a set of trained multidimensional convolutional neural networks.
[0073] In operation S170, the test set is processed using the trained multidimensional convolutional neural network set, and the test set processing result is input into the preset evaluation index to obtain the score of each trained multidimensional convolutional neural network, and based on the score, an optimized multidimensional convolutional neural network is obtained.
[0074] In operation S180, the heart sound signal from the client is processed using an optimized multi-dimensional convolutional neural network, and classification information of the heart sound signal from the client is output.
[0075] The above-mentioned heart sound signal classification method based on end-to-end lightweight convolutional neural network provided by the present invention preprocesses and extracts features of the original heart sound signals in the database, and randomly divides the processed original heart sound signals into a training set, a validation set and a test set, and uses the training set, the validation set and the test set to perform training optimization, verification adjustment and test screening on the lightweight convolutional neural network, and the final lightweight convolutional neural network is used to process the heart sound signals from the client, and outputs the classification information of the client's heart sound signals.
[0076] Figure 2 The flowchart is a flowchart of obtaining a multi-dimensional heart sound signal with feature labels by using short-time Fourier transform according to an embodiment of the present invention.
[0077] like Figure 2 As shown, the above-mentioned process of extracting features from the segmented heart sound signal using short-time Fourier transform to obtain a multi-dimensional heart sound signal with feature labels includes operations S210 to S230.
[0078] In operation S210, parameters of the short-time Fourier transform are initialized to preset values, wherein the parameters of the short-time Fourier transform include a window length, a step length, and the number of points of the fast Fourier transform.
[0079] Short-time Fourier transform is used to extract features of the heart sound signal obtained in each segment. The parameters of short-time Fourier transform are 0.1s window length, 0.05s step length, and 100 Fourier transform points.
[0080] In operation S220, fast Fourier transform or discrete Fourier transform is performed on the segmented processed heart sound signal by using short-time Fourier transform to obtain frequency domain features of the segmented processed heart sound signal.
[0081] In operation S230, frequency domain information of the segmented processed heart sound signal is processed according to the time sequence of the segmented processed heart sound signal to obtain a multi-dimensional heart sound signal with a feature label.
[0082] The above-mentioned process of feature extraction using short-time Fourier transform is actually a process of extracting information from the heart sound signal. In the process of feature extraction, no additional information will be added to the original heart sound signal. At the same time, due to the use of time-frequency domain feature extraction, the information of the original heart sound signal can be better and more retained.
[0083] According to an embodiment of the present invention, the above-mentioned loss function includes a focal loss function, and the optimizer includes an adaptive moment estimation optimizer.
[0084] The focal loss function (Focal Loss) and the adaptive moment estimation optimizer (Adaptive Moment Estimation, Adam) can improve the training and optimization speed, so that the parameters of the multidimensional convolutional neural network described in the present invention can reach the optimal state more quickly.
[0085] According to an embodiment of the present invention, the multidimensional convolutional neural network includes a global maximum pooling layer, a fully connected output layer and a multi-layer convolutional layer, wherein each convolutional layer includes a plurality of filters based on a neural unit description domain.
[0086] According to an embodiment of the present invention, the above-mentioned preset evaluation indicators include accuracy, sensitivity and specificity.
[0087] According to an embodiment of the present invention, the above accuracy is determined by formula (1):
[0088]
[0089] The above sensitivity is determined by formula (2):
[0090]
[0091] The above specificity is determined by formula (3):
[0092]
[0093] Among them, Accuracy is the accuracy, which indicates the proportion of all samples in the sample station that are predicted correctly; Sensitivity is the sensitivity, which indicates the proportion of all positive examples that are classified correctly; Specificity is the specificity, which indicates the proportion of all negative examples that are classified correctly; TN (True negatives) is true negative, which means the prediction is negative and the actual result is negative; FP (False positives) is false positive, which means the prediction is positive and the actual result is negative; FN (False negatives) is false negative, which means the prediction is negative and the actual result is positive.
[0094] The above accuracy (Accuracy) is used to indicate the proportion of all correctly predicted samples in all heart sound samples to the total number of samples; sensitivity (Sensitivity) is used to indicate the proportion of the number of correctly classified positive samples to the number of all true positive samples; specificity (Specificity) is used to indicate the proportion of the number of correctly classified negative samples to the number of all true negative samples.
[0095] The above-mentioned heart sound signal classification method provided by the present invention first downsamples the heart sound records of different lengths in the database to reduce the amount of calculation in the subsequent steps, and then segments the heart sounds according to a certain duration, and the parts that are less than the duration are discarded. The shortest heart sound is greater than the duration, so it can be ensured that all heart sound records are calculated. Then the original heart sound signals in the database are randomly divided into a training set, a validation set, and a test set.
[0096] Then feature extraction is performed. Feature extraction can be regarded as a process of information extraction. The feature extraction process itself will not add any information to the original signal. On the contrary, since filters are usually used to calculate the signal, the result of feature extraction often has less information than the original signal, so the feature extraction method should retain all the information in the original signal as much as possible. From this perspective, when evaluating feature extraction methods, the method that retains more original information should be better. Common signal feature extraction methods can be divided into three types: time domain, frequency domain, and time-frequency domain. According to the evaluation method described above, the time-frequency domain features retain the most information. The present invention adopts a time-frequency feature extraction method to better and more retain the information of the original heart sound signal. At the same time, the actual deployment of the above method needs to consider the amount of calculation and the cost of calculation. The simpler the entire calculation process, the better. This requires that the number of features extracted in the feature extraction step is as small as possible. Therefore, taking into account the above two considerations, and focusing on low parameter quantity and calculation amount, short-time Fourier transform is mainly used as a feature extraction method. The short-time Fourier transform is shown in formula (4):
[0097]
[0098] Where w(n) is the window function, and x(n) is the signal to be transformed. In practice, the main operation of short-time Fourier transform is to segment the original signal into segments of short-length small signals, which may overlap each other, and then multiply the small signals by the window function, perform fast Fourier transform or discrete Fourier transform to obtain the frequency domain information of each small signal, and then arrange all the frequency domain information in time sequence to obtain the result of short-time Fourier transform.
[0099] The original heart sound signal (similar to common physiological signals) is a one-dimensional signal. By using a convolutional neural network with multiple one-dimensional convolution kernels, the output result will become two-dimensional, as shown in formulas (5) and (6):
[0100]
[0101]
[0102] Where X is an n×m matrix, representing the result of the previous layer calculated by multiple one-dimensional convolution kernels, and is also the input of this layer; K is an n×t matrix, representing a one-dimensional convolution kernel.
[0103] The results of short-time Fourier transform are sent to the two-dimensional neural network for training. The model is trained by fixing other parameters and changing a certain parameter alone. Each training starts from scratch. The optimal short-time Fourier transform parameters, the number of filters (NDF) in each layer of the convolutional neural network, the number of groups in grouped convolution, the weight of the back propagation gradient for positive and negative samples in Focal loss training (Alpha), and the proportion of segments judged as abnormal after the original heart sound signal is segmented (Rate), and common evaluation indicators are introduced. The neural network contains three layers of convolution, one global maximum pooling layer, and one fully connected output layer. The output of the neural network is two real numbers. According to the set threshold, the original heart sound record is finally judged as normal or abnormal. The detailed multi-dimensional convolutional neural network parameters are shown in Table 1.
[0104]
[0105] According to an embodiment of the present invention, the above-mentioned heart sound signal classification method further includes:
[0106] The parameters of the optimized multi-dimensional convolutional neural network are stored in the BRAM of the FPGA, and the optimized multi-dimensional convolutional neural network and the heart sound signal processed by the short-time Fourier transform are stored in the data buffer through the data bus;
[0107] Inputting the heart sound signal stored in the data buffer into the convolution layer of the multidimensional convolutional neural network through a shift register for convolution processing, and outputting the convolution processing result;
[0108] The convolution processing result is buffered by the dual-port BRAM and stored according to the preset data structure;
[0109] The convolution processing results are used to perform global maximum pooling calculations and fully connected layer calculations to obtain the classification results of the heart sound signal.
[0110] Figure 3 It is a structural schematic diagram of a multi-dimensional convolutional neural network hardware acceleration method based on FPGA according to an embodiment of the present invention.
[0111] Combine the following Figure 3 The above FPGA-based hardware acceleration method is further described in detail.
[0112] like Figure 3As shown, in order to realize the hardware acceleration and deployment of the above-mentioned light convolutional neural network-based heart sound signal classification method, FPGA is selected as the computing platform, and the RTL (Register Transfer Level) level description is used as the implementation method to carry out targeted optimization of the specific computing links of the convolutional neural network acceleration computing system. First, the trained parameters in the light-weight neural network heart sound classification method are stored in the BRAM of the FPGA board, and then the top-level design method is adopted to describe the functions of each module in the RTL language, and the system operation is controlled by the state machine. The data in the BRAM is first sent to the data buffer, and the data waits for the call of the FPGA computing acceleration module in the buffer. The data in the buffer is exchanged with the computing acceleration module through the data bus, and the data is sent to the convolution layer module of the CNN through the shift register to start the convolution calculation of the convolutional neural network. Here, multiple convolution kernels are used for simultaneous calculation, and multiple convolution results need to be calculated. A dual-port BRAM is used for data buffering to solve the intermediate cache problem of the convolution layer calculation results and achieve the purpose of parallel optimization. After completing the three-layer convolution calculation, a FIFO data storage structure is used for intermediate data buffering. Then the state machine control system enters the global maximum pooling calculation and the fully connected layer calculation, and finally outputs the results. With low power consumption, the convolutional neural network reasoning acceleration is achieved efficiently and quickly.
[0113] Figure 4 4 is a schematic diagram of the system structure of a heart sound signal classification device based on FPGA according to an embodiment of the present invention.
[0114] like Figure 4 As shown, the above-mentioned FPGA-based heart sound signal classification device includes an on-chip storage buffer processing unit 410, a convolutional neural network hardware acceleration calculation unit 420 and a control unit 430, which is used to implement the above-mentioned end-to-end lightweight convolutional neural network-based heart sound signal classification method, characterized in that.
[0115] The on-chip storage buffer processing unit 410 is used to buffer and store the heart sound signal and the optimized multi-dimensional convolutional neural network.
[0116] The convolutional neural network hardware acceleration computing unit 420 is used to process the heart sound signal through a multi-dimensional convolutional neural network to obtain classification information of the heart sound signal.
[0117] The control unit 430 is used to control the flow of the heart sound signals and the intermediate processing results.
[0118] The heart sound signal classification method provided by the present invention is mainly divided into two steps: feature extraction of heart sound signals and classification of heart sound signals. The goal is to compress the model size and reduce the amount of calculation, so as to facilitate deployment in wearable devices and promote the development of wearable heart sound monitoring and diagnostic equipment. A lightweight heart sound processing convolutional neural network based on FPGA, the lightweight heart sound processing convolutional neural network includes an on-chip storage buffer processing unit, a convolutional neural network hardware acceleration calculation module, and a control unit. The FPGA platform deployment of the heart sound signal classification network can be realized to maximize the use of the existing resources of the FPGA platform, give full play to the high parallelism, high throughput, and low power consumption characteristics of the FPGA platform, and efficiently and quickly realize the acceleration of convolutional neural network reasoning under low power consumption.
[0119] In order to better illustrate the above-mentioned heart sound signal classification method and FPGA-based hardware acceleration method provided by the present invention, another specific embodiment of the present invention and Figures 5 to 9 The present invention is described in further detail.
[0120] Figure 5 4 is a schematic diagram of a multi-dimensional convolutional neural network structure for a heart sound signal classification method according to another embodiment of the present invention.
[0121] Figure 6 4 is a schematic diagram of the influence of short-time Fourier transform parameters on a heart sound signal classification method according to another embodiment of the present invention.
[0122] Figure 7 A schematic diagram of the effect of the number of multi-dimensional convolutional neural network filters on a heart sound signal classification method according to another embodiment of the present invention.
[0123] Figure 8 It is a schematic diagram of the influence of the focal loss parameter on the heart sound signal classification method according to another embodiment of the present invention.
[0124] Fig. 9 Schematic diagram of the influence of a voting threshold heart sound signal classification method according to another embodiment of the present invention.
[0125] According to another specific embodiment of the present invention, firstly, the heart sound signals of different lengths in the database are downsampled to 1000Hz to reduce the amount of calculation in the subsequent steps, and then the original heart sound signals in the database are randomly divided into training set, validation set and test set, with the ratios of 0.75, 0.15 and 0.1 respectively, and then the heart sound is segmented according to the duration of 3s, and the part less than 3s is discarded. The shortest heart sound is 5s, which ensures that all heart sound records are calculated and no heart sound is discarded. For heart sounds with longer duration, they will be segmented into multiple segments, so that the label of each segment is consistent with the label status of the entire heart sound.
[0126] Then, each segment of heart sound is characterized by short-time Fourier transform, where the parameters of short-time Fourier transform are 0.1s window length, 0.05s step length, and 100 Fourier transform points. After processing, each segment of signal becomes a two-dimensional matrix. The detailed data flow structure changes are as follows: Figure 5 , detailed neural network parameters are shown in Table 1. Available neural network models include but are not limited to the following configurations: the neural network contains three layers of convolution, one global maximum pooling layer, and one fully connected output layer. The stride in the convolution layer is set to 2, so that the scale of the output feature map is halved each time. The matrix is sent to the two-dimensional neural network for training. Focal loss is used as the loss function and Adam is used as the optimizer. The 10-fold cross-validation method is used to obtain ten models and calculate the results for the test set. Each time the training is performed, the training set is set to be trained 300 times, and the parameters of the final training model are determined by the highest classification accuracy of the validation set.
[0127] The system test uses common evaluation indicators: accuracy, which is the ratio of all correctly predicted samples among all heart sound samples to the total number of samples; sensitivity, which is the ratio of the number of samples correctly classified as positive to the number of all true positive samples; and specificity, which is the ratio of the number of samples correctly classified as negative to the number of all true negative samples.
[0128] First, test the parameters of the short-time Fourier transform. Figure 6 (a) is the classification result of different signal segments after signal segmentation. Figure 6 (b) is the final classification result of the entire segment of the original heart sound signal. Figure 6 (c) is the computational complexity of the network under different short-time Fourier transform parameters. By modifying the window length of the short-time Fourier transform, the step length is fixed to 50% of the window length, and the number of points of the fast Fourier transform is consistent with the step length. The window lengths of 50, 100, 150, 200, 250, and 300 points are tested respectively. By comprehensively considering the balance between accuracy and Sp and Se, the parameters of the short-time Fourier transform are finally determined to be a window length of 100 points, a step length of 50 points, and a fast Fourier transform of 100 points.
[0129] Then the size of NDF is tested. NDF represents the number of filters in each layer of the convolutional neural network and the number of groups in group convolution. Other parameters are fixed as STFT = [100 50 100], alpha = 0.2, rate = 0.45, and the model parameters vary with NDF. Figure 7As shown in the figure, the change of network accuracy after modifying NDF. Since network training has a certain degree of randomness and the limited computing power leads to a small number of training times, the results in the figure are not smooth, but it can still be seen that with the increase of NDF, Acc gradually increases, Sp gradually increases, but Se shows a slow decrease. Since there are many normal heart sounds in the test set, Acc is mainly affected by Sp, but in actual situations, disease detection is more meaningful. According to the results in the figure, the optional NDF range is [5,12]. The test parameter NDF used in this chapter is 8, the corresponding parameter amount is 434, and the calculation amount is 154k.
[0130] Alpha represents the weight of the back propagation gradient for positive and negative samples in Focal loss training. The default value of abnormal samples is 1. By adjusting the weight alpha of normal samples, the problem of gradient bias caused by sample imbalance can be eliminated. In this problem, there are more normal samples than abnormal samples, so the alpha parameter setting range is less than 1 to reduce the weight of normal samples. Figure 8 The following are the training results for different alpha values. Other parameters are fixed as STFT = [100 50 100], NDF = 8, and rate = 0.45. The final parameter is 0.2, at which the gap between Sp and Se is the smallest.
[0131] Rate represents the proportion of segments that are judged to be abnormal after the original heart sound signal is segmented. If the rate setting parameter is exceeded, the entire heart sound signal is judged to be abnormal. Because not all segments of the entire abnormal heart sound segment are necessarily abnormal, for example, arrhythmia does not necessarily occur in all heartbeats. At the same time, this error is also introduced into the model training, so the determination of the rate parameter needs to be tested experimentally. Fig. 9 As shown in the figure, as the rate increases, Sp increases, Se decreases, and Acc also increases because of the increase in Sp. This curve conforms to the definition of rate. The higher the rate, the fewer abnormal heart sounds are judged, and the more normal heart sounds are judged, so TP decreases and TN increases, which affects the changes in Sp and Se. Finally, the test parameters of this chapter were determined to be 0.45, because the gap between Sp and Se is not too large at this time, and the accuracy is also the highest.
[0132] Finally, the classification category is obtained. The output of the neural network is two real numbers. It is not converted into probability through the Softmax activation function. Instead, the heart sound is normal or abnormal by directly comparing the size of the two real numbers. The network designed in this way can avoid the calculation of the natural number exponent of Softmax in actual deployment. After obtaining the classification of each signal segment, the proportion of abnormal heart sound segments in the original heart sound record to all segments is calculated, and the original heart sound record is finally judged as normal or abnormal heart sound based on the set threshold.
[0133] The values of the set hyperparameters include but are not limited to the following: when the hyperparameters are selected as short-time Fourier transform window length 100, NDF=8, alpha=0.2, rate=0.45. The average of all experimental results of the corresponding parameters is: for the classification of segmented heart sounds, Acc=0.8786±0.0143, Se=0.8399±0.0538, Sp=0.8923±0.0186; for the classification of original heart sounds, Acc=0.8733±0.0193, Se=0.8632±0.0599, Sp=0.8760±0.0311. The number of parameters is 434, and the FLOPs is 154k, realizing an end-to-end lightweight neural network heart sound classification method.
[0134] Fig.10 A block diagram of an electronic device suitable for implementing a heart sound signal classification method based on an end-to-end lightweight convolutional neural network according to an embodiment of the present invention is schematically shown.
[0135] like Fig.10 As shown, the electronic device 1000 according to an embodiment of the present invention includes a processor 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. The processor 1001 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 1001 may also include an onboard memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.
[0136] In RAM 1003, various programs and data required for the operation of electronic device 1000 are stored. Processor 1001, ROM 1002 and RAM 1003 are connected to each other via bus 1004. Processor 1001 performs various operations of the method flow according to the embodiment of the present invention by executing the program in ROM 1002 and / or RAM 1003. It should be noted that the program can also be stored in one or more memories other than ROM 1002 and RAM 1003. Processor 1001 can also perform various operations of the method flow according to the embodiment of the present invention by executing the program stored in the one or more memories.
[0137] According to an embodiment of the present invention, the electronic device 1000 may further include an input / output (I / O) interface 1005, which is also connected to the bus 1004. The electronic device 1000 may further include one or more of the following components connected to the I / O interface 1005: an input portion 1006 including a keyboard, a mouse, etc.; an output portion 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 1008 including a hard disk, etc.; and a communication portion 1009 including a network interface card such as a LAN card, a modem, etc. The communication portion 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage portion 1008 as needed.
[0138] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.
[0139] According to an embodiment of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present invention, the computer-readable storage medium may include the ROM 1002 and / or RAM 1003 described above and / or one or more memories other than ROM 1002 and RAM 1003.
[0140] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A heart sound signal classification method based on an end-to-end lightweight convolutional neural network, comprising: Downsampling the original heart sound signal from the database according to the preset signal frequency, and segmenting the downsampled heart sound signal according to the preset duration to obtain a segmented heart sound signal; Using short-time Fourier transform to extract features from the segmented processed heart sound signal to obtain a multi-dimensional heart sound signal with feature labels; According to a preset allocation ratio, the multidimensional heart sound signal with feature labels is randomly divided into a training set, a validation set and a test set; Processing the training set using a multidimensional convolutional neural network, and training the parameters of the multidimensional convolutional neural network using a loss function and an optimizer according to the training set processing result to obtain a trained multidimensional convolutional neural network, wherein the data dimension processed by the multidimensional convolutional neural network is consistent with the data dimension of the multidimensional heart sound signal with feature labels; Processing the verification set using the trained multidimensional convolutional neural network, adjusting the parameters of the trained multidimensional convolutional neural network according to the processing result of the verification set, and obtaining a multidimensional convolutional neural network that has completed this round of training; According to the preset training rounds, the multidimensional convolutional neural network is cross-optimized and adjusted using the training set and the validation set to obtain a set of trained multidimensional convolutional neural networks; Processing the test set using the trained multidimensional convolutional neural network set, inputting the test set processing result into a preset evaluation index, obtaining a score for each of the trained multidimensional convolutional neural networks, and obtaining an optimized multidimensional convolutional neural network based on the score; Processing the heart sound signal from the client using the optimized multi-dimensional convolutional neural network, and outputting classification information of the heart sound signal from the client; The step of extracting features from the segmented processed heart sound signal using short-time Fourier transform to obtain a multidimensional heart sound signal with feature labels includes: Initializing the parameters of the short-time Fourier transform to preset values, wherein the parameters of the short-time Fourier transform include window length, step length and number of fast Fourier transform points; Performing fast Fourier transform or discrete Fourier transform on the segmented processed heart sound signal using the short-time Fourier transform to obtain frequency domain features of the segmented processed heart sound signal; According to the time sequence of the segmented processed heart sound signals, the frequency domain information of the segmented processed heart sound signals is processed to obtain the multidimensional heart sound signals with feature labels; Wherein, the preset evaluation indicators include accuracy, sensitivity and specificity; The accuracy is determined by formula (1): (1), The sensitivity is determined by formula (2): (2), The specificity is determined by formula (3): (3), Among them, Accuracy is the accuracy, which indicates the proportion of all samples in the sample station that are predicted correctly; Sensitivity is the sensitivity, which indicates the proportion of all positive examples that are classified correctly; Specificity is the specificity, which indicates the proportion of all negative examples that are classified correctly; TN is true negative, indicating that the prediction is negative and the actual result is negative; FP is false positive, indicating that the prediction is positive and the actual result is negative; FN is false negative, indicating that the prediction is negative and the actual result is positive.
2. The method according to claim 1, wherein: The loss function comprises a focal loss function, and the optimizer comprises an adaptive moment estimation optimizer.
3. The method according to claim 1, wherein: The multidimensional convolutional neural network includes a global maximum pooling layer, a fully connected output layer and a multi-layer convolutional layer, wherein each of the convolutional layers includes a plurality of filters based on a neural unit description domain.
4. The method according to claim 1, further comprising: Storing the parameters of the optimized multidimensional convolutional neural network in the BRAM of the FPGA, and storing the optimized multidimensional convolutional neural network and the heart sound signal processed by short-time Fourier transform in a data buffer through a data bus; Inputting the heart sound signal stored in the data buffer into the convolution layer of the multidimensional convolutional neural network through a shift register for convolution processing, and outputting the convolution processing result; The convolution processing result is buffered by a dual-port BRAM and stored according to a preset data structure; A global maximum pooling calculation and a fully connected layer calculation are performed on the convolution processing result to obtain a classification result of the heart sound signal.
5. A heart sound signal classification device based on FPGA, used to implement the method of claim 4, characterized in that: include: An on-chip storage buffer processing unit, used for buffering and storing heart sound signals and the optimized multi-dimensional convolutional neural network; A convolutional neural network hardware acceleration computing unit, used for processing the heart sound signal through the multi-dimensional convolutional neural network to obtain classification information of the heart sound signal; A control unit is used to control the flow of the heart sound signal and the intermediate processing result.
6. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors execute the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the method according to any one of claims 1 to 4.
