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 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_OPTIMIZEPICK_H
00028 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_OPTIMIZEPICK_H
00029
00030 #include <OpenMS/TRANSFORMATIONS/RAW2PEAK/PeakShape.h>
00031 #include <OpenMS/KERNEL/DRawDataPoint.h>
00032
00033 #include <gsl/gsl_vector.h>
00034 #include <gsl/gsl_multifit_nlin.h>
00035 #include <gsl/gsl_blas.h>
00036
00037 #include <iostream>
00038 #include <fstream>
00039 #include <vector>
00040
00041 namespace OpenMS
00042 {
00048 namespace OptimizationFunctions
00049 {
00051 typedef std::vector<DRawDataPoint<1> > RawDataVector;
00053 typedef RawDataVector::iterator RawDataPointIterator;
00054
00063 struct PenaltyFactors
00064 {
00065 PenaltyFactors() : pos(0), lWidth(0), rWidth(0) {}
00066 PenaltyFactors(const PenaltyFactors& p) : pos(p.pos), lWidth(p.lWidth), rWidth(p.rWidth) {}
00067 inline PenaltyFactors& operator=(const PenaltyFactors& p)
00068 {
00069 pos=p.pos;
00070 lWidth=p.lWidth;
00071 rWidth=p.rWidth;
00072
00073 return *this;
00074 }
00075 ~PenaltyFactors(){}
00076
00078 double pos;
00080 double lWidth;
00082 double rWidth;
00083 };
00084
00086 extern std::vector<double> positions_;
00087 extern std::vector<double> signal_;
00089 extern std::vector<PeakShape> peaks_;
00090
00092 int residual(const gsl_vector* x, void* , gsl_vector* f);
00093
00095 int jacobian(const gsl_vector* x, void* , gsl_matrix* J);
00096
00098 int evaluate(const gsl_vector* x, void* params, gsl_vector* f, gsl_matrix* J);
00099
00101 void printSignal(const gsl_vector* x, float resolution = 0.25);
00102 }
00103
00104
00113 class OptimizePick
00114 {
00115 public:
00117 typedef std::vector<DRawDataPoint<1> > RawDataVector;
00119 typedef RawDataVector::iterator RawDataPointIterator;
00121
00122
00124 OptimizePick( )
00125 : max_iteration_(0),
00126 eps_abs_(0),
00127 eps_rel_(0) {}
00128
00130 OptimizePick(const struct OptimizationFunctions::PenaltyFactors& penalties_,
00131 const int max_iteration_,
00132 const double eps_abs_,
00133 const double eps_rel_ );
00134
00136 ~OptimizePick();
00137
00139 inline const struct OptimizationFunctions::PenaltyFactors& getPenalties() const { return penalties_; }
00141 inline struct OptimizationFunctions::PenaltyFactors& getPenalties() { return penalties_; }
00143 inline void setPenalties(const struct OptimizationFunctions::PenaltyFactors& penalties) { penalties_ = penalties; }
00144
00146 inline UInt getNumberIterations() const { return max_iteration_; }
00148 inline unsigned int& getNumberIterations() { return max_iteration_; }
00150 inline void setNumberIterations(const int max_iteration) { max_iteration_ = max_iteration; }
00151
00153 inline DoubleReal getMaxAbsError() const { return eps_abs_; }
00155 inline double& getMaxAbsError() { return eps_abs_; }
00157 inline void setMaxAbsError(double eps_abs) { eps_abs_ = eps_abs; }
00158
00160 inline DoubleReal getMaxRelError() const { return eps_rel_; }
00162 inline double& getMaxRelError() { return eps_rel_; }
00164 inline void setMaxRelError(double eps_rel) { eps_rel_ = eps_rel; }
00166
00167
00169 void optimize(std::vector<PeakShape>& peaks);
00170
00171
00172 protected:
00174 struct OptimizationFunctions::PenaltyFactors penalties_;
00175
00177 unsigned int max_iteration_;
00178
00180 double eps_abs_;
00181 double eps_rel_;
00182
00188 double correlate_(const PeakShape& peak,
00189 double left_endpoint,
00190 double right_endpoint);
00191
00192 };
00193 }
00194
00195 #endif