A method and system for correcting blood sodium detection
By segmenting spectral data into different regions and setting specific parameters, the problem of asymmetric least squares algorithm struggling to balance peak shape and noise smoothing in serum sodium spectral measurement is solved, achieving more accurate baseline correction and serum sodium measurement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- THE NAVAL MEDICAL UNIV OF PLA
- Filing Date
- 2026-03-24
- Publication Date
- 2026-07-28
AI Technical Summary
Existing asymmetric least squares algorithms struggle to simultaneously preserve peak shape information and smooth noise of varying degrees when processing serum sodium spectra, leading to inaccurate measurements.
The spectral data is divided into peak regions and baseline flat regions. Asymmetry factors and smoothing factors are set for each region. A continuous smooth total baseline is generated by piecewise fitting and spline interpolation. The bottom contour of the signal peaks is identified and the smoothing degree is determined based on the local noise level.
It improves the accuracy of spectral baseline correction, ensures the preservation of key information in the peak region and the smoothness of the baseline flat region, generates a continuous and smooth total baseline, and improves the accuracy of serum sodium measurement.
Smart Images

Figure CN122468655A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of detection and calibration, and in particular relates to a method and system for calibrating blood sodium detection. Background Technology
[0002] Serum sodium is an important electrolyte in the human body. Hyponatremia or hypernatremia not only directly reflects the relative loss or retention of water and sodium, but is also related to potential pathological conditions such as endocrine disorders, renal dysfunction, heart failure, cirrhosis, or dehydration. Monitoring serum sodium levels can guide clinical treatment decisions such as fluid replacement and medication, and assess the severity of the condition and prognosis, which is crucial for maintaining normal cellular function and life activities. Spectroscopic analysis techniques, such as atomic emission spectroscopy and near-infrared spectroscopy, are important directions in the field of real-time detection of electrolytes such as serum sodium. However, in actual spectral acquisition, due to fluctuations in instrument light source and detector performance, changes in environmental temperature and humidity, scattering effects of the sample itself, and interference from other complex components in the blood matrix, the acquired raw spectral signal is often superimposed with a slowly changing background signal, i.e., baseline drift. This baseline drift overlaps with the true characteristic peak signal of serum sodium, reducing the signal-to-noise ratio and resolution of the spectrum. Therefore, baseline correction is performed on the raw spectral data before quantitative analysis.
[0003] Various methods exist for spectral baseline correction, such as polynomial fitting, derivative methods, and wavelet transform. Among these, the asymmetric least squares algorithm (AsLS) has become a mainstream baseline correction technique due to its high degree of automation and wide applicability. AsLS assigns different weights to spectral points above and below the current baseline during iterative fitting, allowing the fitted curve to pass through the bottom of the signal peaks and achieve baseline-signal separation. When processing the entire spectrum, AsLS typically employs a uniform asymmetry factor and smoothing factor. For blood sample spectra with complex composition, the signal characteristics vary significantly across different wavenumber ranges, potentially including steep, sharp characteristic peak regions as well as flat baseline regions with varying noise levels. It is difficult to simultaneously preserve peak shape information and smooth noise of varying degrees, easily leading to peak shape distortion in peak regions or baseline underfitting or overfitting in flat regions, resulting in inaccurate serum sodium measurements. Summary of the Invention
[0004] This invention proposes a blood sodium detection correction method to address the problem of low accuracy in spectral baseline correction, comprising:
[0005] Obtain the raw spectral data of the sample to be tested; based on the sign change of the first derivative and the extreme value of the second derivative of the raw spectral data, divide the raw spectral data into at least one peak region and at least one baseline flat region, and calculate the local noise level parameter of each baseline flat region;
[0006] For the peak region, a first asymmetry factor and a first smoothing factor are set; for the baseline flat region, a second asymmetry factor is set, and the second smoothing factor is determined based on the local noise level parameter of the set region.
[0007] Asymmetric least squares iterative fitting is performed on each segmented region. In each iteration, the residual between the spectral data point and the current fitted baseline is calculated, and the weights are updated according to the residual: when the residual is positive, the weight is a function related to the residual and the minimum local noise level parameter in all baseline flat regions; when the residual is not positive, the weight is 1 minus the asymmetric factor set for the region where the spectral data point is located.
[0008] When iteratively fitting subsequent segmented regions, the terminal baseline point obtained from fitting the previous segmented region is used as the initial constraint for the current segmented region iteration to obtain the sub-baseline of each segmented region; spline interpolation is performed on all sub-baselines to generate a continuous and smooth total baseline covering the entire spectral data; the corrected blood sodium spectral data is obtained by subtracting the total baseline from the original spectral data.
[0009] Optionally, based on the sign change of the first derivative and the extrema of the second derivative of the original spectral data, the original spectral data is segmented into at least one peak region and at least one baseline flat region, and the local noise level parameter of each baseline flat region is calculated, including:
[0010] After smoothing and filtering the original spectral data, the first and second derivatives are calculated.
[0011] The region where the first derivative changes from a positive value to a negative value and the corresponding second derivative value is a local minimum is identified as the peak region.
[0012] Regions where the absolute value of the second derivative is continuously less than a preset threshold are identified as baseline flat regions.
[0013] The second derivative value within the flat region of the baseline is calculated using the root mean square method, and the calculation result is used as the local noise level parameter.
[0014] Optionally, the step of setting a first asymmetry factor and a first smoothing factor for the peak region; setting a second asymmetry factor for the baseline flat region, and determining the second smoothing factor based on the local noise level parameter of the set region, includes:
[0015] The first asymmetry factor is set to 0.001, and the first smoothing factor is... ;
[0016] The second asymmetry factor is set to 0.5, and the second smoothing factor is determined by the formula... The calculation yielded, where The local noise level parameter for the baseline flat region.
[0017] Optionally, the step of calculating the residual between the spectral data points and the current fitted baseline in each iteration, and updating the weights based on the residual, includes:
[0018] Let the spectral data points be denoted as The current fitted baseline point is residual ;
[0019] Let the parameter representing the minimum local noise level in all flat baseline regions be . ;
[0020] When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data points are located;
[0021] When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data point is located.
[0022] Optionally, the step of using the endpoint baseline point obtained from fitting the previous segmented region as the initial constraint for iterating the current segmented region when iterating and fitting subsequent segmented regions includes:
[0023] Let the value of the final baseline point obtained by fitting the (k-1)th segment region be... ;
[0024] The linear equation system is solved by iterative fitting over the k-th segmented region. When, replace the first line of the system of equations with Where z is the baseline to be determined, i.e., the baseline vector, and y is the original spectral data. Let D be the smoothing factor, D be the difference matrix, and the weight matrix be... Set the first row and first column element to a maximum value This achieves the initial constraints.
[0025] Optionally, the step of performing spline interpolation to connect all sub-baselines to generate a continuous, smooth total baseline covering the entire spectral data includes:
[0026] Extract the first and last endpoints of the sub-baselines of each segmented region, and use all endpoints as a sequence of control points;
[0027] The control point sequence is fitted using a cubic spline interpolation algorithm to generate the continuous smooth total baseline.
[0028] Furthermore, the present invention also relates to a blood sodium detection correction system, comprising the following modules:
[0029] The calculation module is used to acquire the original spectral data of the sample to be tested; based on the sign change of the first derivative and the extreme value of the second derivative of the original spectral data, the original spectral data is divided into at least one peak region and at least one baseline flat region, and the local noise level parameter of each baseline flat region is calculated.
[0030] A setting module is used to set a first asymmetry factor and a first smoothing factor for the peak region; set a second asymmetry factor for the baseline flat region, and determine a second smoothing factor based on the local noise level parameter of the set region;
[0031] The update module performs asymmetric least squares iterative fitting on each segmented region. In each iteration, it calculates the residual between the spectral data points and the current fitted baseline, and updates the weights based on the residual.
[0032] When the residual is positive, the weight is a function relating the residual and the minimum local noise level parameter in all baseline flat regions; when the residual is not positive, the weight is 1 minus the asymmetry factor set for the region where the spectral data point is located.
[0033] The correction module is used to take the end baseline point obtained by fitting the previous segment region as the initial constraint for the current segment region iteration when iterating and fitting subsequent segment regions, so as to obtain the sub-baseline of each segment region; to perform spline interpolation to connect all sub-baselines to generate a continuous smooth total baseline covering the entire spectral data; and to obtain the corrected blood sodium spectral data by subtracting the total baseline from the original spectral data.
[0034] Preferably, the step of segmenting the original spectral data into at least one peak region and at least one baseline flat region based on the first derivative sign change and second derivative extrema, and calculating the local noise level parameter for each baseline flat region, includes:
[0035] After smoothing and filtering the original spectral data, the first and second derivatives are calculated.
[0036] The region where the first derivative changes from a positive value to a negative value and the corresponding second derivative value is a local minimum is identified as the peak region.
[0037] Regions where the absolute value of the second derivative is continuously less than a preset threshold are identified as baseline flat regions.
[0038] The second derivative value within the flat region of the baseline is calculated using the root mean square method, and the calculation result is used as the local noise level parameter.
[0039] Preferably, the step of setting a first asymmetry factor and a first smoothing factor for the peak region, and setting a second asymmetry factor for the baseline flat region, and determining the second smoothing factor based on the local noise level parameter of the set region, includes:
[0040] The first asymmetry factor is set to 0.001, and the first smoothing factor is... ;
[0041] The second asymmetry factor is set to 0.5, and the second smoothing factor is determined by the formula... The calculation yielded, where The local noise level parameter for the baseline flat region.
[0042] Preferably, the step of calculating the residual between the spectral data points and the current fitted baseline in each iteration, and updating the weights based on the residual, includes:
[0043] Let the spectral data points be denoted as The current fitted baseline point is residual ;
[0044] Let the parameter representing the minimum local noise level in all flat baseline regions be . ;
[0045] When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data points are located;
[0046] When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data point is located.
[0047] Optionally, the step of using the endpoint baseline point obtained from fitting the previous segmented region as the initial constraint for iterating the current segmented region when iterating and fitting subsequent segmented regions includes:
[0048] Let the value of the final baseline point obtained by fitting the (k-1)th segment region be... ;
[0049] The linear equation system is solved by iterative fitting over the k-th segmented region. When, replace the first line of the system of equations with Where z is the baseline to be determined, i.e., the baseline vector, and y is the original spectral data. Let D be the smoothing factor, D be the difference matrix, and the weight matrix be... Set the first row and first column element to a maximum value This achieves the initial constraints.
[0050] Optionally, the step of performing spline interpolation to connect all sub-baselines to generate a continuous, smooth total baseline covering the entire spectral data includes:
[0051] Extract the first and last endpoints of the sub-baselines of each segmented region, and use all endpoints as a sequence of control points;
[0052] The control point sequence is fitted using a cubic spline interpolation algorithm to generate the continuous smooth total baseline.
[0053] Compared to existing asymmetric least squares algorithms that use globally uniform parameters, this invention segments spectral data into peak regions and baseline-flat regions, and sets fitting parameters for each region based on its characteristics. For peak regions, the bottom contour of the signal peaks can be identified, preserving key peak shape information; for baseline-flat regions with varying noise levels, the smoothness is determined based on the local noise level of the region. Furthermore, through piecewise fitting constraints and spline interpolation, the continuity and smoothness of the generated total baseline across the entire spectral range are ensured. Attached Figure Description
[0054] Figure 1 This is a flowchart of Example 1;
[0055] Figure 2 This is a schematic diagram of the original spectral data;
[0056] Figure 3 This is a schematic diagram of the piecewise baseline fitting.
[0057] Figure 4 This is a schematic diagram of the overall baseline;
[0058] Figure 5 This is a schematic diagram of the baseline correction results. Detailed Implementation
[0059] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with relevant laws, regulations, and standards, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0060] In the first embodiment, the present invention proposes a blood sodium detection correction method, such as... Figure 1 As shown, it includes:
[0061] S1, Obtain the original spectral data of the sample to be tested; Based on the sign change of the first derivative and the extreme value of the second derivative of the original spectral data, divide the original spectral data into at least one peak region and at least one baseline flat region, and calculate the local noise level parameter of each baseline flat region;
[0062] Serum samples were scanned using a near-infrared spectrometer, acquiring spectra in the range of 4000 to 10000 wavenumbers per centimeter. The resulting one-dimensional vector, composed of wavenumber and corresponding absorbance, was used as the raw spectral data. Figure 2 Preferably, the first and second derivative spectra of the original spectral data are calculated using the Savitzky-Golay smoothing algorithm. The second derivative spectrum is traversed, and local minima below a preset negative threshold are identified as potential peak locations. Zero-crossing points in the second derivative spectrum are searched outwards from each peak, and the region between two zero-crossing points is defined as the peak region. The remaining unlabeled regions are defined as baseline flat regions. The standard deviation of the first derivative data within each identified baseline flat region is calculated, and this standard deviation is used as a parameter for the local noise level of that region.
[0063] To automatically segment complex spectral data into easily processed peak and baseline regions, in an optional embodiment, the original spectral data is segmented into at least one peak region and at least one baseline flat region based on the first derivative sign change and second derivative extrema of the original spectral data, and the local noise level parameter of each baseline flat region is calculated, including:
[0064] After smoothing and filtering the original spectral data, the first and second derivatives are calculated.
[0065] The region where the first derivative changes from a positive value to a negative value and the corresponding second derivative value is a local minimum is identified as the peak region.
[0066] Regions where the absolute value of the second derivative is continuously less than a preset threshold are identified as baseline flat regions.
[0067] The second derivative value within the flat region of the baseline is calculated using the root mean square method, and the calculation result is used as the local noise level parameter.
[0068] Taking a Raman spectrum containing 1000 data points as an example, a Savitzky-Golay smoothing filter with a window size of 15 is applied to the original data. Filtering reduces the interference of random noise and calculates the first and second derivatives for each data point. This derivative information is key to identifying spectral features.
[0069] Different regions are distinguished by analyzing the variation patterns of the derivatives. For example, between the 300th and 350th data points in the spectrum, if the first derivative gradually decreases from a positive value (e.g., 0.2), crosses zero, and becomes a negative value (e.g., -0.15), and the second derivative at the zero-crossing point is a local minimum (e.g., -0.5), this region is identified as a peak region containing a characteristic peak. Conversely, if between the 500th and 600th data points, the absolute values of the second derivatives at multiple consecutive points are all less than a preset threshold of 0.005, it indicates that the curvature of this region is very small, the spectral shape is flat, and it is identified as a region with a flat baseline.
[0070] Each identified flat baseline region needs to have its noise level represented. Taking the baseline region from point 500 to 600 as an example, the second derivative values of all points within this region are extracted and calculated using the root mean square method. This involves squaring each second derivative value, such as 0.001, -0.002, 0.0015, etc., calculating their average value, and then taking the square root of the result. Assuming the calculated root mean square value is 0.0023, this value is used as a local noise level parameter for this region to adjust the smoothness of the baseline fitting.
[0071] S2, for the peak region, set a first asymmetry factor and a first smoothing factor; for the baseline flat region, set a second asymmetry factor, and determine the second smoothing factor according to the local noise level parameter of the set region;
[0072] Specifically, for all peak regions, a first asymmetry factor is uniformly set. A small value, such as 0.01, allows the baseline to pass below the peak signal; this sets the first smoothing factor. Set a small value, such as 10 to the power of 3. For regions with flat baselines, set a second asymmetry factor. A value close to 0.5, such as 0.48, is used to symmetrically handle noise fluctuations. This is the second smoothing factor for this region. The smoothing effect is achieved by using a formula such as λ2=C×σ, preferably with C being 10 to the power of 7, so that areas with higher noise levels receive a stronger smoothing effect.
[0073] To assign different fitting control parameters to spectral regions of different properties to achieve baseline subtraction, in an optional embodiment, a first asymmetry factor and a first smoothing factor are set for the peak region; a second asymmetry factor is set for the baseline flat region, and a second smoothing factor is determined based on the local noise level parameter of the set region, including:
[0074] The first asymmetry factor is set to 0.001, and the first smoothing factor is... ;
[0075] The second asymmetry factor is set to 0.5, and the second smoothing factor is determined by the formula... The calculation yielded, where The local noise level parameter for the baseline flat region.
[0076] Specifically, the peak regions in the spectrum are the main carriers of the signal, and should not be disturbed by the peak signals when fitting the baseline; while the flat regions of the baseline reflect the true baseline position and noise level, and should be fitted as close as possible to the data points.
[0077] For the previously identified peak region, such as data points 300 to 350, a special combination of parameters is set. The first asymmetry factor is set to a very small value of 0.001, while the first smoothing factor is set to a very large value of 10 to the power of 8. The extremely small asymmetry factor results in a significant penalty when the fitted baseline point is above the original data point, thus forcing the baseline to be below the peak. The extremely large smoothing factor, on the other hand, makes this baseline exceptionally smooth, close to a straight line, avoiding the problem of the baseline bending towards the peak.
[0078] For regions with flat baselines, such as the area between points 500 and 600, a different set of parameters is used. The second asymmetry factor is set to 0.5, a value close to symmetry that allows the fitted baseline to symmetrically cross the data points. The second smoothing factor depends on the local noise level parameter. For example, if the local noise level parameter for the region is 0.0023, then the smoothing factor is calculated using a formula and is approximately equal to 10 to the power of 3.0092.
[0079] S3, perform asymmetric least squares iterative fitting on each segmented region. In each iteration, calculate the residual between the spectral data point and the current fitted baseline, and update the weights based on the residual: when the residual is positive, the weight is a function related to the residual and the minimum local noise level parameter in all baseline flat regions; when the residual is not positive, the weight is 1 minus the asymmetric factor set for the region where the spectral data point is located.
[0080] Specifically, within each segmented region, the baseline z is iteratively updated by minimizing an objective function, which is the weighted sum of the sum of squared weighted errors and the sum of squared second-order differences of the baseline. During the iteration, if the original spectral value of a point i... Not greater than the current baseline value Its weight =1-p, where p is the asymmetry factor set for this region. If Greater than Its weight This is equal to p multiplied by an attenuation term, which is calculated based on the residuals, making the weight of the signal peaks much smaller than the weight of the baseline points. To distinguish between the signal and the baseline, in an optional embodiment, calculating the residual between the spectral data points and the currently fitted baseline in each iteration, and updating the weights based on the residuals, includes:
[0081] Let the spectral data points be denoted as The current fitted baseline point is residual ;
[0082] Let the parameter representing the minimum local noise level in all flat baseline regions be . ;
[0083] When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data points are located;
[0084] When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data point is located.
[0085] Specifically, in each iteration, the contribution of a data point to the baseline shape is reassessed, and a new weight is assigned to it. The magnitude of this weight determines the influence of the data point in the next baseline calculation.
[0086] The weights are calculated differently depending on the relative position of the data point to the current baseline. A baseline noise level is required, using the minimum local noise level parameter calculated in all flat regions of the baseline, assuming a value of 0.0015. Consider a data point located in a peak region with a value of 1.5, while the baseline for the current iteration has a value of 1.1 in that region. The residual is then positive 0.4. The asymmetry factor of the region where this point is located is 0.001, and its weight will be calculated as 0.001 multiplied by an exponentially decaying term. Since the residual is greater than the noise level, this exponential term will approach zero, resulting in a weight very close to zero.
[0087] The situation is entirely different when a data point is below the current baseline. Suppose a data point has a value of 1.0 and the current baseline value is 1.1, then the residual is -0.1. The weight is calculated as 1 minus the asymmetry factor set for that region. If the point is in the peak region with an asymmetry factor of 0.001, then its weight is 0.999. If it is in the baseline region with an asymmetry factor of 0.5, then its weight is 0.5.
[0088] S4, when iteratively fitting subsequent segmented regions, the end baseline point obtained from fitting the previous segmented region is used as the initial constraint for iterating the current segmented region to obtain the sub-baseline of each segmented region; spline interpolation is performed on all sub-baselines to generate a continuous and smooth total baseline covering the entire spectral data; the corrected blood sodium spectral data is obtained by subtracting the total baseline from the original spectral data.
[0089] Specifically, after completing the iterative fitting of the first segmented region, the baseline value corresponding to the last data point is recorded. When fitting the second adjacent segmented region, the equation in the linear equation system corresponding to the first data point in that region is forcibly replaced with... = Using this as the boundary constraint, we then iteratively solve the problem to ensure that the values at the connection point of the two sub-baselines are equal.
[0090] All sub-baseline data points calculated from all segmented regions are merged into a complete set of baseline points in wavenumber order, such as... Figure 3 A cubic spline interpolation algorithm is used to fit the baseline point set, generating a smooth curve that is continuous across the entire spectral wavenumber range and has a continuous second derivative; this curve is the total baseline. The original spectral data vector is subtracted point-by-point from the total baseline vector generated in the previous step at each corresponding wavenumber point, resulting in a new spectral data vector containing the characteristic peak information of purified serum sodium; this is the corrected serum sodium spectrum. After obtaining the serum sodium spectrum, the serum sodium content is calculated according to a pre-established formula or model.
[0091] To address potential discontinuities in spectrum segmentation during processing and ensure a smooth transition of the generated baseline at segmentation points, in an optional embodiment, when iteratively fitting subsequent segmented regions, the endpoint of the fitted previous segment is used as the initial constraint for the current segment iteration, including:
[0092] Let the value of the final baseline point obtained by fitting the (k-1)th segment region be... ;
[0093] The linear equation system is solved by iterative fitting over the k-th segmented region. When, replace the first line of the system of equations with Where z is the baseline to be determined, i.e., the baseline vector, and y is the original spectral data. Let D be the smoothing factor, D be the difference matrix, and set the first row and first column element of the weight matrix W to a maximum value. This achieves the initial constraints.
[0094] Because the entire spectrum is segmented into multiple regions for independent iterative fitting, without constraints, the calculated sub-baselines for each region may exhibit a step at the boundary, meaning the end point of one segment is numerically unequal to the beginning point of the next, resulting in a broken baseline. Assume that baseline fitting for the first spectral region, i.e., data points 1 to 200, has been completed, and the baseline value for its last point, the 200th point, has been calculated to be 0.85. This value of 0.85 will be used as the initial baseline value for the next segmented region, starting from the 201st data point. When fitting the second region, a hard condition is set: the value of the first baseline point in the second region must be equal to 0.85.
[0095] To implement this hard constraint in numerical computation, the system of linear equations for solving the baseline is modified. Originally, this system solved for all baseline points by minimizing the weighted sum of squared residuals. The entire first line of the equations is replaced with a simple equation representing the first point of the new baseline. =0.85. Meanwhile, to ensure the equation is strictly adhered to during the solution process, the first diagonal element in the weight matrix corresponding to this point is set to a very large value, such as 10 to the power of 10.
[0096] In an optional embodiment, spline interpolation is performed on all sub-baselines to generate a continuous, smooth total baseline covering the entire spectral data, such as... Figure 4 ,include:
[0097] Extract the first and last endpoints of the sub-baselines of each segmented region, and use all endpoints as a sequence of control points;
[0098] The control point sequence is fitted using a cubic spline interpolation algorithm to generate the continuous smooth total baseline.
[0099] Although the previous step ensures that the values of each sub-baseline are equal at the endpoints, their slopes may be inconsistent at the connection points, resulting in sharp corners and insufficient smoothness. This problem is solved by using a higher-order interpolation method to achieve higher-order continuity.
[0100] Key connection points are extracted from all calculated segmented sub-baselines, i.e., the start and end points of each segment. For example, if the spectrum is divided into three regions for processing: the first region is points 1 to 200, the second is points 201 to 450, and the third is points 451 to 700, the coordinates and corresponding baseline values of points 1, 200, 450, and 700 are extracted. These points together form a control point sequence, defining the key inflection points of the entire baseline. Cubic spline interpolation is used to fit this control point sequence. Cubic spline interpolation constructs a cubic polynomial curve between each pair of adjacent control points, ensuring that at each control point, the function values, first derivative, and second derivative values of the polynomial curves of adjacent segments are equal. This means that the generated total baseline is not only continuous, but its slope and curvature also change continuously, resulting in a smooth curve without sharp inflection points. The smooth total baseline generated by spline interpolation is used to correct the baseline of the original spectrum, such as... Figure 5 .
[0101] In a second embodiment, the present invention proposes a blood sodium detection correction system, comprising the following modules:
[0102] The calculation module is used to acquire the original spectral data of the sample to be tested; based on the sign change of the first derivative and the extreme value of the second derivative of the original spectral data, the original spectral data is divided into at least one peak region and at least one baseline flat region, and the local noise level parameter of each baseline flat region is calculated.
[0103] A setting module is used to set a first asymmetry factor and a first smoothing factor for the peak region; set a second asymmetry factor for the baseline flat region, and determine a second smoothing factor based on the local noise level parameter of the set region;
[0104] The update module performs asymmetric least squares iterative fitting on each segmented region. In each iteration, it calculates the residual between the spectral data points and the current fitted baseline, and updates the weights based on the residual.
[0105] When the residual is positive, the weight is a function relating the residual and the minimum local noise level parameter in all baseline flat regions; when the residual is not positive, the weight is 1 minus the asymmetry factor set for the region where the spectral data point is located.
[0106] The correction module is used to take the end baseline point obtained by fitting the previous segment region as the initial constraint for the current segment region iteration when iterating and fitting subsequent segment regions, so as to obtain the sub-baseline of each segment region; to perform spline interpolation to connect all sub-baselines to generate a continuous smooth total baseline covering the entire spectral data; and to obtain the corrected blood sodium spectral data by subtracting the total baseline from the original spectral data.
[0107] Preferably, the step of segmenting the original spectral data into at least one peak region and at least one baseline flat region based on the first derivative sign change and second derivative extrema, and calculating the local noise level parameter for each baseline flat region, includes:
[0108] After smoothing and filtering the original spectral data, the first and second derivatives are calculated.
[0109] The region where the first derivative changes from a positive value to a negative value and the corresponding second derivative value is a local minimum is identified as the peak region.
[0110] Regions where the absolute value of the second derivative is continuously less than a preset threshold are identified as baseline flat regions.
[0111] The second derivative value within the flat region of the baseline is calculated using the root mean square method, and the calculation result is used as the local noise level parameter.
[0112] Preferably, the step of setting a first asymmetry factor and a first smoothing factor for the peak region, and setting a second asymmetry factor for the baseline flat region, and determining the second smoothing factor based on the local noise level parameter of the set region, includes:
[0113] The first asymmetry factor is set to 0.001, and the first smoothing factor is... ;
[0114] The second asymmetry factor is set to 0.5, and the second smoothing factor is determined by the formula... The calculation yielded, where The local noise level parameter for the baseline flat region.
[0115] Preferably, the step of calculating the residual between the spectral data points and the current fitted baseline in each iteration, and updating the weights based on the residual, includes:
[0116] Let the spectral data points be denoted as The current fitted baseline point is residual ;
[0117] Let the parameter representing the minimum local noise level in all flat baseline regions be . ;
[0118] When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data points are located;
[0119] When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data point is located.
[0120] Optionally, the step of using the endpoint baseline point obtained from fitting the previous segmented region as the initial constraint for iterating the current segmented region when iterating and fitting subsequent segmented regions includes:
[0121] Let the value of the final baseline point obtained by fitting the (k-1)th segment region be... ;
[0122] The linear equation system is solved by iterative fitting over the k-th segmented region. When, replace the first line of the system of equations with Where z is the baseline to be determined, i.e., the baseline vector, and y is the original spectral data. Let D be the smoothing factor, D be the difference matrix, and the weight matrix be... Set the first row and first column element to a maximum value This achieves the initial constraints.
[0123] Optionally, the step of performing spline interpolation to connect all sub-baselines to generate a continuous, smooth total baseline covering the entire spectral data includes:
[0124] Extract the first and last endpoints of the sub-baselines of each segmented region, and use all endpoints as a sequence of control points;
[0125] The control point sequence is fitted using a cubic spline interpolation algorithm to generate the continuous smooth total baseline.
[0126] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0127] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for calibrating blood sodium levels, characterized in that, include: Obtain the raw spectral data of the sample to be tested; based on the sign change of the first derivative and the extreme value of the second derivative of the raw spectral data, divide the raw spectral data into at least one peak region and at least one baseline flat region, and calculate the local noise level parameter of each baseline flat region; For the peak region, a first asymmetry factor and a first smoothing factor are set; for the baseline flat region, a second asymmetry factor is set, and the second smoothing factor is determined based on the local noise level parameter of the set region. Asymmetric least squares iterative fitting is performed on each segmented region. In each iteration, the residual between the spectral data point and the current fitted baseline is calculated, and the weights are updated according to the residual: when the residual is positive, the weight is a function related to the residual and the minimum local noise level parameter in all baseline flat regions; when the residual is not positive, the weight is 1 minus the asymmetric factor set for the region where the spectral data point is located. When iteratively fitting subsequent segmented regions, the terminal baseline point obtained from fitting the previous segmented region is used as the initial constraint for the current segmented region iteration to obtain the sub-baseline of each segmented region; spline interpolation is performed on all sub-baselines to generate a continuous and smooth total baseline covering the entire spectral data; the corrected blood sodium spectral data is obtained by subtracting the total baseline from the original spectral data.
2. The method according to claim 1, characterized in that, Based on the sign change of the first derivative and the extrema of the second derivative of the original spectral data, the original spectral data is segmented into at least one peak region and at least one baseline flat region, and the local noise level parameter of each baseline flat region is calculated, including: After smoothing and filtering the original spectral data, the first and second derivatives are calculated. The region where the first derivative changes from a positive value to a negative value and the corresponding second derivative value is a local minimum is identified as the peak region. Regions where the absolute value of the second derivative is continuously less than a preset threshold are identified as baseline flat regions. The second derivative value within the flat region of the baseline is calculated using the root mean square method, and the calculation result is used as the local noise level parameter.
3. The method according to claim 1, characterized in that, The steps include setting a first asymmetry factor and a first smoothing factor for the peak region; setting a second asymmetry factor for the baseline flat region; and determining the second smoothing factor based on the local noise level parameters of the set regions, including: The first asymmetry factor is set to 0.001, and the first smoothing factor is... ; The second asymmetry factor is set to 0.5, and the second smoothing factor is determined by the formula... The calculation yielded, where The local noise level parameter for the baseline flat region.
4. The method according to claim 1, characterized in that, In each iteration, the residual between the spectral data points and the current fitted baseline is calculated, and the weights are updated based on the residual, including: Let the spectral data points be denoted as The current fitted baseline point is residual ; Let the parameter representing the minimum local noise level in all flat baseline regions be . ; When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data points are located; When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data point is located.
5. The method according to claim 1, characterized in that, When iteratively fitting subsequent segmented regions, the endpoint baseline point obtained from fitting the previous segmented region is used as the initial constraint for the current segmented region iteration, including: Let the value of the final baseline point obtained by fitting the (k-1)th segment region be... ; The linear equation system is solved by iterative fitting over the k-th segmented region. When, replace the first line of the system of equations with Where z is the baseline to be determined, i.e., the baseline vector, and y is the original spectral data. Let D be the smoothing factor, D be the difference matrix, and set the first row and first column element of the weight matrix W to a maximum value. This achieves the initial constraints.
6. The method according to claim 1, characterized in that, The step of performing spline interpolation to connect all sub-baselines to generate a continuous, smooth total baseline covering the entire spectral data includes: Extract the first and last endpoints of the sub-baselines of each segmented region, and use all endpoints as a sequence of control points; The control point sequence is fitted using a cubic spline interpolation algorithm to generate the continuous smooth total baseline.
7. A blood sodium detection and correction system, characterized in that, Includes the following modules: The calculation module is used to acquire the original spectral data of the sample to be tested; based on the sign change of the first derivative and the extreme value of the second derivative of the original spectral data, the original spectral data is divided into at least one peak region and at least one baseline flat region, and the local noise level parameter of each baseline flat region is calculated. A setting module is used to set a first asymmetry factor and a first smoothing factor for the peak region; set a second asymmetry factor for the baseline flat region, and determine a second smoothing factor based on the local noise level parameter of the set region; The update module is used to perform asymmetric least squares iterative fitting on each segmented region. In each iteration, the residual between the spectral data point and the current fitted baseline is calculated, and the weights are updated according to the residual: when the residual is positive, the weight is a function related to the residual and the minimum local noise level parameter in all baseline flat regions; when the residual is not positive, the weight is 1 minus the asymmetric factor set for the region where the spectral data point is located. The correction module is used to take the end baseline point obtained by fitting the previous segment region as the initial constraint for the current segment region iteration when iterating and fitting subsequent segment regions, so as to obtain the sub-baseline of each segment region; to perform spline interpolation to connect all sub-baselines to generate a continuous smooth total baseline covering the entire spectral data; and to obtain the corrected blood sodium spectral data by subtracting the total baseline from the original spectral data.
8. The system according to claim 7, characterized in that, Based on the sign change of the first derivative and the extrema of the second derivative of the original spectral data, the original spectral data is segmented into at least one peak region and at least one baseline flat region, and the local noise level parameter of each baseline flat region is calculated, including: After smoothing and filtering the original spectral data, the first and second derivatives are calculated. The region where the first derivative changes from a positive value to a negative value and the corresponding second derivative value is a local minimum is identified as the peak region. Regions where the absolute value of the second derivative is continuously less than a preset threshold are identified as baseline flat regions. The second derivative value within the flat region of the baseline is calculated using the root mean square method, and the calculation result is used as the local noise level parameter.
9. The system according to claim 7, characterized in that, The steps include setting a first asymmetry factor and a first smoothing factor for the peak region; setting a second asymmetry factor for the baseline flat region; and determining the second smoothing factor based on the local noise level parameters of the set regions, including: The first asymmetry factor is set to 0.001, and the first smoothing factor is... ; The second asymmetry factor is set to 0.5, and the second smoothing factor is determined by the formula... The calculation yielded, where The local noise level parameter for the baseline flat region.
10. The system according to claim 7, characterized in that, In each iteration, the residual between the spectral data points and the current fitted baseline is calculated, and the weights are updated based on the residual, including: Let the spectral data points be denoted as The current fitted baseline point is residual ; Let the parameter representing the minimum local noise level in all flat baseline regions be . ; When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data points are located; When the residual At that time, weight , where p is the asymmetry factor set for the region where the spectral data point is located.