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/EmgModel.h>
30
#include <OpenMS/CONCEPT/Constants.h>
35
: InterpolationModel()
37
setName(getProductName());
39
defaults_.setValue("bounding_box:min",0.0f,"Lower end of bounding box enclosing the data used to fit the model.", StringList::create("advanced"));
40
defaults_.setValue("bounding_box:max",1.0f,"Upper end of bounding box enclosing the data used to fit the model.", StringList::create("advanced"));
41
defaults_.setValue("statistics:mean",0.0f,"Centroid position of the model.", StringList::create("advanced"));
42
defaults_.setValue("statistics:variance",1.0f,"The variance of the model.", StringList::create("advanced"));
43
defaults_.setValue("emg:height",100000.0f,"Height of the exponentially modified Gaussian.", StringList::create("advanced"));
44
defaults_.setValue("emg:width",5.0f,"Width of the exponentially modified Gaussian.", StringList::create("advanced"));
45
defaults_.setValue("emg:symmetry",5.0f,"Symmetry of the exponentially modified Gaussian.", StringList::create("advanced"));
46
defaults_.setValue("emg:retention",1200.0f,"Retention time of the exponentially modified Gaussian.", StringList::create("advanced"));
51
EmgModel::EmgModel(const EmgModel& source)
52
: InterpolationModel(source)
54
setParameters( source.getParameters() );
62
EmgModel& EmgModel::operator = (const EmgModel& source)
64
if (&source == this) return *this;
66
InterpolationModel::operator = (source);
67
setParameters( source.getParameters() );
73
void EmgModel::setSamples()
75
LinearInterpolation::container_type& data = interpolation_.getData();
77
if (max_==min_) return;
78
data.reserve( UInt ( (max_-min_) / interpolation_step_ + 1 ) );
79
CoordinateType pos = min_;
81
DoubleReal sqrt_2pi = sqrt(2*Constants::PI);
82
DoubleReal term_sq2 = (-2.4055/sqrt(2.0));
83
DoubleReal part1 = (height_*width_/symmetry_);
84
DoubleReal part2 = pow(width_,2)/(2*pow(symmetry_,2));
85
DoubleReal part3 = width_/symmetry_;
87
for ( UInt i = 0; pos< max_; ++i)
89
pos = min_ + i * interpolation_step_;
90
DoubleReal tmp = pos - retention_;
92
// data.push_back (Simplified EMG)
93
data.push_back((part1*sqrt_2pi*exp(part2-(tmp/symmetry_))/(1+exp(term_sq2*((tmp/width_)-part3)))));
96
interpolation_.setScale ( interpolation_step_ );
97
interpolation_.setOffset ( min_ );
100
void EmgModel::setOffset(CoordinateType offset)
102
DoubleReal diff = offset - getInterpolation().getOffset();
105
statistics_.setMean(statistics_.mean() + diff);
107
InterpolationModel::setOffset(offset);
109
param_.setValue("bounding_box:min", min_);
110
param_.setValue("bounding_box:max", max_);
111
param_.setValue("statistics:mean", statistics_.mean());
114
EmgModel::CoordinateType EmgModel::getCenter() const
116
return statistics_.mean();
119
void EmgModel::updateMembers_()
121
InterpolationModel::updateMembers_();
123
min_ = param_.getValue("bounding_box:min");
124
max_ = param_.getValue("bounding_box:max");
125
statistics_.setMean( param_.getValue("statistics:mean") );
126
statistics_.setVariance(param_.getValue("statistics:variance"));
127
height_ = param_.getValue("emg:height");
128
width_ = param_.getValue("emg:width");
129
symmetry_ = param_.getValue("emg:symmetry");
130
retention_ = param_.getValue("emg:retention");