![]() |
OpenMS
|
Computes a modified sinc smoothing filter for profile data. More...
#include <OpenMS/PROCESSING/SMOOTHING/ModifiedSincSmoother.h>
Classes | |
| struct | LinearRegression |
| Helper class for weighted linear regression. More... | |
Public Member Functions | |
| ModifiedSincSmoother () | |
| Default constructor with parameter registration. | |
| ModifiedSincSmoother (bool isMS1, int degree, int m) | |
| Constructor initializing the modified sinc smoother. | |
| std::vector< double > | smooth (const std::vector< double > &data) |
| Smooth a vector of data values with boundary extrapolation. | |
| std::vector< double > | smoothExceptBoundaries (const std::vector< double > &data) |
| Smooth data without boundary extension (interior points only). | |
| void | filter (MSSpectrum &spectrum) |
| Apply modified sinc smoothing to an MSSpectrum. | |
| void | filter (MSChromatogram &chromatogram) |
| Apply modified sinc smoothing to an MSChromatogram. | |
| void | filter (Mobilogram &mobilogram) |
| Apply modified sinc smoothing to a Mobilogram. | |
| void | filterExperiment (PeakMap &map) |
| Apply modified sinc smoothing to all spectra and chromatograms in an experiment. | |
Public Member Functions inherited from ProgressLogger | |
| ProgressLogger () | |
| Constructor. | |
| virtual | ~ProgressLogger () |
| Destructor. | |
| ProgressLogger (const ProgressLogger &other) | |
| Copy constructor. | |
| ProgressLogger & | operator= (const ProgressLogger &other) |
| Assignment Operator. | |
| void | setLogType (LogType type) const |
| Sets the progress log that should be used. The default type is NONE! | |
| LogType | getLogType () const |
| Returns the type of progress log being used. | |
| void | setLogger (ProgressLoggerImpl *logger) |
| Sets the logger to be used for progress logging. | |
| void | startProgress (SignedSize begin, SignedSize end, const String &label) const |
| Initializes the progress display. | |
| void | setProgress (SignedSize value) const |
| Sets the current progress. | |
| void | endProgress (UInt64 bytes_processed=0) const |
| void | nextProgress () const |
| increment progress by 1 (according to range begin-end) | |
Public Member Functions inherited from DefaultParamHandler | |
| DefaultParamHandler (const String &name) | |
| Constructor with name that is displayed in error messages. | |
| DefaultParamHandler (const DefaultParamHandler &rhs) | |
| Copy constructor. | |
| virtual | ~DefaultParamHandler () |
| Destructor. | |
| DefaultParamHandler & | operator= (const DefaultParamHandler &rhs) |
| Assignment operator. | |
| virtual bool | operator== (const DefaultParamHandler &rhs) const |
| Equality operator. | |
| void | setParameters (const Param ¶m) |
| Sets the parameters. | |
| const Param & | getParameters () const |
| Non-mutable access to the parameters. | |
| const Param & | getDefaults () const |
| Non-mutable access to the default parameters. | |
| const String & | getName () const |
| Non-mutable access to the name. | |
| void | setName (const String &name) |
| Mutable access to the name. | |
| const std::vector< String > & | getSubsections () const |
| Non-mutable access to the registered subsections. | |
Static Public Member Functions | |
| static int | bandwidthToM (bool isMS1, int degree, double bandwidth) |
| Convert frequency domain bandwidth to spatial domain parameter m. | |
| static int | noiseGainToM (bool isMS1, int degree, double noiseGain) |
| Convert desired noise gain to optimal parameter m. | |
| static double | savitzkyGolayBandwidth (int degree, int m) |
| Compute equivalent Savitzky-Golay bandwidth for comparison. | |
Static Public Member Functions inherited from DefaultParamHandler | |
| static void | writeParametersToMetaValues (const Param &write_this, MetaInfoInterface &write_here, const String &key_prefix="") |
| Writes all parameters to meta values. | |
Protected Member Functions | |
| void | updateMembers_ () override |
| Sync internal state from parameters. | |
Protected Member Functions inherited from DefaultParamHandler | |
| void | defaultsToParam_ () |
| Updates the parameters after the defaults have been set in the constructor. | |
Private Member Functions | |
| void | registerDefaults_ () |
| Register default parameters (shared by both constructors) | |
| std::vector< double > | makeKernel (bool isMS1, int degree, int m, const std::vector< double > &coeffs) |
| Construct the modified sinc convolution kernel. | |
| std::vector< double > | getCoefficients (bool isMS1, int degree, int m) |
| Get correction coefficients for kernel modification. | |
| std::vector< double > | makeFitWeights (bool isMS1, int degree, int m) |
| Construct weights for boundary linear regression. | |
| std::vector< double > | extendData (const std::vector< double > &data, int m) |
| Extend data boundaries using weighted linear regression. | |
Static Private Member Functions | |
| static double | sqr (double x) |
| Helper: square function. | |
Private Attributes | |
| bool | isMS1_ |
| MS1 vs MS filter variant selection. | |
| int | degree_ |
| Polynomial degree for sinc modification (even, 2-10) | |
| int | m_ |
| Kernel half-width parameter (spatial domain) | |
| std::vector< double > | kernel_ |
| Symmetric convolution kernel coefficients [k_0, k_1, ..., k_m]. | |
| std::vector< double > | fit_weights_ |
| Weights for boundary linear regression fitting. | |
Additional Inherited Members | |
Public Types inherited from ProgressLogger | |
| enum | LogType { CMD , GUI , NONE } |
| Possible log types. More... | |
Protected Attributes inherited from ProgressLogger | |
| LogType | type_ |
| time_t | last_invoke_ |
| ProgressLoggerImpl * | current_logger_ |
Protected Attributes inherited from DefaultParamHandler | |
| Param | param_ |
| Container for current parameters. | |
| Param | defaults_ |
| Container for default parameters. This member should be filled in the constructor of derived classes! | |
| std::vector< String > | subsections_ |
| Container for registered subsections. This member should be filled in the constructor of derived classes! | |
| String | error_name_ |
| Name that is displayed in error messages during the parameter checking. | |
| bool | check_defaults_ |
| If this member is set to false no checking if parameters in done;. | |
| bool | warn_empty_defaults_ |
| If this member is set to false no warning is emitted when defaults are empty;. | |
Static Protected Attributes inherited from ProgressLogger | |
| static int | recursion_depth_ |
Computes a modified sinc smoothing filter for profile data.
This class implements the modified sinc (MS) filter from Schmid, Rath & Diebold, "Why and How Savitzky-Golay Filters Should Be Replaced", ACS Measurement Science Au, 2022, 2(2), 185-196.
The filter supports two variants from the paper:
isMS1 = false): wider kernel with decay alpha=4, providing excellent stopband suppression (~-70 dB). Requires m >= degree/2 + 2.isMS1 = true): narrower kernel with decay alpha=2, trading some stopband suppression for a smaller kernel size. Requires m >= degree/2 + 1.The algorithm constructs a symmetric convolution kernel based on a sinc function multiplied by a modified Gaussian window, with optional passband correction terms for polynomial degrees >= 6 (MS) or >= 4 (MS1).
Parameters:
degree: polynomial degree (must be even, 2-10). Higher degree gives sharper cutoff.m: kernel half-width (determines smoothing strength). Use bandwidthToM() or noiseGainToM() to compute from desired filter characteristics.isMS1: selects MS1 (smaller) vs MS (wider) kernel variant.Boundary Handling: For finite data, the filter extends boundaries using weighted linear regression on the nearest available data points to minimize edge artifacts.
Container Support: The filter can process individual data vectors or OpenMS container types (MSSpectrum, MSChromatogram, Mobilogram, PeakMap).
Default constructor with parameter registration.
| ModifiedSincSmoother | ( | bool | isMS1, |
| int | degree, | ||
| int | m | ||
| ) |
Constructor initializing the modified sinc smoother.
| isMS1 | true for MS1 variant (smaller kernel), false for MS variant (wider kernel) |
| degree | polynomial degree for sinc modification (must be even, 2-10) |
| m | kernel half-width parameter (spatial domain) |
| std::invalid_argument | if degree is not even or outside [2,10] |
| std::invalid_argument | if m is too small for the given degree (minimum: m >= degree/2 + 1 for MS1 variant, m >= degree/2 + 2 for MS variant) |
|
static |
Convert frequency domain bandwidth to spatial domain parameter m.
| isMS1 | true for MS1 variant (smaller kernel), false for MS variant (wider kernel) |
| degree | polynomial degree used in the filter |
| bandwidth | normalized frequency bandwidth in (0, 0.5) |
| std::invalid_argument | if bandwidth ∉ (0, 0.5) |
|
private |
Extend data boundaries using weighted linear regression.
Fits linear models to boundary regions using cosine-squared weights, then extrapolates to extend the data symmetrically by m points on each side.
| data | original data vector |
| m | extension half-width (points to add on each side) |
| void filter | ( | Mobilogram & | mobilogram | ) |
Apply modified sinc smoothing to a Mobilogram.
Smooths the intensity values of an ion mobility spectrum while preserving all mobility positions and metadata.
| mobilogram | input/output mobilogram to be smoothed in-place |
| void filter | ( | MSChromatogram & | chromatogram | ) |
Apply modified sinc smoothing to an MSChromatogram.
Smooths the intensity values of a chromatogram while preserving all retention time positions and metadata.
| chromatogram | input/output chromatogram to be smoothed in-place |
| void filter | ( | MSSpectrum & | spectrum | ) |
Apply modified sinc smoothing to an MSSpectrum.
Smooths the intensity values of a mass spectrum while preserving all m/z positions and metadata. Uses copy-filter-swap pattern for exception safety.
| spectrum | input/output spectrum to be smoothed in-place |
| void filterExperiment | ( | PeakMap & | map | ) |
Apply modified sinc smoothing to all spectra and chromatograms in an experiment.
Batch processes all MSSpectra and MSChromatograms in the peak map, applying the filter to each container. Progress is reported via the ProgressLogger interface.
| map | input/output experiment to be smoothed in-place |
|
private |
Get correction coefficients for kernel modification.
| isMS1 | MS1 vs MS filter variant selection |
| degree | polynomial degree |
| m | kernel half-width |
|
private |
Construct weights for boundary linear regression.
Derives fitting window size and cosine-squared weights based on kernel first zero location and empirical beta parameter.
| isMS1 | MS1 vs MS filter variant selection |
| degree | polynomial degree |
| m | kernel half-width |
|
private |
Construct the modified sinc convolution kernel.
| isMS1 | MS1 vs MS filter variant selection |
| degree | polynomial degree for modifications |
| m | kernel half-width |
| coeffs | optional correction coefficients (currently unused) |
|
static |
Convert desired noise gain to optimal parameter m.
Computes the kernel half-width m that achieves the specified noise gain factor for the given filter configuration.
| isMS1 | true for MS1 variant (smaller kernel), false for MS variant (wider kernel) |
| degree | polynomial degree used in the filter |
| noiseGain | desired noise amplification factor (typically < 1) |
|
private |
Register default parameters (shared by both constructors)
|
static |
Compute equivalent Savitzky-Golay bandwidth for comparison.
Given modified sinc parameters, computes the frequency bandwidth that a Savitzky-Golay filter of the same degree would need to achieve similar smoothing characteristics.
| degree | polynomial degree |
| m | kernel half-width parameter |
| std::vector< double > smooth | ( | const std::vector< double > & | data | ) |
Smooth a vector of data values with boundary extrapolation.
Applies the modified sinc filter to the input data. Boundaries are extended using weighted linear regression before filtering, then the result is trimmed to match the original input size.
| data | input intensity values to be smoothed |
| std::vector< double > smoothExceptBoundaries | ( | const std::vector< double > & | data | ) |
Smooth data without boundary extension (interior points only).
Applies the modified sinc filter only where a full symmetric neighborhood exists. Boundary points are left as zeros. This method is typically used with pre-extended data.
| data | input data (potentially pre-extended) |
|
inlinestaticprivate |
Helper: square function.
|
overrideprotectedvirtual |
Sync internal state from parameters.
Reimplemented from DefaultParamHandler.
|
private |
Polynomial degree for sinc modification (even, 2-10)
|
private |
Weights for boundary linear regression fitting.
|
private |
MS1 vs MS filter variant selection.
|
private |
Symmetric convolution kernel coefficients [k_0, k_1, ..., k_m].
|
private |
Kernel half-width parameter (spatial domain)