CTL  0.6.1
Computed Tomography Library
intervaldataseries.h
1 #ifndef CTL_INTERVALDATASERIES_H
2 #define CTL_INTERVALDATASERIES_H
3 
4 #include "pointseriesbase.h"
5 #include "abstractdatamodel.h"
6 #include "processing/range.h"
7 
8 namespace CTL {
9 
66 {
67 public:
68  enum ValueType { BinIntegral,
69  MeanValue, };
70 
71  //IntervalDataSeries() = default;
72  explicit IntervalDataSeries(float binWidth, float firstBinStart = 0.0f,
73  ValueType valueType = BinIntegral);
74  IntervalDataSeries(float binWidth, float firstBinStart, const std::vector<float>& values,
75  ValueType valueType = BinIntegral);
76 
77  // factory methods
79  float from, float to, uint nbSamples,
80  ValueType samples = BinIntegral);
81  static IntervalDataSeries sampledFromModel(std::shared_ptr<AbstractIntegrableDataModel> dataModel,
82  float from, float to, uint nbSamples,
83  ValueType samples = BinIntegral);
84 
85  // data manipulation
86  void append(float value);
87  void append(const std::vector<float>& values);
88  void clampToRange(const SamplingRange& range);
89  void normalizeByIntegral();
90  using PointSeriesBase::normalizeByMaxAbsVal;
91  using PointSeriesBase::normalizeByMaxVal;
93  void setValue(uint sampleNb, float value);
94  void setValues(const std::vector<float>& values);
95 
96  // other methods
97  SamplingRange binBounds(uint binNb) const;
98  float binWidth() const;
99  float centroid() const;
100  float integral() const;
101  float integral(const std::vector<float>& weights) const;
103  SamplingRange samplingRange() const; // overloads PointSeriesBase::samplingRange()
104  ValueType valueType() const;
105 
106 private:
107  float _binWidth;
108  float _firstBinStart;
109  ValueType _valueType;
110 
111  std::vector<float> samplingPointsForIndices(uint startIdx, uint endIdx) const;
112 };
113 
114 }
115 #endif // CTL_INTERVALDATASERIES_H
void setValues(const std::vector< float > &values)
Sets the values passed by values as bin values for this series.
Definition: intervaldataseries.cpp:276
IntervalDataSeries(float binWidth, float firstBinStart=0.0f, ValueType valueType=BinIntegral)
Constructs an empty IntervalDataSeries object for a series with bin width binWidth.
Definition: intervaldataseries.cpp:30
static IntervalDataSeries sampledFromModel(const AbstractIntegrableDataModel &dataModel, float from, float to, uint nbSamples, ValueType samples=BinIntegral)
Return a series of nbSamples values sampled from dataModel within the specified interval [ from,...
Definition: intervaldataseries.cpp:110
ValueType valueType() const
Returns the type of the values in the series, i.e. whether they represent bin integrals or mean value...
Definition: intervaldataseries.cpp:373
The PointSeriesBase class is the base class used to represent a series of data tuples.
Definition: pointseriesbase.h:32
IntervalDataSeries normalizedByIntegral() const
Returns a copy of the series in which the values have been normalized such that the integral will be ...
Definition: intervaldataseries.cpp:250
The IntervalDataSeries class is a container for a series of values sampled in equidistant steps (i....
Definition: intervaldataseries.h:65
void append(float value)
Appends value to the series.
Definition: intervaldataseries.cpp:187
float centroid() const
Returns the centroid of the series.
Definition: intervaldataseries.cpp:335
void clampToRange(const SamplingRange &range)
Clamps all values in this series to the interval specified by range.
Definition: intervaldataseries.cpp:421
unsigned int uint
Qt style alias for unsigned int.
Definition: modulelayout.h:6
SamplingRange samplingRange() const
Returns the range (of x-values) covered by all bins of this series.
Definition: intervaldataseries.cpp:359
float integral() const
Returns the integral over the series.
Definition: intervaldataseries.cpp:198
std::vector< float > values() const
Definition: pointseriesbase.cpp:145
The AbstractIntegrableDataModel class is the base class for data models that provide a means to integ...
Definition: abstractdatamodel.h:110
float value(uint sampleNb) const
Definition: pointseriesbase.cpp:135
uint nbSamples() const
Definition: pointseriesbase.cpp:59
SamplingRange binBounds(uint binNb) const
Returns the boundaries of the interval covered by the bin with index binNb.
Definition: intervaldataseries.cpp:305
float binWidth() const
Returns the bin width (or x distance between two consecutive sampling points).
Definition: intervaldataseries.cpp:314
void normalizeByIntegral()
Normalizes the values in the series such that the integral will be one afterwards.
Definition: intervaldataseries.cpp:232
void scaleValues(float factor)
Definition: pointseriesbase.cpp:251
std::vector< float > samplingPointsForIndices(uint startIdx, uint endIdx) const
Computes the sampling points for bins with indices between startIdx and endIdx.
Definition: intervaldataseries.cpp:383