Skip to main content

Multivariate Curve Resolution in Python

Project description

Travis AppVeyor CodeCov Py34 Py35 Py36 PyPi

pyMCR: Multivariate Curve Resolution in Python

pyMCR is a small package for performing multivariate curve resolution. Currently, it implements a simple alternating least squares method (i.e., MCR-ALS).

MCR-ALS, in general, is a constrained implementation of alternating least squares (ALS) nonnegative matrix factorization (NMF). Historically, other names were used for MCR as well:

  • Self modeling mixture analysis (SMMA)

  • Self modeling curve resolution (SMCR)

Available methods:

What it does do:

  • Approximate the concentration and spectral matrices via minimization routines. This is the core the MCR-ALS methods.

  • Enable the application of certain constraints (currently): sum-to-one, non-negativity, normalization, maximum limits (closure)

What it does not do:

Dependencies

Note: These are the developmental system specs. Older versions of certain packages may work.

  • python >= 3.4

    • Tested with 3.4.6, 3.5.4, 3.6.3

  • numpy (1.9.3)

    • Tested with 1.12.1, 1.13.1, 1.13.3

  • scipy (1.0.0) - Tested with 1.0.0

Known Issues

Installation

Using pip (hard install)

# Only Python 3.* installed
pip install pyMCR

# If you have both Python 2.* and 3.* you may need
pip3 install pyMCR

Using pip (soft install [can update with git])

# Make new directory for pyMCR and enter it
# Clone from github
git clone https://github.com/CCampJr/pyMCR

# Only Python 3.* installed
pip install -e .

# If you have both Python 2.* and 3.* you may need instead
pip3 install -e .

# To update in the future
git pull

Using setuptools

You will need to download the repository or clone the repository with git:

# Make new directory for pyMCR and enter it
# Clone from github
git clone https://github.com/CCampJr/pyMCR

Perform the install:

python setup.py install

Usage

from pymcr.mcr import McrAls
mcrals = McrAls()

# Data that you will provide
# data [n_samples, n_features]  # Measurements
#
# initial_spectra [n_components, n_features]  ## S^T in the literature
# OR
# initial_conc [n_samples, n_components]   ## C in the literature

# If you have an initial estimate of the spectra
mcrals.fit(data, initial_spectra=initial_spectra)

# Otherwise, if you have an initial estimate of the concentrations
mcrals.fit(data, initial_conc=initial_conc)

Examples

Command line and Jupyter notebook examples are provided in the Examples/ folder.

From Examples/Demo.ipynb:

./Examples/mcr_spectra_retr.png ./Examples/mcr_conc_retr.png

References

NONLICENSE

This software was developed at the National Institute of Standards and Technology (NIST) by employees of the Federal Government in the course of their official duties. Pursuant to Title 17 Section 105 of the United States Code, this software is not subject to copyright protection and is in the public domain. NIST assumes no responsibility whatsoever for use by other parties of its source code, and makes no guarantees, expressed or implied, about its quality, reliability, or any other characteristic.

Specific software products identified in this open source project were used in order to perform technology transfer and collaboration. In no case does such identification imply recommendation or endorsement by the National Institute of Standards and Technology, nor does it imply that the products identified are necessarily the best available for the purpose.

Contact

Charles H Camp Jr: charles.camp@nist.gov

Contributors

Charles H Camp Jr

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

pyMCR-0.1.0rc1.tar.gz (12.0 kB view details)

Uploaded Source

File details

Details for the file pyMCR-0.1.0rc1.tar.gz.

File metadata

  • Download URL: pyMCR-0.1.0rc1.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyMCR-0.1.0rc1.tar.gz
Algorithm Hash digest
SHA256 b1c01053047a0c20ce0a4692a36473fd32d3d3fff67839e81ab61373c3f66ca5
MD5 374b233dc9d59004bd0bbe999ae668c1
BLAKE2b-256 2543cb272b27186e2b59d15a955668abb7a541e96ab6d62fe8ddafc88ffc00b8

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