Savitzky-Golay Filter

Table of contents

  1. How to Use
  2. Behavior
  3. References

How to Use

To apply Savitzky-Golay smoothening to your data:

  1. Upload data and select the spectra you want to process.
  2. Navigate to the sidebar and turn on the “Smoothening” toggle.
  3. Select “Savitzky-Golay filter” from the drop-down menu.
  4. Configure parameters:
    • Window length (defaults to 15)
    • Polynomial order (defaults to 2) - Should be less than window length.

Behavior

If “Savitky-Golay filter” is selected, SpectraGuru’s smoothening feature applies SciPy’s implementation signal.savgol_filter to each spectrum, which works as follows:

  1. For each Ramanshift value $x$, consider the values between $x-\frac{w}{2}$ and $x+\frac{w}{2}$, where $w$ is the window length.
  2. Try to find the polynomial with order $d$ that best fits with the data centered around $x$. Mathematically speaking, this can be thought of as a minimization of the following expression as the coefficients $a_i$ vary:

    \[\sum_{j=-w/2}^{w/2} \left(I(x+j)-\sum_{i=0}^d \left(a_i (x+j)^i\right)\right)^2\]

    where $I(x)$ is the actual intensity at Ramanshift $x$.

  3. Minimize the above expression using least squares optimization on the coefficients $a_i$. Then use the polynomial fit to find the filtered intensity at Ramanshift $x$.
  4. Repeat this process for all $x$.

References

SpectraGuru uses SciPy’s signal.savgol_filter function for Savitzky-Golay smoothening.

  1. Virtanen, P., Gommers, R., Oliphant, T. E., Haberland, M., Reddy, T., Cournapeau, D., … SciPy 1.0 Contributors. (2020). SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nature Methods, 17(3), 261–272. https://doi.org/10.1038/s41592-019-0686-2

Back to Smoothening