Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_ANALYSIS_MAPMATCHING_TRANSFORMATIONMODEL_H
00036 #define OPENMS_ANALYSIS_MAPMATCHING_TRANSFORMATIONMODEL_H
00037
00038 #include <OpenMS/DATASTRUCTURES/Param.h>
00039
00040 #include <gsl/gsl_bspline.h>
00041 #include <gsl/gsl_interp.h>
00042
00043 namespace OpenMS
00044 {
00052 class OPENMS_DLLAPI TransformationModel
00053 {
00054 public:
00056 typedef std::pair<DoubleReal, DoubleReal> DataPoint;
00058 typedef std::vector<DataPoint> DataPoints;
00059
00061 TransformationModel() {}
00062
00064 TransformationModel(const TransformationModel::DataPoints &,
00065 const Param &) :
00066 params_() {}
00067
00069 virtual ~TransformationModel() {}
00070
00072 virtual DoubleReal evaluate(const DoubleReal value) const
00073 {
00074 return value;
00075 }
00076
00078 void getParameters(Param & params) const
00079 {
00080 params = params_;
00081 }
00082
00084 static void getDefaultParameters(Param & params)
00085 {
00086 params.clear();
00087 }
00088
00089 protected:
00091 Param params_;
00092 };
00093
00094
00104 class OPENMS_DLLAPI TransformationModelLinear :
00105 public TransformationModel
00106 {
00107 public:
00113 TransformationModelLinear(const DataPoints & data, const Param & params);
00114
00116 ~TransformationModelLinear();
00117
00119 virtual DoubleReal evaluate(const DoubleReal value) const;
00120
00121 using TransformationModel::getParameters;
00122
00124 void getParameters(DoubleReal & slope, DoubleReal & intercept) const;
00125
00127 static void getDefaultParameters(Param & params);
00128
00134 void invert();
00135
00136 protected:
00138 DoubleReal slope_, intercept_;
00140 bool data_given_;
00142 bool symmetric_;
00143 };
00144
00145
00155 class OPENMS_DLLAPI TransformationModelInterpolated :
00156 public TransformationModel
00157 {
00158 public:
00164 TransformationModelInterpolated(const DataPoints & data,
00165 const Param & params);
00166
00168 ~TransformationModelInterpolated();
00169
00171 DoubleReal evaluate(const DoubleReal value) const;
00172
00174 static void getDefaultParameters(Param & params);
00175
00176 protected:
00178 std::vector<double> x_, y_;
00180 size_t size_;
00182 gsl_interp_accel * acc_;
00184 gsl_interp * interp_;
00186 TransformationModelLinear * lm_;
00187 };
00188
00189
00199 class OPENMS_DLLAPI TransformationModelBSpline :
00200 public TransformationModel
00201 {
00202 public:
00208 TransformationModelBSpline(const DataPoints & data, const Param & params);
00209
00211 ~TransformationModelBSpline();
00212
00214 DoubleReal evaluate(const DoubleReal value) const;
00215
00217 static void getDefaultParameters(Param & params);
00218
00219 protected:
00227 void getQuantiles_(const gsl_vector * x, const std::vector<double> &
00228 quantiles, gsl_vector * results);
00229
00231 void computeFit_();
00232
00234 void computeLinear_(const double pos, double & slope, double & offset,
00235 double & sd_err);
00236
00238 gsl_vector * x_, * y_, * w_, * bsplines_, * coeffs_;
00240 gsl_matrix * cov_;
00242 gsl_bspline_workspace * workspace_;
00244 size_t size_, ncoeffs_;
00245
00246 double xmin_, xmax_;
00248 double slope_min_, slope_max_, offset_min_, offset_max_;
00250 double sd_err_left_, sd_err_right_;
00251 };
00252
00253 }
00254
00255 #endif // OPENMS_ANALYSIS_MAPMATCHING_TRANSFORMATIONMODEL_H