OpenMS
Loading...
Searching...
No Matches
TraceFitter.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg$
6// $Authors: Stephan Aiche, Marc Sturm $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14#include <vector>
15
16namespace OpenMS
17{
18
41 class OPENMS_DLLAPI TraceFitter :
43 {
44
45public:
53 //TODO: This is copy and paste from LevMarqFitter1d.h. Make a generic wrapper for LM optimization
55 {
56public:
58 int inputs() const;
60 int values() const;
61
68 GenericFunctor(int dimensions, int num_data_points);
69
70 virtual ~GenericFunctor();
71
79 virtual int operator()(const double* x, double* fvec) = 0;
80
89 virtual int df(const double* x, double* J) = 0;
90
91protected:
92 const int m_inputs, m_values;
93 };
94
97
99 TraceFitter(const TraceFitter& source);
100
103
105 ~TraceFitter() override;
106
117
123 virtual double getLowerRTBound() const = 0;
124
130 virtual double getUpperRTBound() const = 0;
131
137 virtual double getHeight() const = 0;
138
144 virtual double getCenter() const = 0;
145
151 virtual double getFWHM() const = 0;
152
159 virtual double getValue(double rt) const = 0;
160
169
180 virtual bool checkMinimalRTSpan(const std::pair<double, double>& rt_bounds, const double min_rt_span) = 0;
181
191 virtual bool checkMaximalRTSpan(const double max_rt_span) = 0;
192
198 virtual double getArea() = 0;
199
210 virtual std::string getGnuplotFormula(const FeatureFinderAlgorithmPickedHelperStructs::MassTrace& trace, const char function_name, const double baseline, const double rt_shift) = 0;
211
212protected:
219
220 void updateMembers_() override;
221
229 virtual void getOptimizedParameters_(const std::vector<double>& s) = 0;
230
251 void optimize_(std::vector<double>& x_init, GenericFunctor& functor);
252
257
258 };
259
260}
261
A base class for all classes handling default parameters.
Definition DefaultParamHandler.h:66
Generic LM functor with a raw-pointer interface, used to keep Eigen out of the public API.
Definition TraceFitter.h:55
virtual int df(const double *x, double *J)=0
Compute the Jacobian at the current parameter vector.
int values() const
Number of residuals (data points).
GenericFunctor(int dimensions, int num_data_points)
Construct with the given problem dimensions.
const int m_inputs
Definition TraceFitter.h:92
virtual int operator()(const double *x, double *fvec)=0
Compute residuals at the current parameter vector.
int inputs() const
Number of free parameters (input dimensionality).
Abstract base class for fitting an RT-shape model to one or more mass traces.
Definition TraceFitter.h:43
TraceFitter()
Default constructor; registers the "max_iteration" and "weighted" defaults on DefaultParamHandler.
virtual double getLowerRTBound() const =0
Lower RT bound of the fitted RT model.
virtual void fit(FeatureFinderAlgorithmPickedHelperStructs::MassTraces &traces)=0
Run the LM fit on traces.
FeatureFinderAlgorithmPickedHelperStructs::MassTraces * traces_ptr
Mass traces being fitted.
Definition TraceFitter.h:216
bool weighted_
Whether mass traces are weighted by theoretical intensity during fitting; refreshed from "weighted" i...
Definition TraceFitter.h:256
virtual double getHeight() const =0
Height of the fitted RT model at its centre.
bool weighted
Mirror of weighted_ at fit time.
Definition TraceFitter.h:217
virtual double getValue(double rt) const =0
Evaluate the fitted model at retention time rt.
virtual double getCenter() const =0
Centre of the fitted RT model.
virtual void getOptimizedParameters_(const std::vector< double > &s)=0
Subclass hook: copy the optimised parameter vector back into the subclass's model fields.
double computeTheoretical(const FeatureFinderAlgorithmPickedHelperStructs::MassTrace &trace, Size k) const
Evaluate the fitted model at the RT of the k-th peak of trace, scaled by the trace's theoretical inte...
void optimize_(std::vector< double > &x_init, GenericFunctor &functor)
Run Levenberg-Marquardt on functor starting from x_init.
virtual double getUpperRTBound() const =0
Upper RT bound of the fitted RT model.
TraceFitter & operator=(const TraceFitter &source)
Assignment operator.
virtual double getFWHM() const =0
Full width at half maximum of the fitted RT model.
TraceFitter(const TraceFitter &source)
Copy constructor.
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
virtual bool checkMaximalRTSpan(const double max_rt_span)=0
Whether the fitted RT model stays within max_rt_span of the extended search area.
virtual double getArea()=0
Area under the fitted RT model.
virtual std::string getGnuplotFormula(const FeatureFinderAlgorithmPickedHelperStructs::MassTrace &trace, const char function_name, const double baseline, const double rt_shift)=0
Gnuplot expression of the fitted model for trace.
SignedSize max_iterations_
Maximum number of LM iterations; refreshed from "max_iteration" in updateMembers_.
Definition TraceFitter.h:254
~TraceFitter() override
Destructor.
virtual bool checkMinimalRTSpan(const std::pair< double, double > &rt_bounds, const double min_rt_span)=0
Whether the fitted RT model covers at least min_rt_span of the extended search area.
Helper bundle passed to functors so they can read both the traces and the weighting flag.
Definition TraceFitter.h:215
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition Types.h:104
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Helper struct for mass traces used in FeatureFinderAlgorithmPicked.
Definition FeatureFinderAlgorithmPickedHelperStructs.h:54
Helper struct for a collection of mass traces used in FeatureFinderAlgorithmPicked.
Definition FeatureFinderAlgorithmPickedHelperStructs.h:85