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
00036 #ifndef OPENMS_TRANSFORMATIONS_FEATUREFINDER_INTERPOLATIONMODEL_H
00037 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_INTERPOLATIONMODEL_H
00038
00039 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/BaseModel.h>
00040 #include <OpenMS/MATH/MISC/LinearInterpolation.h>
00041
00042 namespace OpenMS
00043 {
00055 class OPENMS_DLLAPI InterpolationModel :
00056 public BaseModel<1>
00057 {
00058
00059 public:
00060 typedef DoubleReal IntensityType;
00061 typedef DPosition<1> PositionType;
00062 typedef DoubleReal CoordinateType;
00063 typedef Math::LinearInterpolation<DoubleReal> LinearInterpolation;
00064
00066 InterpolationModel() :
00067 BaseModel<1>(),
00068 interpolation_()
00069 {
00070 this->defaults_.setValue("interpolation_step", 0.1, "Sampling rate for the interpolation of the model function ");
00071 this->defaults_.setValue("intensity_scaling", 1.0, "Scaling factor used to adjust the model distribution to the intensities of the data");
00072 }
00073
00075 InterpolationModel(const InterpolationModel & source) :
00076 BaseModel<1>(source),
00077 interpolation_(source.interpolation_),
00078 interpolation_step_(source.interpolation_step_),
00079 scaling_(source.scaling_)
00080 {
00081 }
00082
00084 virtual ~InterpolationModel()
00085 {
00086 }
00087
00089 virtual InterpolationModel & operator=(const InterpolationModel & source)
00090 {
00091 if (&source == this) return *this;
00092
00093 BaseModel<1>::operator=(source);
00094 interpolation_step_ = source.interpolation_step_;
00095 interpolation_ = source.interpolation_;
00096 scaling_ = source.scaling_;
00097
00098 return *this;
00099 }
00100
00102 IntensityType getIntensity(const PositionType & pos) const
00103 {
00104 return interpolation_.value(pos[0]);
00105 }
00106
00108 IntensityType getIntensity(CoordinateType coord) const
00109 {
00110 return interpolation_.value(coord);
00111 }
00112
00114 const LinearInterpolation & getInterpolation() const
00115 {
00116 return interpolation_;
00117 }
00118
00124 CoordinateType getScalingFactor() const
00125 {
00126 return scaling_;
00127 }
00128
00134 virtual void setOffset(CoordinateType offset)
00135 {
00136 interpolation_.setOffset(offset);
00137 }
00138
00140 void getSamples(SamplesType & cont) const
00141 {
00142 cont = SamplesType();
00143 BaseModel<1>::PeakType peak;
00144 for (Size i = 0; i < interpolation_.getData().size(); ++i)
00145 {
00146 peak.setIntensity(interpolation_.getData()[i]);
00147 peak.getPosition()[0] = interpolation_.index2key(i);
00148 cont.push_back(peak);
00149 }
00150 }
00151
00153 virtual CoordinateType getCenter() const
00154 {
00155 throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
00156 return CoordinateType();
00157 }
00158
00160 virtual void setSamples()
00161 {
00162 throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
00163 }
00164
00170 void setInterpolationStep(CoordinateType interpolation_step)
00171 {
00172 interpolation_step_ = interpolation_step;
00173 this->param_.setValue("interpolation_step", interpolation_step_);
00174 }
00175
00176 void setScalingFactor(CoordinateType scaling)
00177 {
00178 scaling_ = scaling;
00179 this->param_.setValue("intensity_scaling", scaling_);
00180 }
00181
00182 protected:
00183 LinearInterpolation interpolation_;
00184 CoordinateType interpolation_step_;
00185 CoordinateType scaling_;
00186
00187 void updateMembers_()
00188 {
00189 BaseModel<1>::updateMembers_();
00190 interpolation_step_ = this->param_.getValue("interpolation_step");
00191 scaling_ = this->param_.getValue("intensity_scaling");
00192 }
00193
00194 };
00195 }
00196
00197 #endif // OPENMS_TRANSFORMATIONS_FEATUREFINDER_INTERPOLATIONMODEL_H