Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
TransformationModel.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-2013.
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: $
32 // $Authors: Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_ANALYSIS_MAPMATCHING_TRANSFORMATIONMODEL_H
36 #define OPENMS_ANALYSIS_MAPMATCHING_TRANSFORMATIONMODEL_H
37 
39 
40 #include <gsl/gsl_bspline.h>
41 #include <gsl/gsl_interp.h>
42 
43 namespace OpenMS
44 {
52  class OPENMS_DLLAPI TransformationModel
53  {
54 public:
56  typedef std::pair<DoubleReal, DoubleReal> DataPoint;
58  typedef std::vector<DataPoint> DataPoints;
59 
62 
65  const Param &) :
66  params_() {}
67 
69  virtual ~TransformationModel() {}
70 
72  virtual DoubleReal evaluate(const DoubleReal value) const
73  {
74  return value;
75  }
76 
78  void getParameters(Param & params) const
79  {
80  params = params_;
81  }
82 
84  static void getDefaultParameters(Param & params)
85  {
86  params.clear();
87  }
88 
89 protected:
92  };
93 
94 
104  class OPENMS_DLLAPI TransformationModelLinear :
105  public TransformationModel
106  {
107 public:
113  TransformationModelLinear(const DataPoints & data, const Param & params);
114 
117 
119  virtual DoubleReal evaluate(const DoubleReal value) const;
120 
122 
124  void getParameters(DoubleReal & slope, DoubleReal & intercept) const;
125 
127  static void getDefaultParameters(Param & params);
128 
134  void invert();
135 
136 protected:
138  DoubleReal slope_, intercept_;
143  };
144 
145 
155  class OPENMS_DLLAPI TransformationModelInterpolated :
156  public TransformationModel
157  {
158 public:
165  const Param & params);
166 
169 
171  DoubleReal evaluate(const DoubleReal value) const;
172 
174  static void getDefaultParameters(Param & params);
175 
176 protected:
178  std::vector<double> x_, y_;
180  size_t size_;
182  gsl_interp_accel * acc_;
184  gsl_interp * interp_;
187  };
188 
189 
199  class OPENMS_DLLAPI TransformationModelBSpline :
200  public TransformationModel
201  {
202 public:
208  TransformationModelBSpline(const DataPoints & data, const Param & params);
209 
212 
214  DoubleReal evaluate(const DoubleReal value) const;
215 
217  static void getDefaultParameters(Param & params);
218 
219 protected:
227  void getQuantiles_(const gsl_vector * x, const std::vector<double> &
228  quantiles, gsl_vector * results);
229 
231  void computeFit_();
232 
234  void computeLinear_(const double pos, double & slope, double & offset,
235  double & sd_err);
236 
238  gsl_vector * x_, * y_, * w_, * bsplines_, * coeffs_;
240  gsl_matrix * cov_;
242  gsl_bspline_workspace * workspace_;
244  size_t size_, ncoeffs_;
245  // First/last breakpoint
246  double xmin_, xmax_;
248  double slope_min_, slope_max_, offset_min_, offset_max_;
250  double sd_err_left_, sd_err_right_;
251  };
252 
253 } // end of namespace OpenMS
254 
255 #endif // OPENMS_ANALYSIS_MAPMATCHING_TRANSFORMATIONMODEL_H
Param params_
Parameters.
Definition: TransformationModel.h:91
TransformationModel()
Constructor.
Definition: TransformationModel.h:61
size_t size_
Number of data points.
Definition: TransformationModel.h:180
gsl_matrix * cov_
Covariance matrix.
Definition: TransformationModel.h:240
TransformationModel(const TransformationModel::DataPoints &, const Param &)
Alternative constructor (derived classes should implement this one!)
Definition: TransformationModel.h:64
B-spline model for transformations.
Definition: TransformationModel.h:199
double slope_min_
Parameters for linear extrapolation.
Definition: TransformationModel.h:248
gsl_interp * interp_
Interpolation function.
Definition: TransformationModel.h:184
int evaluate(const gsl_vector *x, void *params, gsl_vector *f, gsl_matrix *J)
Driver function for the evaluation of function and jacobian.
void clear()
Deletes all entries.
Linear model for transformations.
Definition: TransformationModel.h:104
size_t size_
Number of data points and coefficients.
Definition: TransformationModel.h:244
gsl_interp_accel * acc_
Look-up accelerator.
Definition: TransformationModel.h:182
gsl_bspline_workspace * workspace_
B-spline workspace.
Definition: TransformationModel.h:242
void getParameters(Param &params) const
Gets the (actual) parameters.
Definition: TransformationModel.h:78
gsl_vector * y_
Definition: TransformationModel.h:238
double xmin_
Definition: TransformationModel.h:246
double sd_err_right_
Definition: TransformationModel.h:250
Management and storage of parameters / INI files.
Definition: Param.h:69
std::pair< DoubleReal, DoubleReal > DataPoint
Coordinate pair.
Definition: TransformationModel.h:56
bool symmetric_
Use symmetric regression?
Definition: TransformationModel.h:142
DoubleReal slope_
Parameters of the linear model.
Definition: TransformationModel.h:138
std::vector< DataPoint > DataPoints
Vector of coordinate pairs.
Definition: TransformationModel.h:58
TransformationModelLinear * lm_
Linear model for extrapolation.
Definition: TransformationModel.h:186
Base class for transformation models.
Definition: TransformationModel.h:52
virtual DoubleReal evaluate(const DoubleReal value) const
Evaluates the model at the given value.
Definition: TransformationModel.h:72
virtual ~TransformationModel()
Destructor.
Definition: TransformationModel.h:69
static void getDefaultParameters(Param &params)
Gets the default parameters.
Definition: TransformationModel.h:84
Interpolation model for transformations.
Definition: TransformationModel.h:155
bool data_given_
Was the model estimated from data?
Definition: TransformationModel.h:140
std::vector< double > y_
Definition: TransformationModel.h:178

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:22 using doxygen 1.8.5