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