npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ml-gsd

v12.1.8

Published

Global Spectra Deconvolution

Downloads

8,827

Readme

global-spectral-deconvolution and peak optimizer

NPM version build status Test coverage npm download

Global Spectra Deconvolution

gsdis using an algorithm that is searching for inflection points to determine the position and width of peaks. The width is defined as the distance between the 2 inflection points. Depending the shape of the peak this width may differ from 'fwhm' (Full Width Half Maximum).

Preprocessing of the data involves the following parameters

  • maxCriteria: search either for maxima or minima. We will invert the data and the results if searching for a minima
  • noiseLevel: specifies the noise level. All the peaks bellow this value (or above in case of maxCriteria=false) are ignored. By default the noiseLevel will be set to the median + 3 x sd. This is a good value when not too many peaks are present in the spectrum.
  • sgOptions: Savitzky-Golay filter that is used to smooth the data for the calculation of the derivatives
  • smoothY: If this value is true the SG filter is not only applied during the calculation of the derivatives but also on the original data

gsd({x:[], y:[]}, options)

The result of GSD is an array of GSDPeak:

  • x: position of the peak on the x axis
  • y: the height of the peak
  • width: width at the level of the inflection points
  • index: index in the 'x' and 'y' array of the peak
  • ddY: second derivative value at the level of the peak. Allows to identify 'large' peaks
  • inflectionPoints: an object with the position of the inflection points
    • from: { x, index }
    • to: { x, index }

Parameters

minMaxRatio=0.00025 (0-1)

Threshold to determine if a given peak should be considered as a noise, bases on its relative height compared to the highest peak.

maxCriteria=true [true||false]

Peaks are local maximum(true) or minimum(false)

smoothY=true [true||false]

Select the peak intensities from a smoothed version of the independent variables?

realTopDetection=false [true||false]

Use a quadratic optimizations with the peak and its 3 closest neighbors to determine the true x,y values of the peak?

sgOptions={windowSize: 5, polynomial: 3}

Savitzky-Golay parameters. windowSize should be odd; polynomial is the degree of the polynomial to use in the approximations. It should be bigger than 2.

Post methods

GSD.broadenPeaks(peakList, {factor=2, overlap=false})

We enlarge the peaks and add the properties from and to. By default we enlarge of a factor 2 and we don't allow overlap.

GSD.optimizePeaks(data, peakList, options)

Optimize the position (x), max intensity (y), full width at half maximum (fwhm) and the ratio of gaussian contribution (mu) if it's required. It currently supports three kind of shapes: gaussian, lorentzian and pseudovoigt

Example

import { IsotopicDistribution } from 'mf-global';
import { gsd, optimizePeaks } from 'ml-gsd';

// generate a sample spectrum of the form {x:[], y:[]}
const data = new IsotopicDistribution('C').getGaussian();

let peaks = gsd(data, {
  minMaxRatio: 0.00025, // Threshold to determine if a given peak should be considered as a noise
  realTopDetection: true, // Correction of the x and y coordinates using a quadratic optimizations
  maxCriteria: true, // Are we looking for maxima or minima
  smoothY: false, // should we smooth the spectra and return smoothed peaks ? Default false.
  sgOptions: { windowSize: 7, polynomial: 3 }, // Savitzky-Golay smoothing parameters for first and second derivative calculation
});
console.log(peaks);
/*
  array of peaks containing {x, y, width, ddY, inflectionPoints}
  - width = distance between inflection points
  - ddY = second derivative on the top of the peak
 */

let optimized = optimizePeaks(data, peaks);
console.log(optimized);
/*
[
  {
    x: 11.99999999960885,
    y: 0.9892695646808637,
    shape: { kind: 'gaussian' },
    fwhm: 0.010000209455943584,
    width: 0.008493395898379276
  },
  {
    x: 13.003354834590702,
    y: 0.010699637653261198,
    shape: { kind: 'gaussian' },
    fwhm: 0.010000226962299321,
    width: 0.008493410766908847
  }
]
*/

i

API documentation

License

MIT