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

OptimizePick.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: Alexandra Zerck $
00032 // $Authors: Eva Lange $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_OPTIMIZEPICK_H
00036 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_OPTIMIZEPICK_H
00037 
00038 #include <OpenMS/TRANSFORMATIONS/RAW2PEAK/PeakShape.h>
00039 #include <OpenMS/KERNEL/Peak1D.h>
00040 
00041 #include <gsl/gsl_vector.h>
00042 #include <gsl/gsl_multifit_nlin.h>
00043 #include <gsl/gsl_blas.h>
00044 
00045 #include <iostream>
00046 #include <fstream>
00047 #include <vector>
00048 
00049 namespace OpenMS
00050 {
00056   namespace OptimizationFunctions
00057   {
00059     typedef std::vector<Peak1D> RawDataVector;
00061     typedef RawDataVector::iterator PeakIterator;
00062 
00071     struct OPENMS_DLLAPI PenaltyFactors
00072     {
00073       PenaltyFactors() :
00074         pos(0), lWidth(0), rWidth(0) {}
00075       PenaltyFactors(const PenaltyFactors & p) :
00076         pos(p.pos), lWidth(p.lWidth), rWidth(p.rWidth) {}
00077       inline PenaltyFactors & operator=(const PenaltyFactors & p)
00078       {
00079         pos = p.pos;
00080         lWidth = p.lWidth;
00081         rWidth = p.rWidth;
00082 
00083         return *this;
00084       }
00085 
00086       ~PenaltyFactors(){}
00087 
00089       double pos;
00091       double lWidth;
00093       double rWidth;
00094     };
00095 
00097     int residual(const gsl_vector * x, void * params, gsl_vector * f);
00098 
00100     int jacobian(const gsl_vector * x, void * params, gsl_matrix * J);
00101 
00103     int evaluate(const gsl_vector * x, void * params, gsl_vector * f, gsl_matrix * J);
00104 
00106     void printSignal(const gsl_vector * x, void * param, float resolution = 0.25);
00107   }
00108 
00109 
00116   class OPENMS_DLLAPI OptimizePick
00117   {
00118 public:
00119 
00120     struct Data
00121     {
00123       std::vector<double> positions;
00124       std::vector<double> signal;
00126       std::vector<PeakShape> peaks;
00127 
00128       OptimizationFunctions::PenaltyFactors penalties;
00129 
00130     };
00131 
00132 
00134     typedef std::vector<Peak1D> RawDataVector;
00136     typedef RawDataVector::iterator PeakIterator;
00137 
00138 
00140     OptimizePick() :
00141       max_iteration_(0),
00142       eps_abs_(0),
00143       eps_rel_(0) {}
00144 
00146     OptimizePick(const struct OptimizationFunctions::PenaltyFactors & penalties_,
00147                  const int max_iteration_,
00148                  const double eps_abs_,
00149                  const double eps_rel_);
00150 
00152     ~OptimizePick();
00153 
00155     inline const struct OptimizationFunctions::PenaltyFactors & getPenalties() const { return penalties_; }
00157     inline struct OptimizationFunctions::PenaltyFactors & getPenalties() { return penalties_; }
00159     inline void setPenalties(const struct OptimizationFunctions::PenaltyFactors & penalties) { penalties_ = penalties; }
00160 
00162     inline UInt getNumberIterations() const { return max_iteration_; }
00164     inline unsigned int & getNumberIterations() { return max_iteration_; }
00166     inline void setNumberIterations(const int max_iteration) { max_iteration_ = max_iteration; }
00167 
00169     inline DoubleReal getMaxAbsError() const { return eps_abs_; }
00171     inline double & getMaxAbsError() { return eps_abs_; }
00173     inline void setMaxAbsError(double eps_abs) { eps_abs_ = eps_abs; }
00174 
00176     inline DoubleReal getMaxRelError() const { return eps_rel_; }
00178     inline double & getMaxRelError() { return eps_rel_; }
00180     inline void setMaxRelError(double eps_rel) { eps_rel_ = eps_rel; }
00181 
00183     void optimize(std::vector<PeakShape> & peaks, Data & data);
00184 
00185 
00186 protected:
00188     struct OptimizationFunctions::PenaltyFactors penalties_;
00189 
00191     unsigned int max_iteration_;
00192 
00194     double eps_abs_;
00195     double eps_rel_;
00196 
00197 //       /** @brief Returns the squared pearson coefficient.
00198 
00199 //         Computes the correlation of the peak and the original data given by the peak enpoints.
00200 //         If the value is near 1, the fitted peakshape and the raw data are expected to be very similar.
00201 //     */
00202 //     double correlate_(const PeakShape& peak,
00203 //                                          double left_endpoint,
00204 //                                          double right_endpoint,Data& data);
00205 
00206   };
00207 }
00208 
00209 #endif

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