BaselineRemoval


NameBaselineRemoval JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttps://github.com/StatguyUser/BaselineRemoval
SummaryPerform baseline removal, baseline correction and baseline substraction for raman spectra using Modpoly, ImodPoly and Zhang fit. Returns baseline-subtracted spectrum
upload_time2024-04-09 11:46:58
maintainerNone
docs_urlNone
authorStatguyUser
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            What is it?
===========

Companion python library for the machine learning book [Feature Engineering & Selection for Explainable Models: A Second Course for Data Scientists](https://statguyuser.github.io/feature-engg-selection-for-explainable-models.github.io/index.html). 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?
=================

```python

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
============

 - [numpy](https://www.numpy.org/])

 - [scikit-learn](https://scikit-learn.org/)

 - [scipy](https://www.scipy.org/)

References
============

1. [Automated Method for Subtraction of Fluorescence from Biological Raman Spectra](https://www.researchgate.net/publication/8974238_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](https://www.researchgate.net/publication/5818031_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](https://pubs.rsc.org/is/content/articlelanding/2010/an/b922045c#!divAbstract) by Zhi-Min Zhang, Shan Chena and Yi-Zeng Liang (2010)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/StatguyUser/BaselineRemoval",
    "name": "BaselineRemoval",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "StatguyUser",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/a3/88/6dd700e07913d91c4778b4dbd9ebb8fae13e2ad3c4db965b3635054706a7/BaselineRemoval-0.1.6.tar.gz",
    "platform": null,
    "description": "What is it?\n===========\n\nCompanion python library for the machine learning book [Feature Engineering & Selection for Explainable Models: A Second Course for Data Scientists](https://statguyuser.github.io/feature-engg-selection-for-explainable-models.github.io/index.html). It is used for baseline correction. It has below 3 methods for baseline removal from spectra.\n\n  - **Modpoly** Modified multi-polynomial fit [1]. It has below 3 parameters.\n\n  1) `degree`, it refers to polynomial degree, and default value is 2.\n\n  2) `repitition`, it refers to how many iterations to run, and default value is 100.\n\n  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.\n\n  - **IModPoly** Improved ModPoly[2], which addresses noise issue in ModPoly. It has below 3 parameters.\n\n  1) `degree`, it refers to polynomial degree, and default value is 2.\n\n  2) `repitition`, it refers to how many iterations to run, and default value is 100.\n\n  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.\n\n  - **ZhangFit** Zhang fit[3], which doesn\u2019t require any user intervention and prior information, such as detected peaks. It has below 3 parameters.\n\n  1) `lambda_`, it can be adjusted by user. The larger lambda is,  the smoother the resulting background. Default value is 100.\n\n  2) `porder` refers to adaptive iteratively reweighted penalized least squares for baseline fitting. Default value is 1.\n\n  3) `repitition` is how many iterations to run, and default value is 15.\n\nWe 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.\n\nHow to use it?\n=================\n\n```python\n\nfrom BaselineRemoval import BaselineRemoval\n\ninput_array=[10,20,1.5,5,2,9,99,25,47]\n\npolynomial_degree=2 #only needed for Modpoly and IModPoly algorithm\n\nbaseObj=BaselineRemoval(input_array)\n\nModpoly_output=baseObj.ModPoly(polynomial_degree)\n\nImodpoly_output=baseObj.IModPoly(polynomial_degree)\n\nZhangfit_output=baseObj.ZhangFit()\n\nprint('Original input:',input_array)\n\nprint('Modpoly base corrected values:',Modpoly_output)\n\nprint('IModPoly base corrected values:',Imodpoly_output)\n\nprint('ZhangFit base corrected values:',Zhangfit_output)\n\nOriginal input: [10, 20, 1.5, 5, 2, 9, 99, 25, 47]\n\nModpoly base corrected values: [-1.98455800e-04  1.61793368e+01  1.08455179e+00  5.21544654e+00\n  7.20210508e-02  2.15427531e+00  8.44622093e+01 -4.17691125e-03\n  8.75511661e+00]\n\nIModPoly base corrected values: [-0.84912125 15.13786196 -0.11351367  3.89675187 -1.33134142  0.70220645\n 82.99739548 -1.44577432  7.37269705]\n\nZhangFit base corrected values: [ 8.49924691e+00  1.84994576e+01 -3.31739230e-04  3.49854060e+00\n  4.97412948e-01  7.49628529e+00  9.74951576e+01  2.34940300e+01\n  4.54929023e+01\n\n```\nWhere to get it?\n================\n\n`pip install BaselineRemoval`\n\nHow to cite?\n============\nMd Azimul Haque (2022). Feature Engineering & Selection for Explainable Models: A Second Course for Data Scientists. Lulu Press, Inc.\n\nDependencies\n============\n\n - [numpy](https://www.numpy.org/])\n\n - [scikit-learn](https://scikit-learn.org/)\n\n - [scipy](https://www.scipy.org/)\n\nReferences\n============\n\n1. [Automated Method for Subtraction of Fluorescence from Biological Raman Spectra](https://www.researchgate.net/publication/8974238_Automated_Method_for_Subtraction_of_Fluorescence_from_Biological_Raman_Spectra) by Lieber & Mahadevan-Jansen (2003)\n2. [Automated Autofluorescence Background Subtraction Algorithm for Biomedical Raman Spectroscopy](https://www.researchgate.net/publication/5818031_Automated_Autofluorescence_Background_Subtraction_Algorithm_for_Biomedical_Raman_Spectroscopy) by Zhao, Jianhua, Lui, Harvey, McLean, David I., Zeng, Haishan (2007)\n3. [Baseline correction using adaptive iteratively reweighted penalized least squares](https://pubs.rsc.org/is/content/articlelanding/2010/an/b922045c#!divAbstract) by Zhi-Min Zhang, Shan Chena and Yi-Zeng Liang (2010)\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Perform baseline removal, baseline correction and baseline substraction for raman spectra using Modpoly, ImodPoly and Zhang fit. Returns baseline-subtracted spectrum",
    "version": "0.1.6",
    "project_urls": {
        "Download": "https://github.com/StatguyUser/BaselineRemoval.git",
        "Homepage": "https://github.com/StatguyUser/BaselineRemoval"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ea335f2b59dee9e18e5086a6d29d9446350613c6da8ba01eb96aa858d0456b9d",
                "md5": "49e035bf5e52b1004f72579947563295",
                "sha256": "f09ce3d361ae0b4e92b91a64d654c23a8327155b09da7f09b7dab05d3cf722dd"
            },
            "downloads": -1,
            "filename": "BaselineRemoval-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "49e035bf5e52b1004f72579947563295",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6468,
            "upload_time": "2024-04-09T11:46:57",
            "upload_time_iso_8601": "2024-04-09T11:46:57.738040Z",
            "url": "https://files.pythonhosted.org/packages/ea/33/5f2b59dee9e18e5086a6d29d9446350613c6da8ba01eb96aa858d0456b9d/BaselineRemoval-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a3886dd700e07913d91c4778b4dbd9ebb8fae13e2ad3c4db965b3635054706a7",
                "md5": "4cb5d1849fd0588653298633737e45c1",
                "sha256": "82c63a4a100b433e776b9be533b391c1893e3eb1f0491cbdcda5282a3394b8ed"
            },
            "downloads": -1,
            "filename": "BaselineRemoval-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "4cb5d1849fd0588653298633737e45c1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6140,
            "upload_time": "2024-04-09T11:46:58",
            "upload_time_iso_8601": "2024-04-09T11:46:58.968920Z",
            "url": "https://files.pythonhosted.org/packages/a3/88/6dd700e07913d91c4778b4dbd9ebb8fae13e2ad3c4db965b3635054706a7/BaselineRemoval-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-09 11:46:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "StatguyUser",
    "github_project": "BaselineRemoval",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "baselineremoval"
}
        
Elapsed time: 0.22049s