cheminfo / nmrium

React component to display and process nuclear magnetic resonance (NMR) spectra.
https://docs.nmrium.org
MIT License
55 stars 26 forks source link

interpolate spectrum to determine top of a picked peaks #27

Closed djeanner closed 3 years ago

djeanner commented 5 years ago

When spectra have relatively low resolution (which the the standard in the processing of spectra (in particular 2d, but also 1D), it is a good idea to interpolate the spectrum near the point of selection to get the true top. When the user clicks near a top, the value picked could be interpolated (x and y coordinates). Example: for a peak over this bit of spectrum : x: 1 2 3 4 5 6 y: 1 2 5 4 1.8 1 The "naive" top of the peak when selecting the point at x=4 would be (3,5), but it would be even better to interpolate to find it at (3.31,5.8). In NMR the prefered interpolation is the trigonometric interpolation ifft/zero filling/fft, but this may take too a bit of time (except if already done before picking the peak). A more serious problem may be if the baseline is terrible, the interpolation may not work. (also over part of a spectrum it is tricky... because peaks should no be truncated... not sure how few it has to be taken to be safe) Another reasonable manner is to use other interpolator such as spline (need only a few points). The advantage is that it would be more robust (for other type of spectra if this is to be used for jcamp in general instead of only NMR). The ideal would be to use trigonometric interpolation, check that it makes sense by comparing with the spline and return just one... Make sure you consider picking minima (either when the signals is negative) or when the spectroscopy for which peaks go down.

lpatiny commented 5 years ago

We are using our package https://www.npmjs.com/package/ml-gsd for peak picking

jwist commented 5 years ago

Hi, my understanding is that if "true" peak position and "true" peak integral are sought, then it is a good idea to adust/fit to a function (usually a mixture of Gaussian and Lorentzian). I think we should be able to do both but for teaching, we should recommend the fit way.

lpatiny commented 3 years ago

'Real' top of the peak is now detected based on 3 points.

Peak shape analysis will be done in https://github.com/cheminfo/nmr-displayer/issues/646