Skip to content

Commit e4e1d89

Browse files
committed
Gaussian correction factor
Correction factor added from https://en.wikipedia.org/wiki/Gaussian_function#Properties
1 parent e4713b1 commit e4e1d89

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/optimize.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ function optimizePeaks(peakList,x,y,n, fnType){
4343
var i, j, lastIndex=[0];
4444
var groups = groupPeaks(peakList,n);
4545
var result = [];
46+
var factor = 1;
47+
if(fnType=="gaussian")
48+
factor = 1.17741;//From https://en.wikipedia.org/wiki/Gaussian_function#Properties
4649
//console.log(x[0]+" "+x[1]);
4750
for(i=0;i<groups.length;i++){
4851
//console.log(peakList[i]);
@@ -66,7 +69,7 @@ function optimizePeaks(peakList,x,y,n, fnType){
6669
}
6770
}
6871
for(j=0;j<optPeaks.length;j++){
69-
result.push({x:optPeaks[j][0],y:optPeaks[j][1],width:optPeaks[j][2]});
72+
result.push({x:optPeaks[j][0],y:optPeaks[j][1],width:optPeaks[j][2]*factor});
7073
}
7174
}
7275
}
@@ -89,7 +92,7 @@ function optimizePeaks(peakList,x,y,n, fnType){
8992
var optPeak = Opt.optimizeSingleLorentzian([sampling[0],sampling[1]], peaks, opts);
9093
}
9194
}
92-
result.push({x:optPeak[0],y:optPeak[1],width:optPeak[2]}); // From https://en.wikipedia.org/wiki/Gaussian_function#Properties}
95+
result.push({x:optPeak[0],y:optPeak[1],width:optPeak[2]*factor}); // From https://en.wikipedia.org/wiki/Gaussian_function#Properties}
9396
}
9497
}
9598

test/massPeakPicking.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,9 @@ var spectrum=CC.analyseMF("Cl2.Br2", {isotopomers:'arrayXXYY', fwhm:0.01, gaussi
99
var xy=spectrum.arrayXXYY;
1010
var x=xy[0];
1111
var y=xy[1];
12-
13-
/*for(var i=0;i< 400;i++){
14-
console.log(x[i]+" "+y[i]);
15-
}
16-
*/
1712
//console.log(y);
1813
var noiseLevel=Stat.array.median(y.filter(function(a) {return (a>0)}))*3;
1914

20-
//console.log(y);
2115
var result=peakPicking.gsd(x, y, {noiseLevel: noiseLevel, minMaxRatio:0, broadRatio:0,smoothY:false});
2216
console.log("Before optmization");
2317
console.log(result);
@@ -28,7 +22,7 @@ console.log(result);
2822
describe.only('Check the peak picking of a simulated mass spectrum', function () {
2923

3024
it('Check result', function () {
31-
25+
3226
});
3327
});
3428

0 commit comments

Comments
 (0)