OpenMS
TransformationDescription.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: Clemens Groepl, Hendrik Weisser $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
14 #include <iosfwd>
15 #include <map>
16 
17 namespace OpenMS
18 {
36  class OPENMS_DLLAPI TransformationDescription
37  {
38  // friend class MapAlignmentAlgorithm;
39 
40 public:
41 
47  {
48  // default constructor
50 
51  // copy constructor
53 
54  // copy assignment
56 
57  std::vector<Size> percents = {100, 99, 95, 90, 75, 50, 25}; // TODO: use constexpr array
58  double xmin = 0;
59  double xmax = 0;
60  double ymin = 0;
61  double ymax = 0;
62 
63  std::map<Size, double> percentiles_before;
64  std::map<Size, double> percentiles_after;
65  };
66 
67 
72 
75 
77  explicit TransformationDescription(const DataPoints& data);
78 
81 
86 
88  void fitModel(const String& model_type, const Param& params = Param());
89 
96  double apply(double value) const;
97 
99  const String& getModelType() const;
100 
102  static void getModelTypes(StringList& result);
103 
109  void setDataPoints(const DataPoints& data);
110 
116  void setDataPoints(const std::vector<std::pair<double, double> >& data);
117 
119  const DataPoints& getDataPoints() const;
120 
122  const Param& getModelParameters() const;
123 
125  void invert();
126 
134  void getDeviations(std::vector<double>& diffs, bool do_apply = false,
135  bool do_sort = true) const;
136 
139 
141  void printSummary(std::ostream& os) const;
142 
143 protected:
150  };
151 
152 } // end of namespace OpenMS
153 
Management and storage of parameters / INI files.
Definition: Param.h:44
A more convenient string class.
Definition: String.h:34
Generic description of a coordinate transformation.
Definition: TransformationDescription.h:37
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)
void printSummary(std::ostream &os) const
Print summary statistics for the transformation.
String model_type_
Type of model.
Definition: TransformationDescription.h:147
DataPoints data_
Data points.
Definition: TransformationDescription.h:145
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 invert()
Computes an (approximate) inverse of the transformation.
TransformationModel::DataPoint DataPoint
Coordinate pair.
Definition: TransformationDescription.h:69
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:71
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:149
Base class for transformation models.
Definition: TransformationModel.h:29
std::vector< DataPoint > DataPoints
Vector of coordinate pairs.
Definition: TransformationModel.h:65
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Summary statistics before/after applying the transformation. For deviations before/after transformati...
Definition: TransformationDescription.h:47
std::map< Size, double > percentiles_after
percentiles of x/y deviations after transformation
Definition: TransformationDescription.h:64
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:63
Coordinate pair (with optional annotation)
Definition: TransformationModel.h:33