1D Baseline Correction

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

A class for all baseline correction algorithms.

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

Parameters:
x_dataarray_like, shape (N,), optional

The x-values of the measured data. 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 values. Otherwise, the input is assumed to be sorted, although it will still be checked to be in ascending order. Note that some methods will raise an error if x_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 length as the input data 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]).

property banded_solver

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

Added in version 1.2.0.

An integer between 1 and 4 designating the solver to prefer for solving banded linear systems. Setting to 1 or 2 will use the PTRANS-I and PTRANS-II solvers, respectively, from pentapy.solve() if pentapy is installed and the linear system is pentadiagonal. Otherwise, it will use scipy.linalg.solveh_banded() if the system is symmetric, else scipy.linalg.solve_banded(). Setting banded_solver to 3 will only use the SciPy solvers following the same logic, and 4 will force usage of scipy.linalg.solve_banded(). 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

Baseline.poly

Computes a polynomial that fits the baseline of the data.

Baseline.modpoly

The modified polynomial (ModPoly) baseline algorithm.

Baseline.imodpoly

The improved modofied polynomial (IModPoly) baseline algorithm.

Baseline.penalized_poly

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

Baseline.loess

Locally estimated scatterplot smoothing (LOESS).

Baseline.quant_reg

Approximates the baseline of the data using quantile regression.

Baseline.goldindec

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

Whittaker Smoothing Algorithms

Baseline.asls

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

Baseline.iasls

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

Baseline.airpls

Adaptive iteratively reweighted penalized least squares (airPLS) baseline.

Baseline.arpls

Asymmetrically reweighted penalized least squares smoothing (arPLS).

Baseline.drpls

Doubly reweighted penalized least squares (drPLS) baseline.

Baseline.iarpls

Improved asymmetrically reweighted penalized least squares smoothing (IarPLS).

Baseline.aspls

Adaptive smoothness penalized least squares smoothing (asPLS).

Baseline.psalsa

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

Baseline.derpsalsa

Derivative Peak-Screening Asymmetric Least Squares Algorithm (derpsalsa).

Baseline.brpls

Bayesian Reweighted Penalized Least Squares (BrPLS) baseline.

Baseline.lsrpls

Locally Symmetric Reweighted Penalized Least Squares (LSRPLS).

Morphological Algorithms

Baseline.mpls

The Morphological penalized least squares (MPLS) baseline algorithm.

Baseline.mor

A Morphological based (Mor) baseline algorithm.

Baseline.imor

An Improved Morphological based (IMor) baseline algorithm.

Baseline.mormol

Iterative morphological and mollified (MorMol) baseline.

Baseline.amormol

Iteratively averaging morphological and mollified (aMorMol) baseline.

Baseline.rolling_ball

The rolling ball baseline algorithm.

Baseline.mwmv

Moving window minimum value (MWMV) baseline.

Baseline.tophat

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

Baseline.mpspline

Morphology-based penalized spline baseline.

Baseline.jbcd

Joint Baseline Correction and Denoising (jbcd) Algorithm.

Spline Algorithms

Baseline.mixture_model

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

Baseline.irsqr

Iterative Reweighted Spline Quantile Regression (IRSQR).

Baseline.corner_cutting

Iteratively removes corner points and creates a Bezier spline from the remaining points.

Baseline.pspline_asls

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

Baseline.pspline_iasls

A penalized spline version of the IAsLS algorithm.

Baseline.pspline_airpls

A penalized spline version of the airPLS algorithm.

Baseline.pspline_arpls

A penalized spline version of the arPLS algorithm.

Baseline.pspline_drpls

A penalized spline version of the drPLS algorithm.

Baseline.pspline_iarpls

A penalized spline version of the IarPLS algorithm.

Baseline.pspline_aspls

A penalized spline version of the asPLS algorithm.

Baseline.pspline_psalsa

A penalized spline version of the psalsa algorithm.

Baseline.pspline_derpsalsa

A penalized spline version of the derpsalsa algorithm.

Baseline.pspline_mpls

A penalized spline version of the morphological penalized least squares (MPLS) algorithm.

Baseline.pspline_brpls

A penalized spline version of the BrPLS algorithm.

Baseline.pspline_lsrpls

A penalized spline version of the LSRPLS algorithm.

Smoothing Algorithms

Baseline.noise_median

The noise-median method for baseline identification.

Baseline.snip

Statistics-sensitive Non-linear Iterative Peak-clipping (SNIP).

Baseline.swima

Small-window moving average (SWiMA) baseline.

Baseline.ipsa

Iterative Polynomial Smoothing Algorithm (IPSA).

Baseline.ria

Range Independent Algorithm (RIA).

Baseline.peak_filling

The 4S (Smooth, Subsample, Suppress, Stretch) Peak Filling algorithm.

Baseline/Peak Classification Algorithms

Baseline.dietrich

Dietrich's method for identifying baseline regions.

Baseline.golotvin

Golotvin's method for identifying baseline regions.

Baseline.std_distribution

Identifies baseline segments by analyzing the rolling standard deviation distribution.

Baseline.fastchrom

Identifies baseline segments by thresholding the rolling standard deviation distribution.

Baseline.cwt_br

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

Baseline.fabc

Fully automatic baseline correction (fabc).

Baseline.rubberband

Identifies baseline points by fitting a convex hull to the bottom of the data.

Optimizing Algorithms

Baseline.collab_pls

Collaborative Penalized Least Squares (collab-PLS).

Baseline.optimize_extended_range

Extends data and finds the best parameter value for the given baseline method.

Baseline.adaptive_minmax

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

Baseline.custom_bc

Customized baseline correction for fine tuned stiffness of the baseline at specific regions.

Miscellaneous Algorithms

Baseline.interp_pts

Creates a baseline by interpolating through input points.

Baseline.beads

Baseline estimation and denoising with sparsity (BEADS).