Giter Club home page Giter Club logo

biospectools's People

Contributors

eirikama avatar johannesolheim avatar pisarik avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

biospectools's Issues

EMSC with multiregions does not construct polynomials in the good mid point

Problem

@JohanneSolheim spotted a problem that when EMSC is used with several non-connected regions of spectra, then the established polynomial components look to be off center. In the image below you can see that the red line (linear polynomial) is shifted more towards left region.

image

Explanation

Indeed, current implementation defines the middle point of spectrum as a mean of all wavenumbers (np.mean(wavenumbers)), what essentially means that the middle point lies in the center of mass of wavenumbers. This approach seems to be invalid when used with several non-connected spectral regions, because the middle point will depend on the number of points in each region. The edge case is when one region contains 1000 wavenumbers and another region contains only 1 wavenumber. In that case the mid-point will be placed in the first region.

The suggested improvement is to calculate the middle point as the average of min and max wavenumber ((wns.min() + wns.max()) / 2). In that case mid point will not depend on number of points in regions.

Affected routines

This improvement may change results of correction of spectra with glued multi-regions, for example lipid peaks around 3000 cm-1 and 1700 cm-1. For a single region it should work the same as previously.

Add docs for MeEMSC

Also class MeEMSCDetails needs to be documented.
The simplest way would be to use as a template documentation of the EMSC method.

class EMSC:
"""Extended multiplicative signal correction (EMSC) [1]_.
Parameters
----------
reference : `(K_channels,) ndarray`
Reference spectrum.
wavenumbers : `(K_channels,) ndarray`, optional
Wavenumbers must be passed if given polynomial order
is greater than zero.
poly_order : `int`, optional (default 2)
Order of polynomial to be used in regression model. If None
then polynomial will be not used.
weights : `(K_channels,) ndarray`, optional
Weights for spectra.
constituents : `(N_constituents, K_channels) np.ndarray`, optional
Chemical constituents for regression model [2]_. Can be used to add
orthogonal vectors.
scale : `bool`, default True
If True then spectra will be scaled to reference spectrum.
rebuild_model : `bool`, default True
If True, then model will be built each time transform is called,
this allows to dynamically change parameters of EMSC class.
Otherwise model will be built once (for speed).
Other Parameters
----------------
_model : `(K_channels, 1 + N_constituents + (poly_order + 1) ndarray`
Matrix that is used to solve least squares. First column is a
reference spectrum followed by constituents and polynomial columns.
_norm_wns : `(K_channels,) ndarray`
Normalized wavenumbers to -1, 1 range
References
----------
.. [1] A. Kohler et al. *EMSC: Extended multiplicative
signal correction as a tool for separation and
characterization of physical and chemical
information in fourier transform infrared
microscopy images of cryo-sections of
beef loin.* Applied spectroscopy, 59(6):707โ€“716, 2005.
"""

Array shape mismatch out of DSAE

Hi,
I'm running into an error with the DSAE. When I try to correct spectra, I get an output which is longer by 1 than my raw spectra, so it can't be reshaped :
test

Python version : 3.8.12
Biospectools version : 0.3.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.