mljs / global-spectral-deconvolution

Global Spectra Deconvolution + Peak optimizer
http://mljs.github.io/global-spectral-deconvolution/
MIT License
9 stars 8 forks source link

gsd detect negative peaks even when maxCriteria is true #92

Closed jobo322 closed 2 years ago

lpatiny commented 2 years ago

Could you add a failing simple testcase ?

I guess adding a testcase in https://github.com/mljs/global-spectral-deconvolution/blob/master/src/__tests__/gaussian.test.ts

jobo322 commented 2 years ago

Really, it does not detect the top of the peak, it fails when detecting the minimum values of ddY because for a negative peak with a baseline very close to zero, ddY could have fake minimums.

image

what do you think to calculate the yThreshold as:

const yThreshold = minPositiveY + (maxY - minPositiveY ) * minMaxRatio;

In that way we ensure that only positive internal peaks are the detected.

jobo322 commented 2 years ago

or it could use absolute values in this step

https://github.com/mljs/global-spectral-deconvolution/blob/master/src/gsd.ts#239