Skip to content

Commit 759ad4b

Browse files
committed
Release v1.0.1
1 parent 2ef7a6f commit 759ad4b

File tree

5 files changed

+69
-8
lines changed

5 files changed

+69
-8
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.0",
3+
"version": "1.0.1",
44
"description": "Global Spectra Deconvolution",
55
"keywords": [
66
"optimization",

dist/ml-gsd.js

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ return /******/ (function(modules) { // webpackBootstrap
5555
/***/ function(module, exports, __webpack_require__) {
5656

5757

58-
module.exports.optimize = __webpack_require__(1);
58+
module.exports.post = __webpack_require__(1);
5959
module.exports.gsd = __webpack_require__(15);
6060

6161

@@ -224,6 +224,67 @@ return /******/ (function(modules) { // webpackBootstrap
224224
}
225225
return groups;
226226
}
227+
/**
228+
* This function try to join the peaks that seems to belong to a broad signal in a single broad peak.
229+
* @param peakList
230+
* @param options
231+
*/
232+
function joinBroadPeaks(peakList, options){
233+
var width = options.width;
234+
var broadLines=[];
235+
//Optimize the possible broad lines
236+
var max=0, maxI=0,count=1;
237+
var isPartOf = false;
238+
for(var i=peakList.length-1;i>=0;i--){
239+
if(peakList[i].soft){
240+
broadLines.push(peakList.splice(i,1)[0]);
241+
}
242+
}
243+
//Push a feak peak
244+
broadLines.push({x:Number.MAX_VALUE});
245+
246+
var candidates = [[broadLines[0].x,
247+
broadLines[0].y]];
248+
var indexes = [0];
249+
250+
for(var i=1;i<broadLines.length;i++){
251+
//console.log(broadLines[i-1].x+" "+broadLines[i].x);
252+
if(Math.abs(broadLines[i-1].x-broadLines[i].x)<width){
253+
candidates.push([broadLines[i].x,broadLines[i].y]);
254+
if(broadLines[i].y>max){
255+
max = broadLines[i].y;
256+
maxI = i;
257+
}
258+
indexes.push(i);
259+
count++;
260+
}
261+
else{
262+
if(count>2){
263+
var fitted = Opt.optimizeSingleLorentzian(candidates,
264+
{x: broadLines[maxI].x, y:max, width: Math.abs(candidates[0][0]-candidates[candidates.length-1][0])});
265+
//console.log(fitted)
266+
peakList.push({x:fitted[0][0],y:fitted[1][0],width:fitted[2][0],soft:false});
267+
268+
}
269+
else{
270+
//Put back the candidates to the signals list
271+
indexes.map(function(index){peakList.push(broadLines[index])});
272+
}
273+
candidates = [[broadLines[i].x,broadLines[i].y]];
274+
indexes = [i];
275+
max = broadLines[i].y;
276+
maxI = i;
277+
count = 1;
278+
}
279+
}
280+
281+
peakList.sort(function (a, b) {
282+
return a.x - b.x;
283+
});
284+
285+
return peakList;
286+
287+
}
227288

228289
/*if(options.broadRatio>0){
229290
var broadLines=[[Number.MAX_VALUE,0,0]];
@@ -273,7 +334,7 @@ return /******/ (function(modules) { // webpackBootstrap
273334
}
274335
}*/
275336

276-
module.exports=optimizePeaks;
337+
module.exports={optimizePeaks:optimizePeaks,joinBroadPeaks:joinBroadPeaks};
277338

278339

279340

@@ -4674,7 +4735,7 @@ return /******/ (function(modules) { // webpackBootstrap
46744735

46754736
var sgDefOptions = {
46764737
windowSize: 5,
4677-
polynomial: 3,
4738+
polynomial: 3
46784739
};
46794740

46804741

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.0",
3+
"version": "1.0.1",
44
"description": "Global Spectra Deconvolution",
55
"main": "src/index.js",
66
"directories": {

0 commit comments

Comments
 (0)