OpenMS
Loading...
Searching...
No Matches
TransformationModel.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Hendrik Weisser $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14
15#include <tuple>
16
17namespace OpenMS
18{
28 class OPENMS_DLLAPI TransformationModel
29 {
30 public:
32 struct DataPoint
33 {
34 double first, second;
36
37 DataPoint(double first_ = 0.0,
38 double second_ = 0.0,
39 const String& note_ = "") :
40 first(first_),
41 second(second_),
42 note(note_)
43 {}
44
45 DataPoint(const std::pair<double, double>& pair) :
46 first(pair.first),
47 second(pair.second),
48 note("")
49 {}
50
51 bool operator<(const DataPoint& other) const
52 {
53 return (std::tie(first, second, note) <
54 std::tie(other.first, other.second, other.note));
55 }
56
57 bool operator==(const DataPoint& other) const
58 {
59 return (std::tie(first, second, note) ==
60 std::tie(other.first, other.second, other.note));
61 }
62 };
63
65 typedef std::vector<DataPoint> DataPoints;
66
69
73
76
78 virtual double evaluate(double value) const;
79
93 virtual void weightData(DataPoints& data);
94
98 virtual void unWeightData(DataPoints& data);
99
103 bool checkValidWeight(const String& weight, const std::vector<String>& valid_weights) const;
104
112 double checkDatumRange(const double& datum, const double& datum_min, const double& datum_max);
113
117 double weightDatum(const double& datum, const String& weight) const;
118
122 double unWeightDatum(const double& datum, const String& weight) const;
123
125 const Param& getParameters() const;
126
128 std::vector<String> getValidXWeights() const;
129
131 std::vector<String> getValidYWeights() const;
132
134 static void getDefaultParameters(Param& params);
135
136 protected:
148
149 private:
154
155 };
156
157} // end of namespace OpenMS
158
Management and storage of parameters / INI files.
Definition Param.h:46
A more convenient string class.
Definition String.h:34
Base class for transformation models.
Definition TransformationModel.h:29
bool checkValidWeight(const String &weight, const std::vector< String > &valid_weights) const
Check for a valid weighting function string.
std::vector< String > getValidXWeights() const
Returns a list of valid x weight function strings.
Param params_
Parameters.
Definition TransformationModel.h:138
const Param & getParameters() const
Gets the (actual) parameters.
TransformationModel()
Constructor.
Definition TransformationModel.h:68
TransformationModel(const TransformationModel::DataPoints &, const Param &)
static void getDefaultParameters(Param &params)
Gets the default parameters.
bool weighting_
Definition TransformationModel.h:147
std::vector< String > getValidYWeights() const
Returns a list of valid y weight function strings.
std::vector< DataPoint > DataPoints
Vector of coordinate pairs.
Definition TransformationModel.h:65
double x_datum_max_
Definition TransformationModel.h:142
String y_weight_
y weighting
Definition TransformationModel.h:144
virtual double evaluate(double value) const
Evaluates the model at the given value.
double checkDatumRange(const double &datum, const double &datum_min, const double &datum_max)
Check that the datum is within the valid min and max bounds.
TransformationModel(const TransformationModel &)
do not allow copy
virtual ~TransformationModel()
Destructor.
double weightDatum(const double &datum, const String &weight) const
Weight the data according to the weighting function.
double unWeightDatum(const double &datum, const String &weight) const
Apply the reverse of the weighting function to the data.
const TransformationModel & operator=(const TransformationModel &)
do not allow assignment
virtual void unWeightData(DataPoints &data)
Unweight the data by the given weight function.
virtual void weightData(DataPoints &data)
Weight the data by the given weight function.
double y_datum_min_
Definition TransformationModel.h:145
double x_datum_min_
Definition TransformationModel.h:141
String x_weight_
x weighting
Definition TransformationModel.h:140
double y_datum_max_
Definition TransformationModel.h:146
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Coordinate pair (with optional annotation)
Definition TransformationModel.h:33
double second
Definition TransformationModel.h:34
String note
Definition TransformationModel.h:35
bool operator<(const DataPoint &other) const
Definition TransformationModel.h:51
DataPoint(double first_=0.0, double second_=0.0, const String &note_="")
Definition TransformationModel.h:37
DataPoint(const std::pair< double, double > &pair)
Definition TransformationModel.h:45
double first
Definition TransformationModel.h:34
bool operator==(const DataPoint &other) const
Definition TransformationModel.h:57