Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

TransformationModel.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: $
00032 // $Authors: Hendrik Weisser $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_ANALYSIS_MAPMATCHING_TRANSFORMATIONMODEL_H
00036 #define OPENMS_ANALYSIS_MAPMATCHING_TRANSFORMATIONMODEL_H
00037 
00038 #include <OpenMS/DATASTRUCTURES/Param.h>
00039 
00040 #include <gsl/gsl_bspline.h>
00041 #include <gsl/gsl_interp.h>
00042 
00043 namespace OpenMS
00044 {
00052   class OPENMS_DLLAPI TransformationModel
00053   {
00054 public:
00056     typedef std::pair<DoubleReal, DoubleReal> DataPoint;
00058     typedef std::vector<DataPoint> DataPoints;
00059 
00061     TransformationModel() {}
00062 
00064     TransformationModel(const TransformationModel::DataPoints &,
00065                         const Param &) :
00066       params_() {}
00067 
00069     virtual ~TransformationModel() {}
00070 
00072     virtual DoubleReal evaluate(const DoubleReal value) const
00073     {
00074       return value;
00075     }
00076 
00078     void getParameters(Param & params) const
00079     {
00080       params = params_;
00081     }
00082 
00084     static void getDefaultParameters(Param & params)
00085     {
00086       params.clear();
00087     }
00088 
00089 protected:
00091     Param params_;
00092   };
00093 
00094 
00104   class OPENMS_DLLAPI TransformationModelLinear :
00105     public TransformationModel
00106   {
00107 public:
00113     TransformationModelLinear(const DataPoints & data, const Param & params);
00114 
00116     ~TransformationModelLinear();
00117 
00119     virtual DoubleReal evaluate(const DoubleReal value) const;
00120 
00121     using TransformationModel::getParameters;
00122 
00124     void getParameters(DoubleReal & slope, DoubleReal & intercept) const;
00125 
00127     static void getDefaultParameters(Param & params);
00128 
00134     void invert();
00135 
00136 protected:
00138     DoubleReal slope_, intercept_;
00140     bool data_given_;
00142     bool symmetric_;
00143   };
00144 
00145 
00155   class OPENMS_DLLAPI TransformationModelInterpolated :
00156     public TransformationModel
00157   {
00158 public:
00164     TransformationModelInterpolated(const DataPoints & data,
00165                                     const Param & params);
00166 
00168     ~TransformationModelInterpolated();
00169 
00171     DoubleReal evaluate(const DoubleReal value) const;
00172 
00174     static void getDefaultParameters(Param & params);
00175 
00176 protected:
00178     std::vector<double> x_, y_;
00180     size_t size_;
00182     gsl_interp_accel * acc_;
00184     gsl_interp * interp_;
00186     TransformationModelLinear * lm_;
00187   };
00188 
00189 
00199   class OPENMS_DLLAPI TransformationModelBSpline :
00200     public TransformationModel
00201   {
00202 public:
00208     TransformationModelBSpline(const DataPoints & data, const Param & params);
00209 
00211     ~TransformationModelBSpline();
00212 
00214     DoubleReal evaluate(const DoubleReal value) const;
00215 
00217     static void getDefaultParameters(Param & params);
00218 
00219 protected:
00227     void getQuantiles_(const gsl_vector * x, const std::vector<double> &
00228                        quantiles, gsl_vector * results);
00229 
00231     void computeFit_();
00232 
00234     void computeLinear_(const double pos, double & slope, double & offset,
00235                         double & sd_err);
00236 
00238     gsl_vector * x_, * y_, * w_, * bsplines_, * coeffs_;
00240     gsl_matrix * cov_;
00242     gsl_bspline_workspace * workspace_;
00244     size_t size_, ncoeffs_;
00245     // First/last breakpoint
00246     double xmin_, xmax_;
00248     double slope_min_, slope_max_, offset_min_, offset_max_;
00250     double sd_err_left_, sd_err_right_;
00251   };
00252 
00253 } // end of namespace OpenMS
00254 
00255 #endif // OPENMS_ANALYSIS_MAPMATCHING_TRANSFORMATIONMODEL_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:46 using doxygen 1.7.1