| OpenMS 2.5.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-2020.
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
37 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeatureFinderAlgorithmPickedHelperStructs.h>
38 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
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
62 class GenericFunctor
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
81 TraceFitter();
82
84 TraceFitter(const TraceFitter& source);
85
87 virtual TraceFitter& operator=(const TraceFitter& source);
88
90 ~TraceFitter() override;
91
95 virtual void fit(FeatureFinderAlgorithmPickedHelperStructs::MassTraces& traces) = 0;
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
133 double computeTheoretical(const FeatureFinderAlgorithmPickedHelperStructs::MassTrace& trace, Size k);
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 {
169 FeatureFinderAlgorithmPickedHelperStructs::MassTraces* traces_ptr;
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
187 SignedSize max_iterations_;
189 bool weighted_;
190
191 };
192
193 }
194
OpenMS::SignedSize
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
OpenMS::FeatureFinderAlgorithmPickedHelperStructs::MassTraces
Helper struct for a collection of mass traces used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:109
OpenMS::String
A more convenient string class.
Definition: String.h:58
FeatureFinderAlgorithmPickedHelperStructs.h
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
OpenMS::Constants::k
const double k
OpenMS::TraceFitter::ModelData::weighted
bool weighted
Definition: TraceFitter.h:170
OpenMS::TraceFitter::max_iterations_
SignedSize max_iterations_
Maximum number of iterations.
Definition: TraceFitter.h:187
Peak1D.h
OpenMS::TraceFitter
Abstract fitter for RT profile fitting.
Definition: TraceFitter.h:55
OpenMS::FeatureFinderAlgorithmPickedHelperStructs::MassTrace
Helper struct for mass traces used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:79
OpenMS::TraceFitter::ModelData::traces_ptr
FeatureFinderAlgorithmPickedHelperStructs::MassTraces * traces_ptr
Definition: TraceFitter.h:169
OpenMS::TraceFitter::GenericFunctor::m_values
const int m_values
Definition: TraceFitter.h:77
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::TraceFitter::ModelData
Definition: TraceFitter.h:167
OpenMS::TraceFitter::GenericFunctor
Definition: TraceFitter.h:62
OpenMS::TraceFitter::weighted_
bool weighted_
Whether to weight mass traces by theoretical intensity during the optimization.
Definition: TraceFitter.h:189
DefaultParamHandler.h
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127