Computes the Savitzky-Golay filter coefficients using QR decomposition. More...
#include <OpenMS/FILTERING/SMOOTHING/SavitzkyGolayFilter.h>
Public Member Functions | |
| SavitzkyGolayFilter () | |
| Constructor. | |
| virtual | ~SavitzkyGolayFilter () |
| Destructor. | |
| template<typename PeakType > | |
| void | filter (MSSpectrum< PeakType > &spectrum) |
| Removed the noise from an MSSpectrum containing profile data. | |
| template<typename PeakType > | |
| void | filterExperiment (MSExperiment< PeakType > &map) |
| Removed the noise from an MSExperiment containing profile data. | |
Protected Member Functions | |
| virtual void | updateMembers_ () |
| This method is used to update extra member variables at the end of the setParameters() method. | |
Protected Attributes | |
| std::vector< DoubleReal > | coeffs_ |
| Coefficients. | |
| UInt | frame_size_ |
| UInt of the filter kernel (number of pre-tabulated coefficients). | |
| UInt | order_ |
| The order of the smoothing polynomial. | |
Computes the Savitzky-Golay filter coefficients using QR decomposition.
This class represents a Savitzky-Golay lowpass-filter. The idea of the Savitzky-Golay filter is to find filtercoefficients that preserve higher moments, which means to approximate the underlying function within the moving window by a polynomial of higher order (typically quadratic or quartic). Therefore we least-squares fit for each data point a polynomial to all points
in the window and set
to be the value of that polynomial at position
. This method is superior to adjacent averaging because it tends to preserve features of the data such as peak height and width, which are usually 'washed out' by adjacent averaging.
Because of the linearity of the problem, we can reduce the work computing by fitting in advance, for fictious data consisiting of all zeros except for a singe 1 and then do the fits on the real data just by taking linear combinations. There are a particular sets of filter coefficients
which accomplish the process of polynomial least-squares fit inside a moving window. To get the symmetric coefficient-matrix
with
The first (last)
rows of
we need to smooth the first (last)
data points of the signal. So we use for the smoothing of the first data point the data point itself and the next
future points. For the second point we take the first datapoint, the data point itself and
of rightward data points... . We compute the Matrix
by solving the underlying least-squares problems with the singular value decomposition. Here we demonstrate the computation of the first row of a coefficient-matrix
for a Savitzky-Golay Filter of order=3 and frameSize=5: The design-matrix for the least-squares fit of a linear combination of 3 basis functions to 5 data points is:
To smooth the first data point we have to create a design-matrix with
. Now we have to solve the over-determined set of
linear equations
where
represents the fictious data. Therefore we solve the normal equations of the least-squares problem
Now, it is possible to get
with
. Because we only need one row of the inverse matrix, it is possible to use LU decomposition with only a single backsubstitution. The vector
represents the wanted coefficients. Note that the solution of a least-squares problem directly from the normal equations is faster than the singular value decomposition but rather susceptible to roundoff error!
| Name | Type | Default | Restrictions | Description |
|---|---|---|---|---|
| frame_length | int | 11 | The number of subsequent data points used for smoothing. This number has to be uneven. If it is not, 1 will be added. |
|
| polynomial_order | int | 4 | Order or the polynomial that is fitted. |
Constructor.
| virtual ~SavitzkyGolayFilter | ( | ) | [virtual] |
Destructor.
| void filter | ( | MSSpectrum< PeakType > & | spectrum | ) | [inline] |
Removed the noise from an MSSpectrum containing profile data.
| void filterExperiment | ( | MSExperiment< PeakType > & | map | ) | [inline] |
Removed the noise from an MSExperiment containing profile data.
| virtual void updateMembers_ | ( | ) | [protected, virtual] |
This method is used to update extra member variables at the end of the setParameters() method.
Also call it at the end of the derived classes' copy constructor and assignment operator.
The default implementation is empty.
Reimplemented from DefaultParamHandler.
std::vector<DoubleReal> coeffs_ [protected] |
Coefficients.
UInt frame_size_ [protected] |
UInt of the filter kernel (number of pre-tabulated coefficients).
| OpenMS / TOPP release 1.10.0 | Documentation generated on Thu Mar 7 2013 09:42:53 using doxygen 1.7.1 |