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_TRANSFORMATIONS_RAW2PEAK_OPTIMIZEPICK_H
00036 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_OPTIMIZEPICK_H
00037
00038 #include <OpenMS/TRANSFORMATIONS/RAW2PEAK/PeakShape.h>
00039 #include <OpenMS/KERNEL/Peak1D.h>
00040
00041 #include <gsl/gsl_vector.h>
00042 #include <gsl/gsl_multifit_nlin.h>
00043 #include <gsl/gsl_blas.h>
00044
00045 #include <iostream>
00046 #include <fstream>
00047 #include <vector>
00048
00049 namespace OpenMS
00050 {
00056 namespace OptimizationFunctions
00057 {
00059 typedef std::vector<Peak1D> RawDataVector;
00061 typedef RawDataVector::iterator PeakIterator;
00062
00071 struct OPENMS_DLLAPI PenaltyFactors
00072 {
00073 PenaltyFactors() :
00074 pos(0), lWidth(0), rWidth(0) {}
00075 PenaltyFactors(const PenaltyFactors & p) :
00076 pos(p.pos), lWidth(p.lWidth), rWidth(p.rWidth) {}
00077 inline PenaltyFactors & operator=(const PenaltyFactors & p)
00078 {
00079 pos = p.pos;
00080 lWidth = p.lWidth;
00081 rWidth = p.rWidth;
00082
00083 return *this;
00084 }
00085
00086 ~PenaltyFactors(){}
00087
00089 double pos;
00091 double lWidth;
00093 double rWidth;
00094 };
00095
00097 int residual(const gsl_vector * x, void * params, gsl_vector * f);
00098
00100 int jacobian(const gsl_vector * x, void * params, gsl_matrix * J);
00101
00103 int evaluate(const gsl_vector * x, void * params, gsl_vector * f, gsl_matrix * J);
00104
00106 void printSignal(const gsl_vector * x, void * param, float resolution = 0.25);
00107 }
00108
00109
00116 class OPENMS_DLLAPI OptimizePick
00117 {
00118 public:
00119
00120 struct Data
00121 {
00123 std::vector<double> positions;
00124 std::vector<double> signal;
00126 std::vector<PeakShape> peaks;
00127
00128 OptimizationFunctions::PenaltyFactors penalties;
00129
00130 };
00131
00132
00134 typedef std::vector<Peak1D> RawDataVector;
00136 typedef RawDataVector::iterator PeakIterator;
00137
00138
00140 OptimizePick() :
00141 max_iteration_(0),
00142 eps_abs_(0),
00143 eps_rel_(0) {}
00144
00146 OptimizePick(const struct OptimizationFunctions::PenaltyFactors & penalties_,
00147 const int max_iteration_,
00148 const double eps_abs_,
00149 const double eps_rel_);
00150
00152 ~OptimizePick();
00153
00155 inline const struct OptimizationFunctions::PenaltyFactors & getPenalties() const { return penalties_; }
00157 inline struct OptimizationFunctions::PenaltyFactors & getPenalties() { return penalties_; }
00159 inline void setPenalties(const struct OptimizationFunctions::PenaltyFactors & penalties) { penalties_ = penalties; }
00160
00162 inline UInt getNumberIterations() const { return max_iteration_; }
00164 inline unsigned int & getNumberIterations() { return max_iteration_; }
00166 inline void setNumberIterations(const int max_iteration) { max_iteration_ = max_iteration; }
00167
00169 inline DoubleReal getMaxAbsError() const { return eps_abs_; }
00171 inline double & getMaxAbsError() { return eps_abs_; }
00173 inline void setMaxAbsError(double eps_abs) { eps_abs_ = eps_abs; }
00174
00176 inline DoubleReal getMaxRelError() const { return eps_rel_; }
00178 inline double & getMaxRelError() { return eps_rel_; }
00180 inline void setMaxRelError(double eps_rel) { eps_rel_ = eps_rel; }
00181
00183 void optimize(std::vector<PeakShape> & peaks, Data & data);
00184
00185
00186 protected:
00188 struct OptimizationFunctions::PenaltyFactors penalties_;
00189
00191 unsigned int max_iteration_;
00192
00194 double eps_abs_;
00195 double eps_rel_;
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 };
00207 }
00208
00209 #endif