OpenMS  2.7.0
TraceFitter.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg$
32 // $Authors: Stephan Aiche, Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 #include <OpenMS/KERNEL/Peak1D.h>
40 
41 #include <Eigen/Core>
42 
43 namespace OpenMS
44 {
45 
55  class OPENMS_DLLAPI TraceFitter :
56  public DefaultParamHandler
57  {
58 
59 public:
61  //TODO: This is copy and paste from LevMarqFitter1d.h. Make a generic wrapper for LM optimization
63  {
64 public:
65  int inputs() const;
66  int values() const;
67 
68  GenericFunctor(int dimensions, int num_data_points);
69 
70  virtual ~GenericFunctor();
71 
72  virtual int operator()(const Eigen::VectorXd& x, Eigen::VectorXd& fvec) = 0;
73  // compute Jacobian matrix for the different parameters
74  virtual int df(const Eigen::VectorXd& x, Eigen::MatrixXd& J) = 0;
75 
76 protected:
77  const int m_inputs, m_values;
78  };
79 
82 
84  TraceFitter(const TraceFitter& source);
85 
88 
90  ~TraceFitter() override;
91 
96 
100  virtual double getLowerRTBound() const = 0;
101 
105  virtual double getUpperRTBound() const = 0;
106 
110  virtual double getHeight() const = 0;
111 
115  virtual double getCenter() const = 0;
116 
120  virtual double getFWHM() const = 0;
121 
125  virtual double getValue(double rt) const = 0;
126 
134 
141  virtual bool checkMinimalRTSpan(const std::pair<double, double>& rt_bounds, const double min_rt_span) = 0;
142 
148  virtual bool checkMaximalRTSpan(const double max_rt_span) = 0;
149 
153  virtual double getArea() = 0;
154 
164  virtual String getGnuplotFormula(const FeatureFinderAlgorithmPickedHelperStructs::MassTrace& trace, const char function_name, const double baseline, const double rt_shift) = 0;
165 
166 protected:
167  struct ModelData
168  {
170  bool weighted;
171  };
172 
173  void updateMembers_() override;
174 
180  virtual void getOptimizedParameters_(const Eigen::VectorXd&) = 0;
184  void optimize_(Eigen::VectorXd& x_init, GenericFunctor& functor);
185 
189  bool weighted_;
190 
191  };
192 
193 }
194 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
A more convenient string class.
Definition: String.h:61
Definition: TraceFitter.h:63
virtual int df(const Eigen::VectorXd &x, Eigen::MatrixXd &J)=0
GenericFunctor(int dimensions, int num_data_points)
virtual int operator()(const Eigen::VectorXd &x, Eigen::VectorXd &fvec)=0
const int m_inputs
Definition: TraceFitter.h:77
Abstract fitter for RT profile fitting.
Definition: TraceFitter.h:57
TraceFitter()
default constructor
virtual double getLowerRTBound() const =0
virtual void fit(FeatureFinderAlgorithmPickedHelperStructs::MassTraces &traces)=0
FeatureFinderAlgorithmPickedHelperStructs::MassTraces * traces_ptr
Definition: TraceFitter.h:169
bool weighted_
Whether to weight mass traces by theoretical intensity during the optimization.
Definition: TraceFitter.h:189
virtual double getHeight() const =0
void optimize_(Eigen::VectorXd &x_init, GenericFunctor &functor)
virtual String getGnuplotFormula(const FeatureFinderAlgorithmPickedHelperStructs::MassTrace &trace, const char function_name, const double baseline, const double rt_shift)=0
bool weighted
Definition: TraceFitter.h:170
virtual double getValue(double rt) const =0
virtual double getCenter() const =0
TraceFitter & operator=(const TraceFitter &source)
assignment operator
double computeTheoretical(const FeatureFinderAlgorithmPickedHelperStructs::MassTrace &trace, Size k) const
virtual double getUpperRTBound() const =0
virtual double getFWHM() const =0
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
virtual double getArea()=0
SignedSize max_iterations_
Maximum number of iterations.
Definition: TraceFitter.h:187
~TraceFitter() override
destructor
virtual void getOptimizedParameters_(const Eigen::VectorXd &)=0
virtual bool checkMinimalRTSpan(const std::pair< double, double > &rt_bounds, const double min_rt_span)=0
Definition: TraceFitter.h:168
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
const double k
Definition: Constants.h:153
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Helper struct for mass traces used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:80
Helper struct for a collection of mass traces used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:111