pybaselines.Baseline.cwt_br

Baseline.cwt_br(data, poly_order=5, scales=None, num_std=1.0, min_length=2, max_iter=50, tol=0.001, symmetric=False, weights=None, pad_kwargs=None, **kwargs)[source]

Continuous wavelet transform baseline recognition (CWT-BR) algorithm.

Parameters:
dataarray_like, shape (N,)

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

poly_orderint, optional

The polynomial order for fitting the baseline. Default is 5.

scalesarray_like, optional

The scales at which to perform the continuous wavelet transform. Default is None,

num_stdfloat, optional

The number of standard deviations to include when thresholding. Default is 1.0.

min_lengthint, optional

Any region of consecutive baseline points less than min_length is considered to be a false positive and all points in the region are converted to peak points. A higher min_length ensures less points are falsely assigned as baseline points. Default is 2, which only removes lone baseline points.

max_iterint, optional

The maximum number of iterations. Default is 50.

tolfloat, optional

The exit criteria. Default is 1e-3.

symmetricbool, optional

When fitting the identified baseline points with a polynomial, if symmetric is False (default), will add any point i as a baseline point where the fit polynomial is greater than the input data for N/100 consecutive points on both sides of point i. If symmetric is True, then it means that both positive and negative peaks exist and baseline points are not modified during the polynomial fitting.

weightsarray_like, shape (N,), optional

The weighting array, used to override the function's baseline identification to designate peak points. Only elements with 0 or False values will have an effect; all non-zero values are considered baseline points. If None (default), then will be an array with size equal to N and all values set to 1.

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 convolution for the continuous wavelet transform. 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:

  • 'mask': numpy.ndarray, shape (N,)

    The boolean array designating baseline points as True and peak points as False.

  • '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.

  • 'best_scale'scalar

    The scale at which the Shannon entropy of the continuous wavelet transform of the data is at a minimum.

Notes

Uses the standard deviation for determining outliers during polynomial fitting rather than the standard error as used in the reference since the number of standard errors to include when thresholding varies with data size while the number of standard deviations is independent of data size.

References

Bertinetto, C., et al. Automatic Baseline Recognition for the Correction of Large Sets of Spectra Using Continuous Wavelet Transform and Iterative Fitting. Applied Spectroscopy, 2014, 68(2), 155-164.