Pulmonary rales analysis and recognition system based on machine learning
By using machine learning-based methods in the lung rales analysis and identification system, dynamically adjusting the peak and valley thresholds and time window sizes, the problem of insufficient accuracy and adaptability of traditional systems in signal processing and classification model construction is solved, and the problem of insufficient accuracy and adaptability in signal processing and classification model construction is achieved. Higher recognition accuracy and system stability.
Patent Information
- Application Number
- CN202410832772.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-06-26
AI Technical Summary
The traditional lung rales analysis and identification system has problems such as insufficient accuracy, poor adaptability and risk of overfitting in signal peak and valley detection, time window classification and classification model construction.
A machine learning-based system is adopted, including data collection and preprocessing, signal segmentation, feature extraction, model construction and decision-making modules. The classification model is constructed through a random forest algorithm, the peak and valley thresholds and time window sizes are dynamically adjusted, and feedback is adjusted according to the accuracy of the classification model.
It improves the accuracy and flexibility of signal segmentation, enhances the adaptability and stability of the system, reduces the situation of false detection and missed detection, and improves the recognition accuracy of lung rales signals.
Smart Images

Figure CN118797408B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of lung rales analysis, and in particular to a lung rales analysis and recognition system based on machine learning. Background Art
[0002] Traditional lung rales analysis and recognition systems usually rely on fixed thresholds and predefined time windows for signal processing and classification. In the process of signal peak and valley detection, traditional methods often use simple fixed thresholds, which may result in a large number of false peaks and valleys that cannot be effectively eliminated, resulting in insufficient accuracy of signal segmentation.
[0003] In addition, these systems usually use static time window sizes when dividing time windows. Whether it is feature extraction or signal segmentation, they lack dynamic adjustment mechanisms and are difficult to adapt to lung rales of different lengths and complexities. This static processing method cannot fully capture the important features in each respiratory cycle, resulting in low accuracy of feature extraction.
[0004] Furthermore, when building classification models, traditional systems often use a single machine learning model, such as a decision tree or support vector machine, which is prone to overfitting problems and has low classification stability and accuracy. In addition, these systems lack an effective feedback mechanism and cannot dynamically adjust parameters according to the accuracy of the classification model, resulting in poor adaptability and stability of the system under different signal characteristics and real-time data. Traditional methods lack in-depth analysis of misclassified and correctly classified samples, cannot effectively adjust the thresholds for peak and valley detection, and cannot dynamically adjust according to the differential results of the time window. The overall performance is poor in complex and changing clinical environments. Summary of the invention
[0005] The purpose of the present invention is to provide a lung rales analysis and recognition system based on machine learning to solve the problems raised in the above background technology.
[0006] To achieve the above object, the present invention provides the following technical solution: a lung rales analysis and recognition system based on machine learning, characterized in that it includes a data collection and preprocessing module, a signal segmentation module, a feature extraction module and a model construction and decision module, wherein:
[0007] The data collection and preprocessing module collects historical lung rales signal data, and the historical lung rales signal data includes different actual classification results.
[0008] The signal segmentation module detects signal peaks and valleys based on the historical pulmonary rales signal data to determine the boundary of each respiratory cycle; determines the respiratory cycle based on the boundary of the respiratory cycle, and determines an initial time window for each respiratory cycle to generate segmented signal data.
[0009] The feature extraction module is used to extract key features from the segmented signal data, and the key features include frequency domain features and time domain features.
[0010] The model building and decision module builds a classification model using a random Senli algorithm according to the key features and the corresponding actual classification results, and calculates the accuracy of the classification model, where:
[0011] If the accuracy of the classification model is qualified, the classification model will be sent to the management personnel as a completed model for real-time lung rales analysis and recognition.
[0012] If the accuracy of the classification model is unqualified, then according to the classification results generated by the classification model, extract the samples of incorrect classification and correct classification, and calculate and analyze the peak and valley indicators of the incorrectly classified samples and the correctly classified samples to generate the peak and valley difference results; and calculate and analyze the statistics under different time window sizes to generate the time difference results; send the peak and valley difference results and the time difference results to the signal segmentation module; wherein:
[0013] The signal segmentation module adjusts the peak-to-valley threshold of peak detection according to the peak difference result, and adjusts the initial time window according to the time difference result. After the adjustment, the signal segmentation module, feature extraction module, model construction and decision module are re-run until the accuracy of the classification model is qualified.
[0014] As a further improvement of the technical solution, the signal segmentation module includes a peak-valley analysis unit, which detects the signal peak and valley values according to the historical lung rales signal data and determines the boundary of each respiratory cycle, specifically including:
[0015] According to the amplitude change of the audio signal data in the historical lung rales signal data, the peak and valley values are detected. The peak and valley values correspond to the change points of air flow during breathing. The detection conditions are as follows:
[0016] Peak detection condition: S(t i )>S(t i-1 ) and S(t i )>S(t i+1 );
[0017] Valley value detection condition: S(t i )<S(t i-1 ) and S(t i )<S(t i+1 ); where S(t i ) represents the amplitude of the audio signal data at the i-th time point;
[0018] Set the peak-valley threshold to remove extreme points whose amplitude is lower than the peak-valley threshold; the peak-valley threshold includes the peak threshold P ot and valley threshold V ot ;
[0019] The detected peaks and valleys are marked to form a series of peak-valley sequences, where the peak sequence is p = (p1, p2, ..., p u ) and the valley sequence is v=(v1,v2,...,v u );
[0020] According to the detected peak-valley sequence, the boundary of each respiratory cycle is determined. A respiratory cycle includes a complete inhalation and exhalation process, corresponding to a peak-valley pair, and the respiratory cycle boundary is: B = ((p1,v1), (p2,v2), ..., (p u ,v u )).
[0021] As a further improvement of the present technical solution, the signal segmentation module includes a time window determination unit, which determines the respiratory cycle according to the boundary of the respiratory cycle, and determines the initial time window for each respiratory cycle to generate segmented signal data, specifically including:
[0022] According to the respiratory cycle boundary, the entire signal is divided into several independent respiratory cycles, each of which represents a complete respiratory process. j =S(t), Among them C j represents the audio signal data of the j-th breathing cycle; S(t) represents the audio signal data; Indicates the start time of the jth respiratory cycle, corresponding to the time of the peak point of the jth peak-to-valley pair; It indicates the end time of the j-th respiratory cycle, corresponding to the time of the valley point in the j-th peak-valley pair.
[0023] Set the current time window: Set an initial time window for each breathing cycle. The time window size is: w j represents the time window of the jth respiratory cycle.
[0024] Segmentation signal: Segment the signal according to the set initial time window, extract the audio signal data in each breathing cycle, generate multiple independent segmentation signal segments, and generate segmentation signal data.
[0025] As a further improvement of the present technical solution, the feature extraction module is used to extract key features of the segmented signal data, and the key features include frequency domain features and time domain features, wherein the time domain features include average amplitude, maximum amplitude, minimum amplitude and root mean square value.
[0026] The calculation is as follows:
[0027] Add up all the amplitude values of the segmented signal data within a time window, divide the sum by the number of samples in the time window, and the resulting value represents the average amplitude of the signal;
[0028] Find the highest and lowest amplitudes of the signal within a time window. The maximum value represents the peak value of the signal within the window, and the minimum value represents the valley value of the signal.
[0029] Square each amplitude value of the signal within a time window, calculate the average of these squared values, and take the square root of the average to get the RMS value.
[0030] As a further improvement of the technical solution, the model building and decision module includes a model building unit, which uses a random Mori algorithm to build a classification model based on key features and corresponding actual classification results, and calculates the accuracy of the classification model, specifically including:
[0031] Divide the data set formed by key features and corresponding actual classification results into multiple subsets, and use one of the subsets as a validation set and the rest as training sets;
[0032] Multiple subsets are randomly selected from the training set, and each subset is used to train a decision tree, with replacement sampling, that is, the same sample may be extracted multiple times; for each subset, a part of the features are randomly selected at each node for splitting when building a decision tree; the optimal split point is found according to the splitting criterion; the above steps are repeated to build multiple decision trees to form a random forest, and the prediction result of the random forest is determined by voting of each decision tree;
[0033] Make predictions on the validation set to obtain prediction results; compare the prediction results with the actual classification labels; count the number of correctly classified samples and the total number of samples, and substitute them into the accuracy formula to calculate the accuracy of the classification model, where the accuracy formula is: Accuracy = number of correctly classified samples / total number of samples.
[0034] As a further improvement of the present technical solution, the model building and decision module includes a decision unit, and the decision unit determines a decision path according to the accuracy of the classification model, specifically including:
[0035] A qualified accuracy threshold is set. When the accuracy of the classification model is greater than the accuracy threshold, it means that the accuracy of the classification model is qualified. The classification model is then sent to the management personnel as a completed model for real-time lung rales analysis and recognition.
[0036] When the accuracy of the classification model is less than or equal to the accuracy threshold, it means that the accuracy of the classification model is unqualified. Then, according to the classification results generated by the classification model, the incorrectly classified and correctly classified samples are extracted, where the incorrectly classified samples indicate samples whose predicted categories are inconsistent with the actual categories, and the correctly classified samples indicate samples whose predicted categories are consistent with the actual categories; and the peak indicators of the incorrectly classified samples and the correctly classified samples are calculated and analyzed to generate peak difference results; and the statistics under different time window sizes are calculated and analyzed to generate time difference results.
[0037] As a further improvement of the technical solution, the calculation and analysis of the peak indicators of the misclassified samples and the correctly classified samples to generate the peak difference results specifically include:
[0038] Extracting incorrectly classified and correctly classified samples: Using the constructed classification model to classify key features; extracting incorrectly classified and correctly classified samples separately according to the actual classification results and the classification results of the model to form two sample sets.
[0039] Calculate and analyze the peak and valley indicators of misclassified samples and correctly classified samples: for each sample, extract the peak and valley indicators from the segmented signal data; the peak and valley indicators usually include but are not limited to the following: peaks and valleys in the signal, the time positions of the peaks and valleys, and the amplitudes of the peaks and valleys; calculate the peak and valley indicators of each sample in the misclassified sample set, and count the average peak and average valley of the misclassified samples; similarly, calculate the peak and valley indicators of each sample in the correctly classified sample set, and count the average peak and average valley of the correctly classified samples.
[0040] Generate peak-valley difference results: Compare and analyze the peak-valley indicators in the misclassified sample set and the correctly classified sample set, and calculate the difference between the two, including the difference between the average peak value of the misclassified samples and the average peak value of the correctly classified samples, and the difference between the average valley value of the misclassified samples and the average valley value of the correctly classified samples.
[0041] As a further improvement of the technical solution, the calculation and analysis of statistics under different time window sizes to generate time difference results specifically includes:
[0042] Determine multiple different time window sizes;
[0043] For each time window size, perform sliding window calculations on the entire time series data, and calculate statistics within each sliding window; divide the time series data into multiple subsequences according to the selected time window size;
[0044] For each time window size, a matrix containing all sliding window statistics is generated, where each row of the matrix corresponds to a sliding window and each column corresponds to a calculated statistic; for a time window, each row of the matrix includes all statistics within the time window;
[0045] For each time window size, the average statistics of the misclassified samples and the correctly classified samples are calculated respectively, and the difference of each statistic under different time windows is calculated, including calculating the average statistics of the correctly classified samples minus the average statistics of the misclassified samples to obtain the difference value; a time difference matrix containing all time window sizes and corresponding differences is generated, each row corresponds to a time window, and each column corresponds to a difference value of a statistic; the time window with the largest difference value is sent to the time window determination unit, and the time window determination unit uses the time window with the largest difference value as the current time window.
[0046] As a further improvement of the technical solution, the peak-valley analysis unit adjusts the peak-valley threshold of the peak detection according to the peak difference result, specifically including:
[0047] The average peak difference between the misclassified samples and the correctly classified samples is: ΔP = P corrmean -P errmean , where P corrmean The average peak value of correctly classified samples, P errmean is the average peak value of misclassified samples;
[0048] The average valley value difference between the misclassified samples and the correctly classified samples is: ΔV = V corrmean -V errmean , where V corrmean is the average valley value of correctly classified samples, V errmean is the average valley value of misclassified samples;
[0049] When ΔP>0, it means that the average peak value of the correctly classified samples is higher than the average peak value of the incorrectly classified samples, and the peak threshold needs to be lowered: P nt =P ot -α×ΔP, where P nt is the peak threshold after reduction, α is the peak adjustment amplitude coefficient;
[0050] When ΔV>0, it means that the average valley value of the correctly classified samples is lower than the average valley value of the incorrectly classified samples, and the valley value threshold V needs to be increased. nt =V ot +β×ΔV, where V nt is the improved valley threshold, and β is the valley adjustment coefficient.
[0051] Compared with the prior art, the present invention has the following beneficial effects:
[0052] 1. After detecting the signal peak and valley values, the machine learning-based lung rales analysis and recognition system determines the initial time window and generates segmented signal data; when the accuracy of the classification model is unqualified, it calculates and analyzes the peak and valley indicators of the misclassified samples and the correctly classified samples, generates the peak and valley difference results, and adjusts the peak and valley threshold of the peak detection according to the peak difference results; this mechanism based on peak and valley detection and adjustment ensures the accuracy of signal segmentation, and improves the reliability of peak and valley detection by eliminating pseudo peaks and pseudo valleys that do not meet the characteristics; the system compares and analyzes the peak and valley indicators of the misclassified samples and the correctly classified samples, calculates the difference of the average peak and valley values, and dynamically adjusts the detection threshold, thereby improving the recognition accuracy of lung rales signals in subsequent signal processing. This adjustment mechanism reduces false detection and missed detection, enhances the robustness of signal processing, and enables the system to maintain high recognition performance under different conditions.
[0053] 2. The machine learning-based lung rales analysis and recognition system determines the respiratory cycle according to the boundaries of the respiratory cycle, determines the initial time window for each respiratory cycle, and generates segmented signal data; and when extracting key features, it also involves the application of time windows; and calculates and analyzes statistics under different time window sizes, generates time difference results, and adjusts the initial time window according to the time difference results; through the precise division of the respiratory cycle and the reasonable setting of the initial time window, the system can effectively capture the important features in each respiratory cycle; the dynamic adjustment mechanism of the time window ensures the flexibility and accuracy of signal segmentation, and different time window sizes adapt to different types of lung rales signals, improving the accuracy of feature extraction; under the guidance of the time difference results, the adjustment of the time window enables the system to maintain high adaptability and accuracy when processing signals of different lengths and complexities, ensuring the consistency and efficiency of feature extraction and signal segmentation.
[0054] 3. The machine learning-based lung rales analysis and recognition system builds a classification model through the random forest algorithm, which enhances the classification accuracy and robustness of the system; random forests build multiple decision trees for voting decisions, reducing the risk of overfitting of a single model and improving the stability and accuracy of classification. The entire system embodies a powerful feedback mechanism, which continuously calculates and analyzes the accuracy of the classification model, dynamically adjusts the threshold and time window size of peak and valley detection, and ensures the continuous optimization of the performance of the classification model; the feedback mechanism not only enables the system to adapt to different signal characteristics, but also adjusts according to real-time data, maintaining the efficiency and stability of the system in various complex environments; this feedback-based adaptive learning system significantly improves the overall performance of lung rales signal analysis and recognition, ensuring the reliability and accuracy of clinical applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is a schematic diagram of the overall module of the present invention;
[0056] Figure 2 It is a schematic diagram of a signal segmentation module unit of the present invention;
[0057] Figure 3 It is a schematic diagram of the model construction and decision module unit of the present invention.
[0058] In the figure: 100, data collection and preprocessing module; 200, signal segmentation module; 201, peak and valley analysis unit; 202, time window determination unit; 300, feature extraction module; 400, model building and decision module; 401, model building unit; 402, decision unit. DETAILED DESCRIPTION
[0059] The following will be combined with the accompanying drawings in the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] See also Figure 1-3 The present invention provides a technical solution: a lung rales analysis and recognition system based on machine learning, including a data collection and preprocessing module 100, a signal segmentation module 200, a feature extraction module 300 and a model building and decision module 400.
[0061] The data collection and preprocessing module 100 collects historical pulmonary rales signal data from a medical database. The historical pulmonary rales signal data includes but is not limited to fields such as signal ID, acquisition time, audio signal data, and classification labels; wherein the classification labels are different actual classification results, i.e., rales types.
[0062] The data collection and preprocessing module 100 preprocesses the historical pulmonary rales signal data, and the preprocessing includes data cleaning and data normalization. The purity of the signal is ensured by removing noise and interference; the integrity and accuracy of the data are ensured by processing missing values and outliers; the historical pulmonary rales signal data are normalized so that signal data from different sources have consistent standards, which is convenient for subsequent processing and analysis; and the signal segmentation module 200 is ensured to accurately detect peaks and valleys and determine the boundaries of the respiratory cycle.
[0063] The peak-valley analysis unit 201 in the signal segmentation module 200 detects the signal peak and valley values based on the historical lung rales signal data processed by the data collection and preprocessing module 100 to determine the boundary of each respiratory cycle.
[0064] Specifically include:
[0065] According to the amplitude change of the audio signal data in the historical lung rales signal data, the peak and valley values are detected. The peak and valley values correspond to the change points of air flow during breathing, such as the beginning and end of inhalation and exhalation. The detection conditions are as follows:
[0066] Peak detection condition: S(t i )>S(t i-1 ) and S(t i )>S(t i+1 );
[0067] Valley value detection condition: S(t i )<S(t i-1 ) and S(t i )<S(t i+1 ); where S(t i ) represents the amplitude of the audio signal data at the i-th time point.
[0068] Set the peak-valley threshold to remove pseudo peaks and pseudo valleys that do not meet the characteristics, that is, remove extreme points with amplitudes lower than the peak-valley threshold, so as to perform signal smoothing and reduce pseudo extreme values caused by noise; the peak-valley threshold includes the peak threshold P ot and valley threshold V ot ;
[0069] The detected peaks and valleys are marked to form a series of peak-valley sequences, where the peak sequence is p = (p1, p2, ..., p u ) and the valley sequence is v=(v1,v2,...,v u );
[0070] According to the detected peak-valley sequence, the boundary of each respiratory cycle is determined. Since a respiratory cycle includes a complete inhalation and exhalation process, corresponding to a peak-valley pair, the respiratory cycle boundary is: B = ((p1,v1), (p2,v2), ..., (p u ,v u )).
[0071] The time window determination unit 202 in the signal segmentation module 200 determines the respiratory cycle according to the boundary of the respiratory cycle, and determines an initial time window for each respiratory cycle to generate segmented signal data, specifically including:
[0072] According to the respiratory cycle boundary, the entire signal is divided into several independent respiratory cycles, each of which represents a complete respiratory process. j =S(t), Among them C jrepresents the audio signal data of the j-th breathing cycle; S(t) represents the audio signal data; Indicates the start time of the jth respiratory cycle, corresponding to the time of the peak point of the jth peak-to-valley pair; It indicates the end time of the j-th respiratory cycle, corresponding to the time of the valley point in the j-th peak-valley pair.
[0073] Set the current time window: Set an initial time window for each breathing cycle. The time window size is: w j represents the time window of the jth respiratory cycle.
[0074] Segmentation signal: Segment the signal according to the set initial time window, extract the audio signal data in each breathing cycle, generate multiple independent segmentation signal segments, and generate segmentation signal data.
[0075] The feature extraction module 300 is used to extract key features from the segmented signal data, where the key features include frequency domain features and time domain features.
[0076] Specifically include:
[0077] The frequency domain features are calculated as follows:
[0078] Convert the segmented signal data from the time domain to the frequency domain, use Fourier transform to decompose the time signal into sine waves of different frequencies to obtain a spectrum diagram; extract the amplitude information in the spectrum diagram to display the energy distribution of the signal at each frequency; identify the frequency with the highest energy in the spectrum diagram as the main component;
[0079] Calculate the frequency range where the signal energy is concentrated in the spectrum as the frequency bandwidth;
[0080] Evaluate the energy density of a signal at different frequencies, showing the energy distribution of the signal in the frequency domain as power spectral density;
[0081] The principal components, frequency bandwidth and power spectral density are used as frequency domain features.
[0082] The time domain features are calculated as follows:
[0083] Add up all the amplitude values of the segmented signal data within a time window, divide the sum by the number of samples in the time window, and the resulting value represents the average amplitude of the signal, reflecting its DC component;
[0084] Find the highest and lowest amplitudes of a signal within a time window. The maximum value represents the peak value of the signal within the window, and the minimum value represents the valley value of the signal. It is used to describe the extreme value characteristics of the signal.
[0085] Square each amplitude value of the signal within a time window, calculate the average of these square values, and square the average value to obtain the root mean square value, which represents the effective value of the signal;
[0086] The average amplitude, maximum amplitude, minimum amplitude and root mean square value are taken as time domain features.
[0087] The model building unit 401 in the model building and decision module 400 builds a classification model using a random Mori algorithm according to key features and corresponding actual classification results, and calculates the accuracy of the classification model.
[0088] Specifically include:
[0089] Divide the data set formed by key features and corresponding actual classification results into multiple subsets, and use one of the subsets as a validation set and the rest as training sets in a loop to reduce the risk of model overfitting and improve the stability of the evaluation;
[0090] Multiple subsets are randomly selected from the training set, and each subset is used to train a decision tree, with replacement sampling, that is, the same sample may be extracted multiple times; for each subset, a part of the features are randomly selected at each node for splitting when building a decision tree; the optimal split point is found according to the splitting criteria (such as Gini coefficient, information gain); the above steps are repeated to build multiple decision trees to form a random forest, and the prediction result of the random forest is determined by voting of each decision tree;
[0091] Make predictions on the validation set to obtain prediction results; compare the prediction results with the actual classification labels; count the number of correctly classified samples and the total number of samples, and substitute them into the accuracy formula to calculate the accuracy of the classification model, where the accuracy formula is: Accuracy = number of correctly classified samples / total number of samples.
[0092] The decision unit 402 in the model building and decision module 400 receives the accuracy of the classification model in the model building unit 401, and determines the decision path according to the accuracy of the classification model.
[0093] Specifically include:
[0094] A qualified accuracy threshold is set. When the accuracy of the classification model is greater than the accuracy threshold, it means that the accuracy of the classification model is qualified. The classification model is then sent to the management personnel as a completed model for real-time lung rales analysis and recognition.
[0095] When the accuracy of the classification model is less than or equal to the accuracy threshold, it means that the accuracy of the classification model is unqualified. Then, according to the classification results generated by the classification model, the incorrectly classified and correctly classified samples are extracted, where the incorrectly classified samples indicate samples whose predicted categories are inconsistent with the actual categories, and the correctly classified samples indicate samples whose predicted categories are consistent with the actual categories; and the peak indicators of the incorrectly classified samples and the correctly classified samples are calculated and analyzed to generate peak difference results.
[0096] Specifically include:
[0097] Extract misclassified and correctly classified samples: Use the constructed classification model to classify key features; identify which samples are misclassified and which samples are correctly classified based on the actual classification results and the classification results of the model; extract these misclassified and correctly classified samples separately to form two sample sets, including misclassified samples and correctly classified samples.
[0098] Calculate and analyze the peak and valley indicators of misclassified samples and correctly classified samples: For each sample (whether misclassified or correctly classified), extract the peak and valley indicators from the segmented signal data; the peak and valley indicators usually include but are not limited to the following: peaks and valleys in the signal, the time positions of the peaks and valleys, and the amplitudes of the peaks and valleys; calculate the peak and valley indicators of each sample in the misclassified sample set, and count the average peak and average valley values of the misclassified samples; similarly, calculate the peak and valley indicators of each sample in the correctly classified sample set, and count the average peak and average valley values of the correctly classified samples.
[0099] Generate peak-valley difference results: Compare and analyze the peak-valley indicators in the misclassified sample set and the correctly classified sample set, and calculate the difference between the two, including the difference between the average peak value of the misclassified samples and the average peak value of the correctly classified samples, and the difference between the average valley value of the misclassified samples and the average valley value of the correctly classified samples.
[0100] The decision unit 402 sends the peak-valley difference result to the peak-valley analysis unit 201 , and the peak-valley analysis unit 201 adjusts the peak-valley threshold of the peak detection according to the peak difference result.
[0101] Specifically include:
[0102] The average peak difference between the misclassified samples and the correctly classified samples is: ΔP = P corrmean -P errmean , where P corrmean The average peak value of correctly classified samples, P errmean is the average peak value of misclassified samples;
[0103] The average valley value difference between the misclassified samples and the correctly classified samples is: ΔV = Vcorrmean -V errmean , where V corrmean is the average valley value of correctly classified samples, V errmean is the average valley value of misclassified samples;
[0104] When ΔP>0, it means that the average peak value of the correctly classified samples is higher than the average peak value of the incorrectly classified samples, that is, the peak threshold is too high, resulting in some correct peaks not being detected. Therefore, the peak threshold needs to be lowered: P nt =P ot -α×ΔP, where P nt is the peak threshold after reduction, α is the peak adjustment amplitude coefficient;
[0105] When ΔV>0, it means that the average valley value of the correctly classified samples is lower than the average valley value of the incorrectly classified samples, that is, the valley value threshold is too low, resulting in some correct valley values not being detected. Therefore, it is necessary to increase the valley value threshold V nt =V ot +β×ΔV, where V nt is the improved valley threshold, and β is the valley adjustment coefficient.
[0106] In addition, when the accuracy of the classification model is less than or equal to the accuracy threshold, the decision unit 402 calculates and analyzes statistics under different time window sizes to generate time difference results, specifically including: determining multiple different time window sizes, such as 5 seconds, 10 seconds, 30 seconds, etc.
[0107] For each time window size, a sliding window calculation is performed on the entire time series data. Within each sliding window, statistics such as mean, standard deviation, maximum, minimum, etc. are calculated; the time series data is divided into multiple subsequences according to the selected time window size.
[0108] For each time window size, a matrix containing all sliding window statistics is generated, where each row of the matrix corresponds to a sliding window and each column corresponds to a calculated statistic; for example, for a time window, each row of the matrix includes all statistics within the time window, such as the peak value, valley value, etc. of the window.
[0109] For each time window size, the average statistics of the misclassified samples and the correctly classified samples are calculated respectively, and the difference of each statistic under different time windows is calculated, including calculating the average statistics of the correctly classified samples minus the average statistics of the misclassified samples to obtain the difference value; a time difference matrix containing all time window sizes and corresponding differences is generated, where each row corresponds to a time window, and each column corresponds to a difference value of a statistic; the time window with the largest difference value is sent to the time window determination unit 202, and the time window determination unit 202 uses the time window with the largest difference value as the current time window.
[0110] The peak-to-valley difference result adjusts the peak-to-valley threshold of the peak detection according to the peak difference result, and the time window determination unit 202 adjusts the initial time window according to the time difference result. After the adjustment, the signal segmentation module 200, the feature extraction module 300 and the model construction and decision module 400 are re-run until the accuracy of the classification model is qualified.
[0111] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited by the above embodiments. The above embodiments and descriptions are only preferred examples of the present invention and are not intended to limit the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. A lung rales analysis and recognition system based on machine learning, characterized in that: The system comprises a data collection and preprocessing module (100), a signal segmentation module (200), a feature extraction module (300) and a model building and decision module (400), wherein: The data collection and preprocessing module (100) collects historical lung rales signal data, wherein the historical lung rales signal data includes different actual classification results; The signal segmentation module (200) detects signal peaks and valleys based on the historical lung rales signal data, and determines the boundary of each respiratory cycle; determines the respiratory cycle based on the boundary of the respiratory cycle, and determines an initial time window for each respiratory cycle, and generates segmented signal data; The feature extraction module (300) is used to extract key features from the segmented signal data, where the key features include frequency domain features and time domain features; The model building and decision module (400) builds a classification model using a random Mori algorithm according to the key features and the corresponding actual classification results, and calculates the accuracy of the classification model, wherein: If the accuracy of the classification model is qualified, the classification model is sent to the management personnel as a completed model for real-time lung rales analysis and recognition; If the accuracy of the classification model is unqualified, then according to the classification results generated by the classification model, extract the samples of incorrect classification and correct classification, and calculate and analyze the peak and valley indicators of the incorrect classification samples and the correct classification samples to generate the peak and valley difference results; and calculate and analyze the statistics under different time window sizes to generate the time difference results; send the peak and valley difference results and the time difference results to the signal segmentation module (200); wherein: The signal segmentation module (200) adjusts the peak-valley threshold of the peak detection according to the peak difference result, and adjusts the initial time window according to the time difference result. After the adjustment, the signal segmentation module (200), the feature extraction module (300) and the model construction and decision module (400) are re-run until the accuracy of the classification model is qualified; The signal segmentation module (200) comprises a peak-valley analysis unit (201), wherein the peak-valley analysis unit (201) detects signal peaks and valleys based on historical lung rales signal data, and determines the boundary of each respiratory cycle, specifically comprising: According to the amplitude change of the audio signal data in the historical lung rales signal data, the peak and valley values are detected. The peak and valley values correspond to the change points of air flow during breathing. The detection conditions are as follows: Peak detection conditions: ; Valley value detection conditions: ;in Indicated in The amplitude of the audio signal data at a time point; Set the peak-valley threshold to remove extreme points whose amplitude is lower than the peak-valley threshold; the peak-valley threshold includes the peak threshold and valley threshold ; The detected peaks and valleys are marked to form a series of peak-valley sequences, where the peak sequence is And the valley sequence is ; According to the detected peak-valley sequence, the boundary of each respiratory cycle is determined. A respiratory cycle includes a complete inhalation and exhalation process, corresponding to a peak-valley pair, and the respiratory cycle boundary is: ; The signal segmentation module (200) comprises a time window determination unit (202), wherein the time window determination unit (202) determines a respiratory cycle according to a boundary of the respiratory cycle, determines an initial time window for each respiratory cycle, and generates segmented signal data, specifically comprising: According to the respiratory cycle boundary, the entire signal is divided into several independent respiratory cycles, each of which represents a complete respiratory process. , ,in Indicates Audio signal data of a breathing cycle; Represents audio signal data; Indicates The start time of the breathing cycle corresponds to the The time between the peak and the valley; Indicates The end time of the breathing cycle corresponds to the The time between the peak and valley point; Set the current time window: Set an initial time window for each breathing cycle. The time window size is: , Indicates The time window of the respiratory cycle; Segmentation signal: Segment the signal according to the set initial time window, extract the audio signal data in each breathing cycle, generate multiple independent segmentation signal segments, and generate segmentation signal data; The peak-valley analysis unit (201) adjusts the peak-valley threshold of the peak detection according to the peak difference result, specifically including: The average peak difference between misclassified samples and correctly classified samples is: ,in The average peak value of correctly classified samples, is the average peak value of misclassified samples; The average difference in valley values between misclassified samples and correctly classified samples is: ,in is the average valley value of correctly classified samples, is the average valley value of misclassified samples; when When , it means that the average peak value of the correctly classified samples is higher than the average peak value of the incorrectly classified samples, and the peak threshold needs to be lowered: ,in is the peak threshold after reduction, is the peak adjustment amplitude coefficient; when , it means that the average valley value of the correctly classified samples is lower than the average valley value of the incorrectly classified samples, and the valley value threshold needs to be increased. ,in is the increased valley threshold, Adjust the amplitude coefficient for the valley value.
2. The machine learning-based lung rales analysis and recognition system according to claim 1, characterized in that: The feature extraction module (300) is used to extract key features from the segmented signal data, the key features including frequency domain features and time domain features, wherein the time domain features include average amplitude, maximum amplitude, minimum amplitude and root mean square value, which are calculated as follows: Add up all the amplitude values of the segmented signal data within a time window, divide the sum by the number of samples in the time window, and the resulting value represents the average amplitude of the signal; Find the highest and lowest amplitudes of the signal within a time window. The maximum value represents the peak value of the signal within the window, and the minimum value represents the valley value of the signal. Square each amplitude value of the signal within a time window, calculate the average of these squared values, and take the square root of the average to get the RMS value.
3. The machine learning-based lung rales analysis and recognition system according to claim 1, characterized in that: The model building and decision module (400) comprises a model building unit (401), wherein the model building unit (401) builds a classification model using a random Mori algorithm according to key features and corresponding actual classification results, and calculates the accuracy of the classification model, specifically comprising: Divide the data set formed by key features and corresponding actual classification results into multiple subsets, and use one of the subsets as a validation set and the rest as training sets; Multiple subsets are randomly selected from the training set, and each subset is used to train a decision tree, with replacement sampling, that is, the same sample may be extracted multiple times; for each subset, a part of the features are randomly selected at each node for splitting when building a decision tree; the optimal split point is found according to the splitting criterion; the above steps are repeated to build multiple decision trees to form a random forest, and the prediction result of the random forest is determined by voting of each decision tree; Make predictions on the validation set to obtain prediction results; compare the prediction results with the actual classification labels; count the number of correctly classified samples and the total number of samples, and substitute them into the accuracy formula to calculate the accuracy of the classification model, where the accuracy formula is: Accuracy = number of correctly classified samples / total number of samples.
4. The machine learning-based lung rales analysis and recognition system according to claim 3, characterized in that: The model building and decision module (400) includes a decision unit (402), and the decision unit (402) determines a decision path according to the accuracy of the classification model, specifically including: A qualified accuracy threshold is set. When the accuracy of the classification model is greater than the accuracy threshold, it means that the accuracy of the classification model is qualified. Then the classification model is sent to the management personnel as a completed model for real-time lung rales analysis and recognition. When the accuracy of the classification model is less than or equal to the accuracy threshold, it means that the accuracy of the classification model is unqualified. Then, according to the classification results generated by the classification model, the incorrectly classified and correctly classified samples are extracted, where the incorrectly classified samples indicate samples whose predicted categories are inconsistent with the actual categories, and the correctly classified samples indicate samples whose predicted categories are consistent with the actual categories; and the peak indicators of the incorrectly classified samples and the correctly classified samples are calculated and analyzed to generate peak difference results; and the statistics under different time window sizes are calculated and analyzed to generate time difference results.
5. The machine learning-based lung rales analysis and recognition system according to claim 4, characterized in that: The calculation and analysis of the peak indicators of the misclassified samples and the correctly classified samples to generate the peak difference results specifically include: Extracting incorrectly classified and correctly classified samples: Using the constructed classification model to classify key features; extracting incorrectly classified and correctly classified samples respectively according to the actual classification results and the classification results of the model to form two sample sets; Calculate and analyze the peak-valley indicators of misclassified samples and correctly classified samples: For each sample, extract the peak-valley indicators from the segmented signal data; the peak-valley indicators usually include but are not limited to the following: the peak and valley values in the signal, the time position of the peak and valley values, and the amplitude of the peak and valley values; calculate the peak-valley indicators of each sample in the misclassified sample set, and count the average peak and average valley values of the misclassified samples; similarly, calculate the peak-valley indicators of each sample in the correctly classified sample set, and count the average peak and average valley values of the correctly classified samples; Generate peak-valley difference results: Compare and analyze the peak-valley indicators in the misclassified sample set and the correctly classified sample set, and calculate the difference between the two, including the difference between the average peak value of the misclassified samples and the average peak value of the correctly classified samples, and the difference between the average valley value of the misclassified samples and the average valley value of the correctly classified samples.
6. The machine learning-based lung rales analysis and recognition system according to claim 4, characterized in that: The calculation and analysis of statistics under different time window sizes to generate time difference results specifically includes: Determine multiple different time window sizes; For each time window size, perform sliding window calculations on the entire time series data, and calculate statistics within each sliding window; divide the time series data into multiple subsequences according to the selected time window size; For each time window size, a matrix containing all sliding window statistics is generated, where each row of the matrix corresponds to a sliding window and each column corresponds to a calculated statistic; for a time window, each row of the matrix includes all statistics within the time window; For each time window size, the average statistics of the misclassified samples and the correctly classified samples are calculated respectively, and the difference of each statistic under different time windows is calculated, including calculating the average statistics of the correctly classified samples minus the average statistics of the misclassified samples to obtain the difference value; generating a time difference matrix containing all time window sizes and corresponding differences, each row corresponding to a time window, and each column corresponding to a difference value of a statistic; sending the time window with the largest difference value to the time window determination unit (202), and the time window determination unit (202) uses the time window with the largest difference value as the current time window.
Citation Information
Patent Citations
Method for dynamically invoking respiratory gating
CN110192886A
System and method for lung rale recognition
CN111009263A