1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
// --------------------------------------------------------------------------
24
// $Maintainer: Clemens Groepl $
26
// --------------------------------------------------------------------------
28
#include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/BiGaussFitter1D.h>
29
#include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/InterpolationModel.h>
30
#include <boost/math/special_functions/fpclassify.hpp>
33
BiGaussFitter1D::BiGaussFitter1D()
36
setName(getProductName());
38
defaults_.setValue("statistics:variance1",1.0,"Variance of the first gaussian, used for the lower half of the model.", StringList::create("advanced"));
39
defaults_.setValue("statistics:variance2",1.0,"Variance of the second gaussian, used for the upper half of the model.", StringList::create("advanced"));
44
BiGaussFitter1D::BiGaussFitter1D(const BiGaussFitter1D& source)
45
: MaxLikeliFitter1D(source)
50
BiGaussFitter1D::~BiGaussFitter1D()
54
BiGaussFitter1D& BiGaussFitter1D::operator = (const BiGaussFitter1D& source)
56
if (&source == this) return *this;
58
MaxLikeliFitter1D::operator = (source);
64
BiGaussFitter1D::QualityType BiGaussFitter1D::fit1d(const RawDataArrayType& set, InterpolationModel*& model)
66
// Calculate bounding box
67
min_ = max_ = set[0].getPos();
68
for ( UInt pos=1; pos < set.size(); ++pos)
70
CoordinateType tmp = set[pos].getPos();
71
if ( min_ > tmp ) min_ = tmp;
72
if ( max_ < tmp ) max_ = tmp;
75
// Enlarge the bounding box by a few multiples of the standard deviation
77
stdev1_ = sqrt ( statistics1_.variance() ) * tolerance_stdev_box_;
78
stdev2_ = sqrt ( statistics2_.variance() ) * tolerance_stdev_box_;
84
model = static_cast<InterpolationModel*> (Factory<BaseModel<1> >::create("BiGaussModel"));
85
model->setInterpolationStep( interpolation_step_ );
87
tmp.setValue( "bounding_box:min", min_ );
88
tmp.setValue( "bounding_box:max", max_ );
89
tmp.setValue( "statistics:mean", statistics1_.mean() );
90
tmp.setValue( "statistics:variance1", statistics1_.variance() );
91
tmp.setValue( "statistics:variance2", statistics2_.variance() );
92
model->setParameters( tmp );
96
quality = fitOffset_(model, set, stdev1_, stdev2_, interpolation_step_);
97
if (boost::math::isnan(quality) ) quality = -1.0;
102
void BiGaussFitter1D::updateMembers_()
104
MaxLikeliFitter1D::updateMembers_();
105
statistics1_.setMean(param_.getValue("statistics:mean"));
106
statistics1_.setVariance(param_.getValue("statistics:variance1"));
107
statistics2_.setMean(param_.getValue("statistics:mean"));
108
statistics2_.setVariance(param_.getValue("statistics:variance2"));