Comparing version 0.0.1 to 0.1.0
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
611696
4953
22
0
1