OpenMS  2.7.0
TransformationDescription.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Clemens Groepl, Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
40 #include <iostream>
41 #include <map>
42 
43 namespace OpenMS
44 {
62  class OPENMS_DLLAPI TransformationDescription
63  {
64  // friend class MapAlignmentAlgorithm;
65 
66 public:
67 
73  {
74  // default constructor
76 
77  // copy constructor
79 
80  // copy assignment
82 
83  std::vector<Size> percents = {100, 99, 95, 90, 75, 50, 25}; // TODO: use constexpr array
84  double xmin = 0;
85  double xmax = 0;
86  double ymin = 0;
87  double ymax = 0;
88 
89  std::map<Size, double> percentiles_before;
90  std::map<Size, double> percentiles_after;
91  };
92 
93 
98 
101 
103  explicit TransformationDescription(const DataPoints& data);
104 
107 
112 
114  void fitModel(const String& model_type, const Param& params = Param());
115 
122  double apply(double value) const;
123 
125  const String& getModelType() const;
126 
128  static void getModelTypes(StringList& result);
129 
135  void setDataPoints(const DataPoints& data);
136 
142  void setDataPoints(const std::vector<std::pair<double, double> >& data);
143 
145  const DataPoints& getDataPoints() const;
146 
148  const Param& getModelParameters() const;
149 
151  void invert();
152 
160  void getDeviations(std::vector<double>& diffs, bool do_apply = false,
161  bool do_sort = true) const;
162 
165 
167  void printSummary(std::ostream& os = std::cout) const;
168 
169 protected:
176  };
177 
178 } // end of namespace OpenMS
179 
Management and storage of parameters / INI files.
Definition: Param.h:70
A more convenient string class.
Definition: String.h:61
Generic description of a coordinate transformation.
Definition: TransformationDescription.h:63
void setDataPoints(const DataPoints &data)
Sets the data points.
TransformationDescription()
Default constructor.
void getDeviations(std::vector< double > &diffs, bool do_apply=false, bool do_sort=true) const
Get the deviations between the data pairs.
TransformationStatistics getStatistics() const
Get summary statistics (ranges and errors before/after)
String model_type_
Type of model.
Definition: TransformationDescription.h:173
DataPoints data_
Data points.
Definition: TransformationDescription.h:171
static void getModelTypes(StringList &result)
Gets the possible types of models.
double apply(double value) const
Applies the transformation to value.
TransformationDescription & operator=(const TransformationDescription &rhs)
Assignment operator.
TransformationDescription(const DataPoints &data)
Constructor from data.
void setDataPoints(const std::vector< std::pair< double, double > > &data)
Sets the data points (backwards-compatible overload)
void fitModel(const String &model_type, const Param &params=Param())
Fits a model to the data.
void printSummary(std::ostream &os=std::cout) const
Print summary statistics for the transformation.
void invert()
Computes an (approximate) inverse of the transformation.
TransformationModel::DataPoint DataPoint
Coordinate pair.
Definition: TransformationDescription.h:95
TransformationDescription(const TransformationDescription &rhs)
Copy constructor.
const String & getModelType() const
Gets the type of the fitted model.
TransformationModel::DataPoints DataPoints
Vector of coordinate pairs.
Definition: TransformationDescription.h:97
const Param & getModelParameters() const
Non-mutable access to the model parameters.
const DataPoints & getDataPoints() const
Returns the data points.
TransformationModel * model_
Pointer to model.
Definition: TransformationDescription.h:175
Base class for transformation models.
Definition: TransformationModel.h:55
std::vector< DataPoint > DataPoints
Vector of coordinate pairs.
Definition: TransformationModel.h:91
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Summary statistics before/after applying the transformation. For deviations before/after transformati...
Definition: TransformationDescription.h:73
std::map< Size, double > percentiles_after
percentiles of x/y deviations after transformation
Definition: TransformationDescription.h:90
TransformationStatistics & operator=(const TransformationStatistics &rhs)=default
TransformationStatistics(const TransformationStatistics &rhs)=default
std::map< Size, double > percentiles_before
percentiles of x/y deviations before transformation
Definition: TransformationDescription.h:89
Coordinate pair (with optional annotation)
Definition: TransformationModel.h:59