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_FEATUREFINDER_MAXLIKELIFITTER1D_H
00036 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_MAXLIKELIFITTER1D_H
00037
00038 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/Fitter1D.h>
00039 #include <OpenMS/MATH/STATISTICS/StatisticFunctions.h>
00040 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/InterpolationModel.h>
00041
00042 namespace OpenMS
00043 {
00044
00048 class OPENMS_DLLAPI MaxLikeliFitter1D :
00049 public Fitter1D
00050 {
00051
00052 public:
00053
00055 MaxLikeliFitter1D() :
00056 Fitter1D()
00057 {
00058 }
00059
00061 MaxLikeliFitter1D(const MaxLikeliFitter1D & source) :
00062 Fitter1D(source)
00063 {
00064 }
00065
00067 virtual ~MaxLikeliFitter1D()
00068 {
00069 }
00070
00072 virtual MaxLikeliFitter1D & operator=(const MaxLikeliFitter1D & source)
00073 {
00074 if (&source == this) return *this;
00075
00076 Fitter1D::operator=(source);
00077
00078 return *this;
00079 }
00080
00081 protected:
00082
00084 QualityType fitOffset_(InterpolationModel * model, const RawDataArrayType & set, const CoordinateType stdev1, const CoordinateType stdev2, const CoordinateType offset_step)
00085 {
00086 const CoordinateType offset_min = model->getInterpolation().supportMin() - stdev1;
00087 const CoordinateType offset_max = model->getInterpolation().supportMin() + stdev2;
00088
00089 CoordinateType offset;
00090 QualityType correlation;
00091
00092
00093 std::vector<Real> real_data;
00094 real_data.reserve(set.size());
00095 std::vector<Real> model_data;
00096 model_data.reserve(set.size());
00097
00098 for (Size i = 0; i < set.size(); ++i)
00099 {
00100 real_data.push_back(set[i].getIntensity());
00101 model_data.push_back(model->getIntensity(DPosition<1>(set[i].getPosition())));
00102 }
00103
00104 CoordinateType max_offset = model->getInterpolation().getOffset();
00105 QualityType max_correlation = Math::pearsonCorrelationCoefficient(real_data.begin(), real_data.end(), model_data.begin(), model_data.end());
00106
00107
00108 for (offset = offset_min; offset <= offset_max; offset += offset_step)
00109 {
00110
00111 model->setOffset(offset);
00112
00113
00114 model_data.clear();
00115 for (Size i = 0; i < set.size(); ++i)
00116 {
00117 model_data.push_back(model->getIntensity(DPosition<1>(set[i].getPosition())));
00118 }
00119
00120 correlation = Math::pearsonCorrelationCoefficient(real_data.begin(), real_data.end(), model_data.begin(), model_data.end());
00121
00122 if (correlation > max_correlation)
00123 {
00124 max_correlation = correlation;
00125 max_offset = offset;
00126 }
00127 }
00128
00129 model->setOffset(max_offset);
00130
00131 return max_correlation;
00132 }
00133
00134 void updateMembers_()
00135 {
00136 Fitter1D::updateMembers_();
00137 }
00138
00139 };
00140 }
00141
00142 #endif // OPENMS_TRANSFORMATIONS_FEATUREFINDER_MAXLIKELIFITTER1D_H