Baseline, smoothing, and curve preprocessing

Separating the background from a peak and reducing the fluctuations of a signal are different operations. Curve Fitter performs both while keeping the original data and creating new Datasets with the information needed to interpret the result.

Reference interface: GX-TXT DEV112-P011 · Dataset Curve Fit.

A peak superimposed on a varying baseline

Consider a signal in volts, observed at 41 instants between 0 and 40 seconds. The response consists of a slowly rising background, a peak centered near 20 seconds and small superimposed fluctuations.

We can represent it schematically as:

U(t) = B(t) + P(t) + ε(t)

where B(t) is the baseline, P(t) is the peak component and ε(t) collects the fluctuations. In our teaching example the components are synthetic and declared: B(t) = 0.45 V + (0.009 V/s)·t and the peak has a nominal amplitude of about 2.1 V.

An incorrect baseline can distort the height, the area and even the meaning of the estimated parameters. Smoothing, on the other hand, acts on local variations: it can make a curve more regular, but it does not replace background removal.

Figure 1. Original signal with 41 observations. The rise of the background on either side of the peak is distinct from the peak amplitude and must be taken into account before any fit.

Correcting the baseline with AsLS

To estimate the background, open the Dataset and select the variables X = Time (s) and Y = Signal (V) . Load the curve with Add Dataset curve, then choose Fit → Advanced methods and preprocessing → Baseline correction….

The available methods are asls, constant, linear and polynomial. The AsLS (Asymmetric Least Squares) method combines a curvature penalty on the baseline with asymmetric weights: points belonging to positive peaks have less influence on the background estimate.

For the signal shown we use:

SettingValueInterpretation
MethodaslsSmooth baseline with asymmetric weighting
AsLS smoothing lambda100000Controls the smoothness of the estimated background
AsLS asymmetry p0.01Reduces the influence of positive peaks
Maximum iterations50Limit on weight updates
Relative weight tolerance0.000001Stopping criterion for the updates
Sampling griduniform_xUses the spacing of the X coordinate
Figure 2. Baseline correction produces a new Dataset: you can keep the original signal as well as the estimated background and the corrected signal.

In the New Dataset ID field, enter a distinct identifier, for example c11_peak_baseline_corrected, and press Create corrected Dataset. The program adds a new source to the Session without replacing the Dataset it comes from.

Understand the columns of the corrected Dataset

The generated Dataset keeps the original variables and adds the baseline and the corrected signal. The main columns are time_s, signal_v, baseline and corrected_y. For each row:

Ucorrected(t) = Uoriginal(t) − Bestimated(t).

At the central instant of 20 s, the original signal is about 2.71457 V, the estimated baseline about 0.64692 V and the correct signal about 2.06765 V. The corrected value expresses the peak height above the estimated background, not the original absolute voltage.

Figure 3. The new Dataset represents the corrected signal. The curve keeps the peak, while the level away from the center is close to zero.

The AsLS method does not know the true baseline in advance: the estimate depends on the chosen parameters and on the distribution of the points. On a real signal you must check that the procedure does not remove physically interesting components or leave systematic background residuals.

Reduce fluctuations with Savitzky–Golay

The Savitzky–Golay filter smooths the signal with a local polynomial fit inside a moving window. Unlike a simple moving average, it can better preserve some geometric features of peaks when the window and the degree are chosen appropriately.

To apply it, select the original c11_peak_signal Dataset again and load its curve. Open Fit → Advanced methods and preprocessing → Smooth into a separate Dataset….

In the dialog, choose Smoothing method = savitzky_golay, Window = 9 and Local polynomial degree = 2. The window must contain an odd number of observations and the polynomial degree must be compatible with the number of points available.

Figure 4. Savitzky–Golay with nine observations per window and a local polynomial of degree 2. The result is stored in a separate Dataset.

Enter a new identifier, for example c11_peak_smoothed, then press Apply. The program creates the smoothed_y and smoothing_residual columns, and keeps the original signal and the row identities.

Read the smoothed curve and the removed component

The new smoothed_y variable describes the regularized signal. The smoothing_residual variable keeps the difference between the original and the smoothed value:

Uoriginal(t) = Usmoothed(t) + rsmoothing(t).

At the center of the peak, at 20 s, the original value is about 2.71457 V, the smoothed value about 2.70738 V and the removed component about 0.00719 V. Smoothing does not remove the rising baseline: it acts mainly on local oscillations.

Figure 5. Signal after Savitzky–Golay. The peak remains present, while the faster oscillations are attenuated.

When to use baseline correction or smoothing

OperationMain purposeWhat to check
Baseline correctionSeparate background and component of interestResidual background, peak height and shape
SmoothingAttenuate local fluctuationsDistortion of peaks, shoulders and extremes

The two operations can be combined, but their order is not automatically interchangeable. A narrow peak can be distorted by a window that is too wide; a baseline that is too stiff can follow a truly curved background poorly. Choosing the parameters correctly requires knowledge of the phenomenon and inspection of the original data.

In addition, local filtering can introduce correlations between the errors of neighboring observations. A later fit of the smoothed curve should therefore not automatically assume that all observations have independent, unchanged errors: descriptive indicators remain useful, while inference on uncertainties requires further assumptions.

Keep data and transformations

The advantage of the GX-TXT workflow is that transformations are kept as new Datasets instead of silently replacing the original measurement. You can go back to the initial observations and read separately the estimated background, the subtracted component, the smoothed signal and the smoothing residual.

The row-identity columns also let you trace the results back to the source samples. This traceability matters especially when you later select ranges, apply filters or compare fit parameters obtained from different versions of the same signal.