cremerlab / hplc-py

A Python utility for the processing and quantification of chromatography data
https://cremerlab.github.io/hplc-py/
GNU General Public License v3.0
19 stars 4 forks source link

Small issue in correct_baseline method #10

Closed derb12 closed 6 months ago

derb12 commented 6 months ago

Hi, cool library! I noticed a small issue in the correct_baseline method in quant.py.

https://github.com/cremerlab/hplc-py/blob/8ce5223f2c1a4accbcafb3f883b8a692fac94337/hplc/quant.py#L884-L885

Within the inner loop, the values of tform need to be used for the minimum comparison rather than tform_new. Since tform_new is being written to within the loop, using its values for the comparison will cause some unforseen issues. To help compare with Morhác's original SNIP implementation, the working vector (w in the paper) is tform_new and the current vector (v in the paper) is tform.

The suggested change is show below:

for i in iter:
    tform_new = tform.copy()
    for j in range(i, len(tform) - i):
        tform_new[j] = min(tform[j], 0.5 * (tform[j+i] + tform[j-i]))  # changed here
    tform = tform_new
gchure commented 6 months ago

Thanks @derb12, good catch! This is now fixed in #11 (along with another tweak to a test). Eventually (#12) , I will deprecate the SNIP algorithm implemented here and will instead integrate with pybaselines so the user will have more options to navigate correction.