pybaselines.morphological.jbcd
- pybaselines.morphological.jbcd(data, half_window=None, alpha=0.1, beta=10.0, gamma=1.0, beta_mult=1.1, gamma_mult=0.909, diff_order=1, max_iter=20, tol=0.01, tol_2=0.001, robust_opening=True, x_data=None, window_kwargs=None, **kwargs)[source]
Joint Baseline Correction and Denoising (jbcd) Algorithm.
- Parameters:
- dataarray_like, shape (N,)
The y-values of the measured data, with N data points.
- half_window
int, optional The half-window used for the morphology functions. If a value is input, then that value will be used. Default is None, which will optimize the half-window size using
optimize_window()and window_kwargs.- alpha
float, optional The regularization parameter that controls how close the baseline must fit the calculated morphological opening. Larger values make the fit more constrained to the opening and can make the baseline less smooth. Default is 0.1.
- beta
float, optional The regularization parameter that controls how smooth the baseline is. Larger values produce smoother baselines. Default is 1e1.
- gamma
float, optional The regularization parameter that controls how smooth the signal is. Larger values produce smoother baselines. Default is 1.
- beta_mult
float, optional The value that beta is multiplied by each iteration. Default is 1.1.
- gamma_mult
float, optional The value that gamma is multiplied by each iteration. Default is 0.909.
- diff_order
int, optional The order of the differential matrix. Must be greater than 0. Default is 1 (first order differential matrix). Typical values are 2 or 1.
- max_iter
int, optional The maximum number of iterations. Default is 20.
- tol
float, optional The exit criteria for the change in the calculated signal. Default is 1e-2.
- tol_2
float, optional The exit criteria for the change in the calculated baseline. Default is 1e-2.
- robust_openingbool, optional
If True (default), the opening used to represent the initial baseline is the element-wise minimum between the morphological opening and the average of the morphological erosion and dilation of the opening, similar to
mor(). If False, the opening is just the morphological opening, as used in the reference. The robust opening typically represents the baseline better.- x_dataarray_like, optional
The x-values. Not used by this function, but input is allowed for consistency with other functions.
- window_kwargs
dict, optional A dictionary of keyword arguments to pass to
optimize_window()for estimating the half window if half_window is None. 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 window_kwargs.
- Returns:
- baseline
numpy.ndarray, shape (N,) The calculated baseline.
- params
dict A dictionary with the following items:
- 'half_window': int
The half window used for the morphological calculations.
- 'tol_history': numpy.ndarray, shape (K, 2)
An array containing the calculated tolerance values for each iteration. Index 0 are the tolerence values for the relative change in the signal, and index 1 are the tolerance values for the relative change in the baseline. The length of the array is the number of iterations completed, K. If the last values in the array are greater than the input tol or tol_2 values, then the function did not converge.
- 'signal': numpy.ndarray, shape (N,)
The pure signal portion of the input data without noise or the baseline.
- baseline
References
Liu, H., et al. Joint Baseline-Correction and Denoising for Raman Spectra. Applied Spectroscopy, 2015, 69(9), 1013-1022.