Skip to main content

Perform baseline removal, baseline correction and baseline substraction for raman spectra using Modpoly, ImodPoly and Zhang fit. Returns baseline-subtracted spectrum

Project description

What is it?

Companion python library for the machine learning book Feature Engineering & Selection for Explainable Models: A Second Course for Data Scientists. It is used for baseline correction. It has below 3 methods for baseline removal from spectra.

  • Modpoly Modified multi-polynomial fit [1]. It has below 3 parameters.
  1. degree, it refers to polynomial degree, and default value is 2.

  2. repitition, it refers to how many iterations to run, and default value is 100.

  3. gradient, it refers to gradient for polynomial loss, default is 0.001. It measures incremental gain over each iteration. If gain in any iteration is less than this, further improvement will stop.

  • IModPoly Improved ModPoly[2], which addresses noise issue in ModPoly. It has below 3 parameters.
  1. degree, it refers to polynomial degree, and default value is 2.

  2. repitition, it refers to how many iterations to run, and default value is 100.

  3. gradient, it refers to gradient for polynomial loss, and default is 0.001. It measures incremental gain over each iteration. If gain in any iteration is less than this, further improvement will stop.

  • ZhangFit Zhang fit[3], which doesn’t require any user intervention and prior information, such as detected peaks. It has below 3 parameters.
  1. lambda_, it can be adjusted by user. The larger lambda is, the smoother the resulting background. Default value is 100.

  2. porder refers to adaptive iteratively reweighted penalized least squares for baseline fitting. Default value is 1.

  3. repitition is how many iterations to run, and default value is 15.

We can use the python library to process spectral data through either of the techniques ModPoly, IModPoly or Zhang fit algorithm for baseline subtraction. The functions will return baseline-subtracted spectrum.

How to use it?

from BaselineRemoval import BaselineRemoval

input_array=[10,20,1.5,5,2,9,99,25,47]

polynomial_degree=2 #only needed for Modpoly and IModPoly algorithm

baseObj=BaselineRemoval(input_array)

Modpoly_output=baseObj.ModPoly(polynomial_degree)

Imodpoly_output=baseObj.IModPoly(polynomial_degree)

Zhangfit_output=baseObj.ZhangFit()

print('Original input:',input_array)

print('Modpoly base corrected values:',Modpoly_output)

print('IModPoly base corrected values:',Imodpoly_output)

print('ZhangFit base corrected values:',Zhangfit_output)

Original input: [10, 20, 1.5, 5, 2, 9, 99, 25, 47]

Modpoly base corrected values: [-1.98455800e-04  1.61793368e+01  1.08455179e+00  5.21544654e+00
  7.20210508e-02  2.15427531e+00  8.44622093e+01 -4.17691125e-03
  8.75511661e+00]

IModPoly base corrected values: [-0.84912125 15.13786196 -0.11351367  3.89675187 -1.33134142  0.70220645
 82.99739548 -1.44577432  7.37269705]

ZhangFit base corrected values: [ 8.49924691e+00  1.84994576e+01 -3.31739230e-04  3.49854060e+00
  4.97412948e-01  7.49628529e+00  9.74951576e+01  2.34940300e+01
  4.54929023e+01

Where to get it?

pip install BaselineRemoval

How to cite?

Md Azimul Haque (2022). Feature Engineering & Selection for Explainable Models: A Second Course for Data Scientists. Lulu Press, Inc.

Dependencies

References

  1. Automated Method for Subtraction of Fluorescence from Biological Raman Spectra by Lieber & Mahadevan-Jansen (2003)
  2. Automated Autofluorescence Background Subtraction Algorithm for Biomedical Raman Spectroscopy by Zhao, Jianhua, Lui, Harvey, McLean, David I., Zeng, Haishan (2007)
  3. Baseline correction using adaptive iteratively reweighted penalized least squares by Zhi-Min Zhang, Shan Chena and Yi-Zeng Liang (2010)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BaselineRemoval-0.1.6.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

BaselineRemoval-0.1.6-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file BaselineRemoval-0.1.6.tar.gz.

File metadata

  • Download URL: BaselineRemoval-0.1.6.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.27.1 setuptools/58.3.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for BaselineRemoval-0.1.6.tar.gz
Algorithm Hash digest
SHA256 82c63a4a100b433e776b9be533b391c1893e3eb1f0491cbdcda5282a3394b8ed
MD5 4cb5d1849fd0588653298633737e45c1
BLAKE2b-256 a3886dd700e07913d91c4778b4dbd9ebb8fae13e2ad3c4db965b3635054706a7

See more details on using hashes here.

File details

Details for the file BaselineRemoval-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: BaselineRemoval-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.27.1 setuptools/58.3.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for BaselineRemoval-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f09ce3d361ae0b4e92b91a64d654c23a8327155b09da7f09b7dab05d3cf722dd
MD5 49e035bf5e52b1004f72579947563295
BLAKE2b-256 ea335f2b59dee9e18e5086a6d29d9446350613c6da8ba01eb96aa858d0456b9d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page