Multivariate Curve Resolution in Python
Project description
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:
Ordinary least squares with Moore-Penrose pseudo-inverse (default, McrAls)
Ordinary least squares with non-negative least squares (McrAls_NNLS)
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:
Estimate the number of components in the sample. This is a bonus feature in some more-advanced MCR-ALS packages.
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:
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pyMCR-0.1.0rc0.tar.gz
.
File metadata
- Download URL: pyMCR-0.1.0rc0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c1d9bbffe3add8975eadd98840ddb205d0958eea2417fa1763ced7230a2bc0d |
|
MD5 | 4662be371ebf472ecc12bc00a8380cf7 |
|
BLAKE2b-256 | 7452505d461bbcfdbbaa027b686eb964c43d79ba4cfa567e77cba61de54ec4fa |