pybaselines.Baseline.ipsa

Baseline.ipsa(data, half_window=None, max_iter=500, tol=None, roi=None, original_criteria=False, pad_kwargs=None, **kwargs)[source]

Iterative Polynomial Smoothing Algorithm (IPSA).

Parameters:
dataarray_like, shape (N,)

The y-values of the measured data, with N data points.

half_windowint

The half-window to use for the smoothing each iteration. Should be approximately equal to the full-width-at-half-maximum of the peaks or features in the data. Default is None, which will use 4 times the output of optimize_window(), which is not always a good value, but at least scales with the number of data points and gives a starting point for tuning the parameter.

max_iterint, optional

The maximum number of iterations. Default is 500.

tolfloat, optional

The exit criteria. Default is None, which uses 1e-3 if original_criteria is False, and 1 / (max(data) - min(data)) if original_criteria is True.

roislice or array_like, shape(N,)

The region of interest, such that np.asarray(data)[roi] gives the values for calculating the tolerance if original_criteria is True. Not used if original_criteria is True. Default is None, which uses all values in data.

original_criteriabool, optional

Whether to use the original exit criteria from the reference, which is difficult to use since it requires knowledge of how high the peaks should be after baseline correction. If False (default), then compares norm(old, new) / norm(old), where old is the previous iteration's baseline, and new is the current iteration's baseline.

pad_kwargsdict, optional

A dictionary of keyword arguments to pass to pad_edges() for padding the edges of the data to prevent edge effects from smoothing. Default is None.

**kwargs

Deprecated since version 1.2.0: Passing additional keyword arguments is deprecated and will be removed in version 1.4.0. Pass keyword arguments using pad_kwargs.

Returns:
baselinenumpy.ndarray, shape (N,)

The calculated baseline.

paramsdict

A dictionary with the following items:

  • 'tol_history': numpy.ndarray

    An array containing the calculated tolerance values for each iteration. The length of the array is the number of iterations completed. If the last value in the array is greater than the input tol value, then the function did not converge.

References

Wang, T., et al. Background Subtraction of Raman Spectra Based on Iterative Polynomial Smoothing. Applied Spectroscopy. 2017, 71(6), 1169-1179.