paucablop / chemotools

Integrate your chemometric tools with the scikit-learn API 🧪 🤖
https://paucablop.github.io/chemotools/
MIT License
45 stars 6 forks source link

Implement successor of Savitzky-Golay: The Modified Sinc Smoother #121

Open MothNik opened 3 months ago

MothNik commented 3 months ago

🚶➡️🏃 Proposed Enhancement

In 2023, some researchers put the Savitzky-Golay-filter to the test and figured out that - despite its wide-spread use - it is actually far from being a good smoother. Their publication Why and How Savitzky–Golay Filters Should Be Replaced introduces a new smoother called "Modified Sinc Smoother" which cuts short all the disadvantages of the Savitzky-Golay-filter - first and foremost that it does many things but fully removing noise. The publication really goes deep into the topic and explains the reasons for this quite nicely.

Given this, an implementation of the Modified Sinc Smoother would be a nice addition to chemotools. It would be light-weight smoother (not heavy like WhittakerSmooth) with yet excellent smoothing capabilities. Fun fact: the Savitzky-Golay and Modified Sinc Smoother share the same parameters (window_length and polyorder; the publication states that polyorder is the wrong naming convention and should be poly_degree), so the Modified Sinc Smoother could become a simple drop-in-replacement for the Savitzky-Golay.

🧑‍💻 Implementation aspects

Both the Savitzky-Golay- and the Modified Sinc Smoother belong to the class of so-called Finite Impulse Response Filters. Their main principle is to convolve the signal with a filter. The only thing they differ in is the shape of the filter, so basically both smoothers can share the same base class. Then, they only provide the computation of their filter coefficients which keeps the transformer classes themselves lean while reusing a lot of logic that then only has to be tested once. All that's required is a common interface where the individual filters can hand over their respective filter coefficients as depicted below.

FIR_Filters

paucablop commented 3 months ago

Hi @MothNik

Excellent idea, this is exactly what I also wanted chemotools to be, a place where new developments can be implemented!! After going through the paper, I agree with creating the FIR interface, it is nice for modularization and reusability of the code! I will make a new branch with this one!! :smile: :muscle: