Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ml-gsd

Package Overview
Dependencies
Maintainers
3
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-gsd - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

2

bower.json
{
"name": "ml-gsd",
"version": "0.0.1",
"version": "0.1.0",
"description": "Global Spectra Deconvolution",

@@ -5,0 +5,0 @@ "keywords": [

{
"name": "ml-gsd",
"version": "0.0.1",
"version": "0.1.0",
"description": "Global Spectra Deconvolution",

@@ -5,0 +5,0 @@ "main": "src/index.js",

# global-spectral-deconvolution
Global Spectra Deconvolution + Peak optimizer
## Example
``
var CC = require('chemcalc');
var Stat = require('ml-stat');
var peakPicking = require("../src/index");
var spectrum=CC.analyseMF("Cl2.Br2", {isotopomers:'arrayXXYY', fwhm:0.01, gaussianWidth: 11});
var xy=spectrum.arrayXXYY;
var x=xy[0];
var y=xy[1];
//Just a fake noiseLevel
var noiseLevel=Stat.array.median(y.filter(function(a) {return (a>0)}))*3;
var result=peakPicking.gsd(x, y, {noiseLevel: noiseLevel, minMaxRatio:0, broadRatio:0,smoothY:false});
result = peakPicking.optimize(result,x,y,1,"gaussian");`
```

@@ -7,4 +7,2 @@ /**

function sampleFunction(from, to, x, y, lastIndex){
//console.log(from+" "+to);
//console.log(lastIndex+" "+x[lastIndex[0]]);
var nbPoints = x.length;

@@ -14,12 +12,15 @@ var sampleX = [];

var direction = Math.sign(x[1]-x[0]);//Direction of the derivative
var delta = (to-from)/2;
if(direction==-1){
lastIndex[0]= x.length-1;
}
var delta = Math.abs(to-from)/2;
var mid = (from+to)/2;
var stop = false;
var index = lastIndex[0];
while(!stop&&index<nbPoints){
while(!stop&&index<nbPoints&&index>=0){
if(Math.abs(x[index]-mid)<=delta){
sampleX.push(x[index]);
sampleY.push(y[index]);
index++;
index+=direction;
}

@@ -29,5 +30,5 @@ //It is outside the range.

if(Math.sign(mid-x[index])==direction){
if(Math.sign(mid-x[index])==1){
//We'll reach the mid going in the current direction
index++;
index+=direction;
}

@@ -52,5 +53,3 @@ else{

factor = 1.17741;//From https://en.wikipedia.org/wiki/Gaussian_function#Properties
//console.log(x[0]+" "+x[1]);
for(i=0;i<groups.length;i++){
//console.log(peakList[i]);
var peaks = groups[i].group;

@@ -60,2 +59,3 @@ if(peaks.length>1){

//console.log("Pending group of overlaped peaks "+peaks.length);
//console.log("here1");
//console.log(groups[i].limits);

@@ -76,4 +76,5 @@ var sampling = sampleFunction(groups[i].limits[0]-groups[i].limits[1],groups[i].limits[0]+groups[i].limits[1],x,y,lastIndex);

}
//console.log(optPeak);
for(j=0;j<optPeaks.length;j++){
result.push({x:optPeaks[j][0],y:optPeaks[j][1],width:optPeaks[j][2]*factor});
result.push({x:optPeaks[j][0][0],y:optPeaks[j][1][0],width:optPeaks[j][2][0]*factor});
}

@@ -87,3 +88,4 @@ }

peaks.x+n*peaks.width,x,y,lastIndex);
//console.log(sampling);
//console.log("here2");
//console.log(groups[i].limits);
if(sampling[0].length>5){

@@ -102,3 +104,4 @@ var error = peaks.width/1000;

}
result.push({x:optPeak[0],y:optPeak[1],width:optPeak[2]*factor}); // From https://en.wikipedia.org/wiki/Gaussian_function#Properties}
//console.log(optPeak);
result.push({x:optPeak[0][0],y:optPeak[1][0],width:optPeak[2][0]*factor}); // From https://en.wikipedia.org/wiki/Gaussian_function#Properties}
}

@@ -105,0 +108,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc