2D Baseline Correction

class pybaselines.Baseline2D(x_data=None, z_data=None, check_finite=True, assume_sorted=False, output_dtype=None)[source]

A class for all 2D baseline correction algorithms.

Contains all available 2D baseline correction algorithms in pybaselines as methods to allow a single interface for easier usage.

Parameters:
x_dataarray_like, shape (M,), optional

The x-values of the measured data (independant variable for the rows). Default is None, which will create an array from -1 to 1 during the first function call with length equal to the input data length.

z_dataarray_like, shape (N,), optional

The z-values of the measured data (independant variable for the columns). Default is None, which will create an array from -1 to 1 during the first function call with length equal to the input data length.

check_finitebool, optional

If True (default), will raise an error if any values in input data are not finite. Setting to False will skip the check. Note that errors may occur if check_finite is False and the input data contains non-finite values.

assume_sortedbool, optional

If False (default), will sort the input x_data and z_data values. Otherwise, the input is assumed to be sorted, although they will still be checked to be in ascending order. Note that some methods will raise an error if x_data or z_data values are not unique.

output_dtypetype or numpy.dtype, optional

The dtype to cast the output array. Default is None, which uses the typing of the input data.

Attributes:
xnumpy.ndarray or None

The x-values for the object. If initialized with None, then x is initialized the first function call to have the same size as the input data.shape[-2] and has min and max values of -1 and 1, respectively.

x_domainnumpy.ndarray

The minimum and maximum values of x. If x_data is None during initialization, then set to numpy.ndarray([-1, 1]).

znumpy.ndarray or None

The z-values for the object. If initialized with None, then z is initialized the first function call to have the same size as the input data.shape[-1] and has min and max values of -1 and 1, respectively.

z_domainnumpy.ndarray

The minimum and maximum values of z. If z_data is None during initialization, then set to numpy.ndarray([-1, 1]).

property banded_solver

Designates the solver to prefer using for solving 1D banded linear systems.

Added in version 1.2.0.

Only used to pass to a new Baseline object when using Baseline2D.individual_axes(). An integer between 1 and 4 designating the solver to prefer for solving banded linear systems in 1D. See banded_solver for more information. Default is 2.

This typically does not need to be modified since all solvers have relatively the same numerical stability and is mostly for internal testing.

property pentapy_solver

The solver if using pentapy to solve banded equations.

Deprecated since version 1.2: The pentapy_solver property is deprecated and will be removed in version 1.4. Use banded_solver instead.

Polynomial Algorithms

Baseline2D.poly

Computes a polynomial that fits the baseline of the data.

Baseline2D.modpoly

The modified polynomial (ModPoly) baseline algorithm.

Baseline2D.imodpoly

The improved modofied polynomial (IModPoly) baseline algorithm.

Baseline2D.penalized_poly

Fits a polynomial baseline using a non-quadratic cost function.

Baseline2D.quant_reg

Approximates the baseline of the data using quantile regression.

Whittaker Smoothing Algorithms

Baseline2D.asls

Fits the baseline using asymmetric least squares (AsLS) fitting.

Baseline2D.iasls

Fits the baseline using the improved asymmetric least squares (IAsLS) algorithm.

Baseline2D.airpls

Adaptive iteratively reweighted penalized least squares (airPLS) baseline.

Baseline2D.arpls

Asymmetrically reweighted penalized least squares smoothing (arPLS).

Baseline2D.drpls

Doubly reweighted penalized least squares (drPLS) baseline.

Baseline2D.iarpls

Improved asymmetrically reweighted penalized least squares smoothing (IarPLS).

Baseline2D.aspls

Adaptive smoothness penalized least squares smoothing (asPLS).

Baseline2D.psalsa

Peaked Signal's Asymmetric Least Squares Algorithm (psalsa).

Baseline2D.brpls

Bayesian Reweighted Penalized Least Squares (BrPLS) baseline.

Baseline2D.lsrpls

Locally Symmetric Reweighted Penalized Least Squares (LSRPLS).

Morphological Algorithms

Baseline2D.mor

A Morphological based (Mor) baseline algorithm.

Baseline2D.imor

An Improved Morphological based (IMor) baseline algorithm.

Baseline2D.rolling_ball

The rolling ball baseline algorithm.

Baseline2D.tophat

Estimates the baseline using a top-hat transformation (morphological opening).

Spline Algorithms

Baseline2D.mixture_model

Considers the data as a mixture model composed of noise and peaks.

Baseline2D.irsqr

Iterative Reweighted Spline Quantile Regression (IRSQR).

Baseline2D.pspline_asls

A penalized spline version of the asymmetric least squares (AsLS) algorithm.

Baseline2D.pspline_iasls

A penalized spline version of the IAsLS algorithm.

Baseline2D.pspline_airpls

A penalized spline version of the airPLS algorithm.

Baseline2D.pspline_arpls

A penalized spline version of the arPLS algorithm.

Baseline2D.pspline_iarpls

A penalized spline version of the IarPLS algorithm.

Baseline2D.pspline_psalsa

A penalized spline version of the psalsa algorithm.

Baseline2D.pspline_brpls

A penalized spline version of the brPLS algorithm.

Baseline2D.pspline_lsrpls

A penalized spline version of the LSRPLS algorithm.

Smoothing Algorithms

Baseline2D.noise_median

The noise-median method for baseline identification.

Optimizing Algorithms

Baseline2D.collab_pls

Collaborative Penalized Least Squares (collab-PLS).

Baseline2D.adaptive_minmax

Fits polynomials of different orders and uses the maximum values as the baseline.

Baseline2D.individual_axes

Applies a one dimensional baseline correction method along each row and/or column.