A lung function breathing detection method based on adaptive threshold
The respiratory flow data is processed through the adaptive threshold method, and the threshold is dynamically adjusted to adapt to different breathing modes, solving the problem of inaccurate detection under the influence of inter-individual variability and noise by the fixed threshold method, achieving higher detection accuracy and robustness.
Patent Information
- Application Number
- CN202210491067.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-07
- Publication Date
- 2025-05-20
- Estimated Expiration
- 2042-05-07
AI Technical Summary
In the prior art, the fixed threshold method is difficult to adapt to the respiratory modes of different individuals and different states due to the influence of inter-individual variability and noise in breath detection, resulting in inaccurate detection results.
The pulmonary function breath detection method based on adaptive threshold is adopted, and the peak points are extracted by convolutional smoothing processing, zero cross detection, first-order derivative solution and local extreme value method on the respiratory flow data, and the breathing mode is divided according to the number of peak points, and the threshold is dynamically adjusted to adapt to different breathing modes.
The adaptability to respiratory detection in different individuals and different states is achieved, the accuracy and robustness of the detection are improved, and the problem of false breathing and leakage detection in the fixed threshold method is avoided.
Smart Images

Figure CN114847926B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of respiratory detection, and particularly relates to a lung function respiratory detection method based on an adaptive threshold. Background Art
[0002] Respiratory detection refers to detecting the time positions of the start of exhalation and the start of inhalation from the respiratory flow signal during a pulmonary function examination. This is a crucial step for a computer to automatically detect pulmonary function parameters and is the starting point for calculating various clinically significant indicators, performing regression analysis, or making predictions. Respiratory detection is a relatively easy task for professional doctors in pulmonary function examinations, but it remains a challenge for computerized automatic detection. Due to the differences in the respiratory rate and respiratory pattern among individuals, there is a high degree of variability between individuals, and the respiratory flow signal has a high level of noise, which does not conform to the assumptions made in most traditional automatic digital signal processing analyses. Therefore, to implement a reliable method for automatic respiratory detection in a spirometer, it is necessary to continuously verify and update it to adapt to the possible special characteristics of individual respiratory flow signals.
[0003] Currently, the respiratory detection method used in most spirometers is the fixed threshold method. In the fixed threshold method, first, all zero-crossing points in the respiratory flow are identified, the flow peak of exhalation or inhalation is obtained between two zero-crossing points, and finally, it is analyzed whether the conditions are met between the two zero-crossing points through a pre-set fixed threshold to determine a qualified respiratory cycle. However, the fixed threshold is affected by the variability between individuals, and it is impossible to specify a single threshold suitable for each situation. The subject can only choose to change the threshold until a satisfactory result is obtained. If the threshold is too low, false breaths may be detected, and if the threshold is too high, real breaths may be missed. Therefore, although the fixed threshold respiratory detection method has practical significance, it has certain limitations. Summary of the Invention
[0004] Aiming at the deficiencies of the prior art, the present invention proposes a lung function respiratory detection method based on an adaptive threshold. Based on the different respiratory patterns of the subject, it is designed to adaptively change the respiratory pattern threshold according to the respiratory characteristics and respiratory state of the subject, forming a robust and general respiratory detection.
[0005] A lung function respiratory detection method based on an adaptive threshold of the present invention includes the following steps:
[0006] Step 1: Perform respiratory detection.
[0007] Step 2: Load the respiratory flow data in the form of a time stream at intervals of time t, and perform convolution smoothing processing on the respiratory flow data to obtain a smoothed respiratory flow signal y(n), where n is the sampling point.
[0008] Step 3: Perform zero-crossing detection on y(n) to obtain the set A of zero-crossing time positions.
[0009] Step 4: Take the first derivative of y(n) to obtain the first derivative X′(k), where k = 1, 2, …, m, and m = M - 1, with M being the total number of sampling points M in the smoothed respiratory flow signal y(n).
[0010] Step 5: Use the local extreme value method to extract peaks from X′(k) to obtain the set B of peak points, and standardize the elements within the set B of peak points.
[0011] Step 6: Divide y(n) into three respiratory patterns according to the number of elements in the set B of peak points: rapid breathing pattern, normal breathing pattern, and slow breathing pattern.
[0012] Step 7: Adjust the current time interval threshold Tn according to the determined respiratory pattern.
[0013] Step 8: Screen the set A of zero-crossing time positions according to the current time interval threshold Tn to determine the positions of the start and end points of respiration.
[0014] Step 9: Determine whether the respiration detection continues. If it continues, return to Step 2 for execution.
[0015] Preferably, the convolution smoothing process in Step 2 is specifically as follows:
[0016] Use the least squares method to regress to a polynomial within the window, and then use polynomial fitting to estimate the respiratory flow value at the center point of the window; the window slides across all respiratory flow data in turn for polynomial fitting estimation until all respiratory flow data is smoothed and the smoothed respiratory flow signal y(n) is returned.
[0017] Preferably, Step 3 is specifically as follows:
[0018] Adopt the analysis strategy of taking the window W1 to judge whether the respiratory flow values at the two positions x(n - 1) and x(n - 2) before the center point position x(n) of the window W1 are negative, and whether the respiratory flow values at the two positions x(n + 1) and x(n + 2) after the center point position x(n) of the window W1 are positive to find the positions of the start point of exhalation and the end point of inhalation; adopt the analysis strategy of taking the window W2 to judge whether the respiratory flow values at the two positions x’(n - 1) and x’(n - 2) before the center point position x’(n) of the window W2 are positive, and whether the respiratory flow values at the two positions x’(n + 1) and x’(n + 2) after the center point position x’(n) of the window W2 are negative to find the positions of the end point of exhalation and the start point of inhalation. The windows W1 and W2 work alternately, and sequentially label and store the center point positions of all windows W1 and W2 that meet the analysis strategy into the set A of zero-crossing time positions.
[0019] Preferably, step 5 is specifically as follows:
[0020] Step 5.1: Take the window adopting the local extreme point search strategy and slide it across the first derivative X′(k) in turn to obtain the position x(k) when the second derivative X″(k) is zero, and sequentially label and store the positions conforming to the search strategy in the peak point set B.
[0021] Step 5.2: Standardize the elements in the peak point set B, and the standardization formula is:
[0022]
[0023] where σ is the standard deviation of x(k), is the mean value of x(k), and X(k) is the standardized value of x(k).
[0024] Preferably, step 6 is specifically as follows:
[0025] If the number of elements in the peak point set B is 2 or 3, it is determined that the breathing mode is the normal breathing mode; if the number of elements in the peak point set B is greater than 3, it is determined that the breathing mode is the rapid breathing mode; if the number of elements in the peak point set B is less than 2, it is determined that the breathing mode is the slow breathing mode.
[0026] Preferably, step 7 is specifically as follows:
[0027] When the breathing mode is the rapid breathing mode and the normal breathing mode, take the average of the time intervals between every two adjacent peak points in the peak point set B and denote it as T. If the current breathing detection is within the first time interval t, directly use T as the current time interval threshold Tn, otherwise use the average of T and the time interval threshold calculated within the previous time interval t as the current time interval threshold Tn. When the breathing mode is the slow breathing mode, perform a fast Fourier transform on the smoothed breathing flow signal y(n), and take the reciprocal of the maximum frequency value f to obtain the minimum period Take T′ as the current time interval threshold Tn.
[0028] Preferably, step 8 is specifically as follows:
[0029] Judge the time intervals between every two adjacent zero-crossing points in the zero-crossing point time position set according to the current time interval threshold Tn. If the time interval is less than the current time interval threshold Tn, it is considered that the latter zero-crossing point is not the starting or ending point of breathing, otherwise it is considered that the latter zero-crossing point is the starting or ending point of breathing, and the exhalation starting point and the inhalation starting point are alternately distributed.
[0030] The beneficial effects of the present invention are:
[0031] 1. The present invention adopts an interval segmentation method to decompose long - term respiratory flow data into multiple short - term interval respiratory flows. The starting and ending points of respiration are processed separately within each interval, enabling the detection process to be carried out in real - time with high operating efficiency. More importantly, the adaptive threshold update method adopted by the present invention can obtain thresholds suitable for each individual's breathing pattern, and the current time - interval threshold updated in real - time better adapts to the respiratory detection of an individual at different times and different living states, avoiding the influence of a fixed threshold on the overall result.
[0032] 2. The detection process of the present invention is simple, reasonably designed, and easy to implement. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 is a flowchart of the present invention;
[0034] Figure 2 is a schematic diagram of the original respiratory flow data;
[0035] Figure 3 is a schematic diagram of the inspiratory flow data after convolution smoothing;
[0036] Figure 4 is a schematic diagram of the smoothed respiratory flow signal and the peak values of its first - order derivative;
[0037] Figure 5 is a schematic diagram for judging the breathing pattern according to the number of elements in the peak point set;
[0038] Figure 6 is a schematic diagram for realizing respiratory detection using an adaptive threshold (current time - interval threshold). DETAILED DESCRIPTION OF THE INVENTION
[0039] The following further describes the present invention with reference to the accompanying drawings.
[0040] As Figure 1 shown, a pulmonary function respiratory detection method based on an adaptive threshold includes the following steps:
[0041] Step 1: Conduct respiratory detection.
[0042] Step 2: Load the respiratory flow data in the form of a time stream at intervals of time t (and can be visualized using PyQt5), simulating the real pulmonary function examination process. Preferably, t is 2 seconds; perform convolution smoothing on the respiratory flow data to obtain a smoothed respiratory flow signal y(n), where n is the sampling point, Figure 2 and Figure 3respectively illustrate a respiratory flow data instance and the smoothed respiratory flow signal after convolution smoothing of the respiratory flow data. Since the sampling rate of the respiratory signal collected by the spirometer is 100 Hz, and the useful frequency band of the real respiratory signal is concentrated between 0.5 - 1.5 Hz, a large amount of respiratory noise will affect respiratory detection. Therefore, convolution smoothing is used to process the respiratory signal.
[0043] Step 3: Perform zero-crossing detection on y(n) to obtain the set A of zero-crossing point time positions, and the set A of zero-crossing point time positions is regarded as a set of potential respiratory start and end points.
[0044] Step 4: Take the first derivative of y(n) to obtain the first derivative X′(k), where k = 1, 2, …, m, and m = M - 1, M is the total number of sampling points M in the smoothed respiratory flow signal y(n), and X′(k) reflects the change in respiratory rate during the respiratory process.
[0045] Step 5: Use the local extreme value method to extract peak points from X′(k) to obtain the set B of peak points, and standardize the elements in the set B of peak points. Figure 4 illustrates Figure 3 the smoothed respiratory flow signal in
[0046] Step 6: Divide y(n) into three respiratory patterns according to the number of elements in the set B of peak points: rapid breathing pattern, normal breathing pattern, and slow breathing pattern. Figure 5 illustrates the Figure 3 respiratory patterns divided from the local signal of the smoothed respiratory flow signal in
[0047] Step 7: Adjust the current time interval threshold Tn according to the determined respiratory pattern.
[0048] Step 8: Screen the set A of zero-crossing point time positions according to the current time interval threshold Tn to determine the respiratory start and end point positions. Figure 6 illustrates the Figure 3 respiratory start and end point positions (black solid circle positions) determined in the local signal of the smoothed respiratory flow signal in
[0049] Step 9: Determine whether the respiratory detection continues. If it continues, return to Step 2 to execute.
[0050] Preferably, the convolution smoothing process in Step 2 is specifically:
[0051] Take a window with a length of 0.55 seconds, and use the least squares method to regress the window onto an L-degree polynomial, where L takes values of 3, 5, 7, or 9. In this embodiment, L = 5 is taken, and then the polynomial fitting is used to estimate the respiratory flow value at the center point of the window. The window slides across all the respiratory flow data in turn for polynomial fitting estimation until all the respiratory flow data is smoothed and the smoothed respiratory flow signal y(n) is returned.
[0052] Preferably, step 3 is specifically as follows:
[0053] Take windows W1 and W2 with a length of 0.05 seconds each; window W1 determines whether the respiratory flow values at the two positions x(n - 1) and x(n - 2) before the center point position x(n) of window W1 are negative, and whether the respiratory flow values at the two positions x(n + 1) and x(n + 2) after the center point position x(n) of window W1 are positive, and uses an analysis strategy to find the positions of the start point of exhalation and the end point of inhalation; window W2 determines whether the respiratory flow values at the two positions x'(n - 1) and x'(n - 2) before the center point position x'(n) of window W2 are positive, and whether the respiratory flow values at the two positions x'(n + 1) and x'(n + 2) after the center point position x'(n) of window W2 are negative, and uses an analysis strategy to find the positions of the end point of exhalation and the start point of inhalation. Windows W1 and W2 work alternately, and sequentially label and store all the center point positions of window W1 and the center point positions of window W2 that meet the analysis strategy into the zero-crossing point time position set A. Each element in the zero-crossing point time position set A is a potential start or end point of respiration.
[0054] Preferably, step 5 is specifically as follows:
[0055] Step 5.1: Take a window with a length of 0.5 seconds and slide it across the first derivative X'(k) in turn. The window adopts a local extreme point search strategy to find the position x(k) when the second derivative X''(k) is zero, and sequentially label and store the positions that meet the search strategy into the peak point set B.
[0056] Step 5.2: Standardize the elements in the peak point set B. The standardization formula is:
[0057]
[0058] where σ is the standard deviation of x(k), and
[0059] Preferably, step 6 is specifically as follows:
[0060] If the number of elements in the peak point set B is 2 or 3, it is at the normal level, and the breathing mode is determined to be the normal breathing mode (Normal Breathing Phase, NBP); if the number of elements in the peak point set B is greater than 3, it exceeds the normal level, and the breathing mode is determined to be the fast breathing mode (Fast Breathing Phase, FBP); if the number of elements in the peak point set B is less than 2, it is below the normal level, and the breathing mode is determined to be the slow breathing mode (Slow Breathing Phase, SBP).
[0061] Preferably, step 7 is specifically as follows:
[0062] When the breathing mode is the fast breathing mode and the normal breathing mode, the time interval between every two adjacent peak points in the peak point set B is averaged and denoted as T. If the current is the breathing detection within the first time interval t, directly use T as the current time interval threshold Tn; otherwise, use the average of T and the time interval threshold calculated within the previous time interval t as the current time interval threshold Tn. When the breathing mode is the slow breathing mode, perform a fast Fourier transform (FFT) on the smoothed breathing flow signal y(n), and obtain the minimum period by taking the reciprocal of the maximum frequency value f Use T′ as the current time interval threshold Tn.
[0063] Preferably, step 8 is specifically as follows:
[0064] Judge the time interval between every two adjacent zero-crossing points in the zero-crossing point time position set according to the current time interval threshold Tn. If the time interval is less than the current time interval threshold Tn, it is considered that the latter zero-crossing point is not the start or end point of breathing; otherwise, it is considered that the latter zero-crossing point is the start or end point of breathing, and the exhalation start point and the inhalation start point are alternately distributed, and the exhalation end point is the inhalation start point, and the inhalation end point is the exhalation start point. The exhalation end point and the inhalation end point do not need to be judged separately.
Claims
1. A lung function breathing detection method based on adaptive threshold, characterized in that: The following steps are involved: Step 1: Perform a breathing test; Step 2: Load the respiratory flow data in the form of a time stream at every time interval t, perform convolution smoothing on the respiratory flow data, and obtain a smoothed respiratory flow signal y(n), where n is a sampling point; Step 3, perform zero crossing detection on y(n) to obtain a zero crossing point time position set A; Step 4, calculate the first-order derivative of y(n) to obtain the first-order derivative X′(k), k=1, 2, …, m, where m=M-1, and M is the total number of sampling points M in the smoothed respiratory flow signal y(n); Step 5: Use the local extremum method to extract the peak value of X′(k) to obtain the peak point set B, and standardize the elements in the peak point set B; Step 6: Divide y(n) into three breathing modes according to the number of elements in the peak point set B: fast breathing mode, normal breathing mode and slow breathing mode; Step 7: adjusting the current time interval threshold Tn according to the determined breathing pattern; Step 8: Screen the zero-crossing point time position set A according to the current time interval threshold Tn to determine the breathing start and end point positions; Step 9: Determine whether the breathing detection continues. If it continues, return to step 2. The step 7 is specifically as follows: When the breathing mode is a fast breathing mode and a normal breathing mode, the time interval between each two adjacent peak points in the peak point set B is averaged and recorded as T. If the current breathing detection is within the first time interval t, T is directly used as the current time interval threshold Tn. Otherwise, T and the time interval threshold calculated within the previous time interval t are averaged and used as the current time interval threshold Tn. When the breathing mode is a slow breathing mode, the smoothed respiratory flow signal y(n) is fast Fourier transformed, and the inverse of the maximum frequency value f is taken to obtain the minimum period. Take T' as the current time interval threshold Tn.
2. The method for detecting lung function based on adaptive threshold according to claim 1, characterized in that: The convolution smoothing process in step 2 is specifically as follows: The least squares method is used to regress to the polynomial in the window, and then the polynomial fitting is used to estimate the respiratory flow value at the center point of the window; the window passes through all the respiratory flow data in turn for polynomial fitting estimation until all the respiratory flow data are smoothed and the smoothed respiratory flow signal y(n) is returned.
3. The method for detecting lung function based on adaptive threshold according to claim 1, characterized in that: The step 3 is specifically as follows: Take window W1 to determine whether the respiratory flow values at the two positions x(n-1) and x(n-2) before the center point position x(n) of window W1 are negative, and the respiratory flow values at the two positions x(n+1) and x(n+2) after the center point position x(n) of window W1 are positive, and use the analysis strategy to find the positions of the start point of exhalation and the end point of inhalation; take window W2 to determine whether the respiratory flow values at the two positions x'(n-1) and x'(n-2) before the center point position x'(n) of window W2 are positive, and use the analysis strategy to find the positions of the end point of exhalation and the start point of inhalation; window W1 and window W2 work alternately, and all the center point positions of window W1 and window W2 that meet the analysis strategy are sequentially marked and stored in the zero crossing point time position set A.
4. The method for detecting lung function based on adaptive threshold according to claim 1, characterized in that: The step 5 is specifically as follows: Step 5.1, take the window that adopts the local extreme point search strategy and sequentially pass through the first-order derivative X′(k), find the position x(k) when the second-order derivative X″(k) is zero, and mark the positions that meet the search strategy in order and store them in the peak point set B; Step 5.2: Standardize the elements in the peak point set B. The standardization formula is: Where σ is the standard deviation of x(k), is the mean of x(k), and X(k) is the standardized value of x(k).
5. The method for detecting lung function based on adaptive threshold according to claim 1, characterized in that: The step 6 is specifically as follows: If the number of elements in the peak point set B is 2 or 3, the breathing mode is determined to be a normal breathing mode; if the number of elements in the peak point set B is greater than 3, the breathing mode is determined to be a fast breathing mode; if the number of elements in the peak point set B is less than 2, the breathing mode is determined to be a slow breathing mode.
6. The method for detecting lung function based on adaptive threshold according to claim 1, characterized in that: The step 8 is specifically as follows: The time interval between each two adjacent zero crossing points in the zero crossing point time position set is judged according to the current time interval threshold Tn. If the time interval is less than the current time interval threshold Tn, the next zero crossing point is considered not to be the start or end point of breathing. Otherwise, the next zero crossing point is considered to be the start or end point of breathing, and the start point of exhalation and the start point of inhalation are alternately distributed.
Citation Information
Patent Citations
Collection and analysis of volume of exhaled gas with compensation for frequency of breathing parameter
CN107874761A
Non-contact respiratory rate detection method based on depth image
CN113628205A