Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
OptimizePick.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-2017.
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: Eva Lange $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_OPTIMIZEPICK_H
36 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_OPTIMIZEPICK_H
37 
39 #include <OpenMS/KERNEL/Peak1D.h>
40 
41 #include <Eigen/Core>
42 #include <unsupported/Eigen/NonLinearOptimization>
43 
44 #include <vector>
45 
46 namespace OpenMS
47 {
48  namespace OptimizationFunctions
49  {
51  typedef std::vector<Peak1D> RawDataVector;
53  typedef RawDataVector::iterator PeakIterator;
54 
63  struct OPENMS_DLLAPI PenaltyFactors
64  {
66  pos(0), lWidth(0), rWidth(0) {}
68  pos(p.pos), lWidth(p.lWidth), rWidth(p.rWidth) {}
70  {
71  pos = p.pos;
72  lWidth = p.lWidth;
73  rWidth = p.rWidth;
74 
75  return *this;
76  }
77 
79 
81  double pos;
83  double lWidth;
85  double rWidth;
86  };
87  }
88 
89 
96  class OPENMS_DLLAPI OptimizePick
97  {
98 public:
99 
100  struct Data
101  {
103  std::vector<double> positions;
104  std::vector<double> signal;
106  std::vector<PeakShape> peaks;
107 
109 
110  };
111 
113  {
114  public:
115  int inputs() const { return m_inputs; }
116  int values() const { return m_values; }
117 
118  OptPeakFunctor(unsigned dimensions, unsigned num_data_points, const OptimizePick::Data * data)
119  : m_inputs(dimensions), m_values(num_data_points), m_data(data) {}
120 
121  int operator()(const Eigen::VectorXd &x, Eigen::VectorXd &fvec);
122  // compute Jacobian matrix for the different parameters
123  int df(const Eigen::VectorXd &x, Eigen::MatrixXd &J);
124 
125  private:
126  const int m_inputs, m_values;
127  const Data * m_data;
128  };
129 
131  typedef std::vector<Peak1D> RawDataVector;
133  typedef RawDataVector::iterator PeakIterator;
134 
135 
138  max_iteration_(400)
139  {}
140 
142  OptimizePick(const struct OptimizationFunctions::PenaltyFactors & penalties_,
143  const int max_iteration_);
144 
146  ~OptimizePick();
147 
149  inline const struct OptimizationFunctions::PenaltyFactors & getPenalties() const { return penalties_; }
151  inline struct OptimizationFunctions::PenaltyFactors & getPenalties() { return penalties_; }
153  inline void setPenalties(const struct OptimizationFunctions::PenaltyFactors & penalties) { penalties_ = penalties; }
154 
156  inline UInt getNumberIterations() const { return max_iteration_; }
158  inline unsigned int & getNumberIterations() { return max_iteration_; }
160  inline void setNumberIterations(const int max_iteration) { max_iteration_ = max_iteration; }
161 
163  void optimize(std::vector<PeakShape> & peaks, Data & data);
164 
165 
166 protected:
169 
171  unsigned int max_iteration_;
172  };
173 }
174 
175 #endif
std::vector< double > positions
Positions and intensity values of the raw data.
Definition: OptimizePick.h:103
unsigned int max_iteration_
Maximum number of iterations during optimization.
Definition: OptimizePick.h:171
Definition: OptimizePick.h:100
void setNumberIterations(const int max_iteration)
Mutable access to the number of iterations.
Definition: OptimizePick.h:160
OptimizePick()
Constructor.
Definition: OptimizePick.h:137
~PenaltyFactors()
Definition: OptimizePick.h:78
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
PenaltyFactors & operator=(const PenaltyFactors &p)
Definition: OptimizePick.h:69
OptimizationFunctions::PenaltyFactors penalties
Definition: OptimizePick.h:108
PenaltyFactors(const PenaltyFactors &p)
Definition: OptimizePick.h:67
const Data * m_data
Definition: OptimizePick.h:127
std::vector< Peak1D > RawDataVector
Raw data vector type.
Definition: OptimizePick.h:51
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
double lWidth
Penalty factor for the peak shape&#39;s left width parameter.
Definition: OptimizePick.h:83
RawDataVector::iterator PeakIterator
Raw data iterator type.
Definition: OptimizePick.h:53
std::vector< PeakShape > peaks
This container contains the peak shapes to be optimized.
Definition: OptimizePick.h:106
const struct OptimizationFunctions::PenaltyFactors & getPenalties() const
Non-mutable access to the penalty factors.
Definition: OptimizePick.h:149
int inputs() const
Definition: OptimizePick.h:115
const int m_values
Definition: OptimizePick.h:126
double pos
Penalty factor for the peak shape&#39;s position.
Definition: OptimizePick.h:81
OptPeakFunctor(unsigned dimensions, unsigned num_data_points, const OptimizePick::Data *data)
Definition: OptimizePick.h:118
unsigned int & getNumberIterations()
Mutable access to the number of iterations.
Definition: OptimizePick.h:158
double rWidth
Penalty factor for the peak shape&#39;s right width parameter.
Definition: OptimizePick.h:85
Definition: OptimizePick.h:112
Class for the penalty factors used during the optimization.
Definition: OptimizePick.h:63
std::vector< double > signal
Definition: OptimizePick.h:104
RawDataVector::iterator PeakIterator
Raw data iterator type.
Definition: OptimizePick.h:133
int values() const
Definition: OptimizePick.h:116
This class provides the non-linear optimization of the peak parameters.
Definition: OptimizePick.h:96
struct OptimizationFunctions::PenaltyFactors & getPenalties()
Mutable access to the penalty factors.
Definition: OptimizePick.h:151
void setPenalties(const struct OptimizationFunctions::PenaltyFactors &penalties)
Mutable access to the penalty factors.
Definition: OptimizePick.h:153
PenaltyFactors()
Definition: OptimizePick.h:65
std::vector< Peak1D > RawDataVector
Raw data vector type.
Definition: OptimizePick.h:131
UInt getNumberIterations() const
Non-mutable access to the number of iterations.
Definition: OptimizePick.h:156

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:02 using doxygen 1.8.13