IMP.bff
Loading...
Searching...
No Matches
DecayCurve.h
Go to the documentation of this file.
1
8#ifndef IMPBFF_DECAYCURVE_H
9#define IMPBFF_DECAYCURVE_H
10#include <IMP/bff/bff_config.h>
11#include <cmath>
12#include <vector>
13#include <numeric>
14#include <algorithm>
15#include <iostream> /* std::cerr */
16#include <string>
17#include <cstring> /* strcmp */
18#include <limits> /* std::numeric_limits */
19#include <IMP/bff/internal/MovingAverage.h>
20#include <IMP/bff/internal/json.h>
21#include <IMP/bff/DecayRoutines.h>
22
23IMPBFF_BEGIN_NAMESPACE
24
29
38class IMPBFFEXPORT DecayCurve {
39 friend class DecayConvolution;
40 friend class DecayPileup;
41 friend class DecayLinearization;
42 friend class DecayScale;
43 friend class DecayScore;
44 friend class DecayPattern;
45
46private:
47
48 int noise_model = NOISE_NA;
49 double current_shift = 0.0;
50 double acquisition_time = std::numeric_limits<double>::max();
51 std::vector<double> dx = {1.0};
52 std::vector<double> x = std::vector<double>();
53 std::vector<double> _y;
54 std::vector<double> y = std::vector<double>();
55 std::vector<double> ey = std::vector<double>();
64 void compute_noise(int noise_model = NOISE_POISSON);
65
66public:
67
78 static std::vector<double> shift_array(
79 double *input, int n_input,
80 double shift
81 );
82
90 size_t size() const;
91
99 bool empty();
100
108 std::vector<double> get_dx();
109
120 void resize(size_t n, double v=0.0, double dx=1.0);
121
130
138 std::vector<double>& get_x();
139
140 void set_x(const std::vector<double>& v);
141
147 void set_x(double* input, int n_input);
148
153 std::vector<double>& get_y();
154
159 void set_y(std::vector<double>& v);
160
166 void set_y(double* input, int n_input);
167
172 std::vector<double>& get_ey();
173
178 void set_ey(std::vector<double>& v);
179
185 void set_ey(double* input, int n_input);
186
191 void set_acquisition_time(double v);
192
197 double get_acquisition_time() const;
198
203 void set_shift(double v);
204
209 double get_shift();
210
215 std::string get_json() const;
216
222 int read_json(std::string json_string);
223
225 std::vector<double> x = std::vector<double>(),
226 std::vector<double> y = std::vector<double>(),
227 std::vector<double> ey = std::vector<double>(),
228 double acquisition_time = std::numeric_limits<double>::max(),
229 int noise_model = NOISE_POISSON,
230 int size = -1
231 );
232
239 double sum(int start=0, int stop=-1);
240
248 void apply_simple_moving_average(int start, int stop, int n_window=5, bool normalize=false);
249
255 DecayCurve& operator+(double v) const;
256
262 DecayCurve& operator-(double v) const;
263
269 DecayCurve& operator*(double v) const;
270
276 DecayCurve& operator/(double v) const;
277
284
291
298
305
311 DecayCurve& operator+(const DecayCurve& other) const;
312
318 DecayCurve& operator-(const DecayCurve& other) const;
319
325 DecayCurve& operator*(const DecayCurve& other) const;
326
332 DecayCurve& operator/(const DecayCurve& other) const;
333
340
347
348};
349
350IMPBFF_END_NAMESPACE
351
352
353#endif //IMPBFF_DECAYCURVE_H
NoiseModelTypes
Definition DecayCurve.h:25
@ NOISE_POISSON
Definition DecayCurve.h:27
@ NOISE_NA
Definition DecayCurve.h:26
Definition DecayConvolution.h:31
Class for fluorescence decay curves.
Definition DecayCurve.h:38
DecayCurve & operator+=(double v)
Adds a value to the decay curve.
std::vector< double > & get_y()
Returns the y values of the decay curve.
double sum(int start=0, int stop=-1)
Calculates the sum of y values within a given range.
void set_shift(double v)
Sets the time shift of the decay curve.
DecayCurve(std::vector< double > x=std::vector< double >(), std::vector< double > y=std::vector< double >(), std::vector< double > ey=std::vector< double >(), double acquisition_time=std::numeric_limits< double >::max(), int noise_model=NOISE_POISSON, int size=-1)
void set_acquisition_time(double v)
Sets the acquisition time of the decay curve.
void set_y(double *input, int n_input)
Sets the y values of the decay curve.
double get_acquisition_time() const
Returns the acquisition time of the decay curve.
DecayCurve & operator/=(double v)
Divides the decay curve by a value.
DecayCurve & operator*(const DecayCurve &other) const
Overloads the '*' operator to multiply two DecayCurve objects.
DecayCurve & operator/(double v) const
Overloads the division operator to divide the decay curve by a constant value.
DecayCurve & operator=(const DecayCurve &other)
Assignment operator.
void set_y(std::vector< double > &v)
Sets the y values of the decay curve.
std::vector< double > & get_x()
Get the x-values of the curve.
DecayCurve & operator+(double v) const
Overloads the addition operator to add a constant value to the decay curve.
static std::vector< double > shift_array(double *input, int n_input, double shift)
Shift an array by a given value.
double get_average_dx()
Get the average x-value difference.
DecayCurve & operator*=(double v)
Multiplies the decay curve by a value.
void set_ey(std::vector< double > &v)
Sets the error values of the decay curve.
void set_ey(double *input, int n_input)
Sets the error values of the decay curve.
DecayCurve & operator<<(double v)
Shifts the curve by a float value.
std::vector< double > & get_ey()
Returns the error values of the decay curve.
DecayCurve & operator-(double v) const
Overloads the subtraction operator to subtract a constant value from the decay curve.
DecayCurve & operator-(const DecayCurve &other) const
Overloads the '-' operator to subtract two DecayCurve objects.
bool empty()
Check if the curve is empty.
void apply_simple_moving_average(int start, int stop, int n_window=5, bool normalize=false)
Applies a simple moving average (SMA) filter to the data.
void set_x(const std::vector< double > &v)
DecayCurve & operator/(const DecayCurve &other) const
Overloads the '/' operator to divide two DecayCurve objects.
std::string get_json() const
Returns the JSON representation of the decay curve.
double get_shift()
Returns the time shift of the decay curve.
DecayCurve & operator*(double v) const
Overloads the multiplication operator to multiply the decay curve by a constant value.
DecayCurve & operator+(const DecayCurve &other) const
Overloads the '+' operator to add two DecayCurve objects.
std::vector< double > get_dx()
Get the x-value differences.
DecayCurve & operator-=(double v)
Subtracts a value from the decay curve.
void set_x(double *input, int n_input)
Sets the x values of the decay curve.
int read_json(std::string json_string)
Reads the decay curve from a JSON string.
size_t size() const
Get the size of the curve.
void resize(size_t n, double v=0.0, double dx=1.0)
Resize the curve.
A decay modifier to apply linearization to a DecayCurve.
Definition DecayLinearization.h:38
The DecayPattern class represents a decay pattern with a constant offset and a background pattern.
Definition DecayPattern.h:26
A decorator that adds pile-up effects to a DecayCurve object.
Definition DecayPileup.h:33
A class for scaling a DecayCurve by a constant factor and subtracting a constant background value.
Definition DecayScale.h:34
Class for scoring model fluorescence decay.
Definition DecayScore.h:34