Skip to content

Commit 64baaae

Browse files
committed
Release v1.1.0
1 parent c0fa0c0 commit 64baaae

File tree

5 files changed

+51
-43
lines changed

5 files changed

+51
-43
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ml-gsd",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "Global Spectra Deconvolution",
55
"keywords": [
66
"optimization",

dist/ml-gsd.js

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4808,8 +4808,10 @@ return /******/ (function(modules) { // webpackBootstrap
48084808
}
48094809
}
48104810
//console.log(maxY+"x"+maxDy+"x"+maxDdy);
4811+
48114812
var minddY = [];
4812-
var intervals = [];
4813+
var intervalL = [];
4814+
var intervalR = [];
48134815
var lastMax = null;
48144816
var lastMin = null;
48154817
var broadMask = new Array();
@@ -4822,7 +4824,9 @@ return /******/ (function(modules) { // webpackBootstrap
48224824
lastMin = X[i];
48234825
//console.log("min "+lastMin);
48244826
if(dx>0&&lastMax!=null){
4825-
intervals.push( [lastMax , lastMin] );
4827+
intervalL.push(lastMax);
4828+
intervalR.push(lastMin);
4829+
48264830
}
48274831
}
48284832

@@ -4831,11 +4835,12 @@ return /******/ (function(modules) { // webpackBootstrap
48314835
lastMax = X[i];
48324836
//console.log("max "+lastMax);
48334837
if(dx<0&&lastMin!=null){
4834-
intervals.push( [lastMax , lastMin] );
4838+
intervalL.push(lastMax);
4839+
intervalR.push(lastMin);
48354840
}
48364841
}
48374842
if ((ddY[i] < ddY[i-1]) && (ddY[i] < ddY[i+1])) {
4838-
minddY.push( [X[i], Y[i], i] ); // TODO should we change this to have 3 arrays ? Huge overhead creating arrays
4843+
minddY.push(i);//( [X[i], Y[i], i] ); // TODO should we change this to have 3 arrays ? Huge overhead creating arrays
48394844
if(Math.abs(ddY[i])>options.broadRatio*maxDdy){ // TODO should this be a parameter =
48404845
broadMask.push(false);
48414846
}
@@ -4848,55 +4853,58 @@ return /******/ (function(modules) { // webpackBootstrap
48484853
realTopDetection(minddY,X,Y);
48494854
}
48504855
//
4851-
//console.log(intervals);
4856+
//console.log(intervalL.length+" "+minddY.length+" "+broadMask.length);
48524857
var signals = [];
4853-
4858+
var lastK = 0,possible, k, f,frequency, distanceJ, minDistance, gettingCloser;
48544859
for (var j = 0; j < minddY.length; j++){
4855-
var f = minddY[j];
4856-
var frequency = f[0];
4857-
var possible = [];
4858-
for (var k=0; k<intervals.length; k++){
4859-
var i = intervals[k];
4860-
if(Math.abs(frequency-(i[0]+i[1])/2)<Math.abs(i[0]-i[1])/2)
4861-
possible.push(i);
4862-
}
4863-
//console.log("possible "+possible.length);
4864-
if (possible.length > 0)
4865-
if (possible.length == 1)
4866-
{
4867-
var inter = possible[0];
4868-
var linewidth = Math.abs(inter[1] - inter[0]);
4869-
var height = f[1];
4870-
//console.log(height);
4871-
if (Math.abs(height) > options.minMaxRatio*maxY) {
4872-
signals.push({
4873-
x: frequency,
4874-
y: (height-yCorrection.b)/yCorrection.m,
4875-
width: linewidth,//*widthCorrection
4876-
soft:broadMask[j]
4877-
})
4878-
}
4860+
frequency = X[minddY[j]];//minddY[j][0];
4861+
possible = -1;
4862+
k=lastK+1;
4863+
minDistance = Number.MAX_VALUE;
4864+
distanceJ = 0;
4865+
gettingCloser=true;
4866+
while(possible==-1&&k<intervalL.length&&gettingCloser){
4867+
distanceJ = Math.abs(frequency-(intervalL[k]+intervalR[k])/2);
4868+
//Still getting closer?
4869+
if(distanceJ<minDistance){
4870+
minDistance = distanceJ;
4871+
}
4872+
else{
4873+
gettingCloser = false;
48794874
}
4880-
else
4881-
{
4882-
//TODO: nested peaks
4883-
// console.log("Nested "+possible);
4875+
if( distanceJ <Math.abs(intervalL[k]-intervalR[k])/2){
4876+
possible=k;
4877+
lastK = k;
48844878
}
4879+
k++;
4880+
}
4881+
//console.log(lastK+" "+intervalL.length+" possible "+k);
4882+
if (possible!=-1){
4883+
//console.log(height);
4884+
if (Math.abs(Y[minddY[j]]) > options.minMaxRatio*maxY) {
4885+
signals.push({
4886+
x: frequency,
4887+
y: (Y[minddY[j]]-yCorrection.b)/yCorrection.m,
4888+
width:Math.abs(intervalR[possible] - intervalL[possible]),//widthCorrection
4889+
soft:broadMask[j]
4890+
})
4891+
}
4892+
}
48854893
}
48864894

48874895
signals.sort(function (a, b) {
48884896
return a.x - b.x;
48894897
});
48904898

4891-
48924899
return signals;
4900+
48934901
}
48944902

48954903
function realTopDetection(peakList, x, y){
48964904
var listP = [];
48974905
var alpha, beta, gamma, p,currentPoint;
48984906
for(var j=0;j<peakList.length;j++){
4899-
currentPoint = peakList[j][2];
4907+
currentPoint = peakList[j];//peakList[j][2];
49004908
//The detected peak could be moved 1 or 2 unit to left or right.
49014909
if(y[currentPoint-1]>=y[currentPoint-2]
49024910
&&y[currentPoint-1]>=y[currentPoint]) {
@@ -4928,8 +4936,8 @@ return /******/ (function(modules) { // webpackBootstrap
49284936
gamma = 20 * Math.log10(y[currentPoint + 1]);
49294937
p = 0.5 * (alpha - gamma) / (alpha - 2 * beta + gamma);
49304938

4931-
peakList[j][0] = x[currentPoint] + (x[currentPoint]-x[currentPoint-1])*p;
4932-
peakList[j][1] = y[currentPoint] - 0.25 * (y[currentPoint - 1]
4939+
x[peakList[j]] = x[currentPoint] + (x[currentPoint]-x[currentPoint-1])*p;
4940+
y[peakList[j]] = y[currentPoint] - 0.25 * (y[currentPoint - 1]
49334941
- [currentPoint + 1]) * p;//signal.peaks[j].intensity);
49344942
}
49354943
}

dist/ml-gsd.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ml-gsd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ml-gsd",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "Global Spectra Deconvolution",
55
"main": "src/index.js",
66
"directories": {

0 commit comments

Comments
 (0)