IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
The Integrative Modeling Platform
DecayScore.h
Go to the documentation of this file.
1 /**
2  * \file IMP/bff/DecayScore.h
3  * \brief Scoring of model fluorescence decay.
4  *
5  * \authors Thomas-Otavio Peulen
6  * Copyright 2007-2023 IMP Inventors. All rights reserved.
7  *
8  */
9 
10 #ifndef IMPBFF_DECAYSCORE_H
11 #define IMPBFF_DECAYSCORE_H
12 
13 #include <IMP/bff/bff_config.h>
14 
15 #include <string>
16 #include <iostream>
17 
18 #include <IMP/bff/internal/PhotonStatistics.h>
19 #include <IMP/bff/DecayRange.h>
20 #include <IMP/bff/DecayCurve.h>
21 
22 
23 IMPBFF_BEGIN_NAMESPACE
24 
25 /**
26  * \class DecayScore
27  * \brief Class for scoring model fluorescence decay.
28  *
29  * This class provides functionality for scoring the fluorescence decay of a model
30  * against experimental data. It calculates the score based on various scoring types,
31  * such as Poisson, Pearson, Gauss, CNP, and SSWR (Sum of Weighted Squared Residuals).
32  * The score can be calculated for a specific range of data points.
33  */
34 class IMPBFFEXPORT DecayScore : public DecayRange {
35 
36 private:
37  DecayCurve* _model = nullptr; /**< Pointer to the model decay curve */
38  DecayCurve* _data = nullptr; /**< Pointer to the experimental data decay curve */
39  DecayCurve* _default_model = nullptr; /**< Default model decay curve */
40  DecayCurve* _default_data = nullptr; /**< Default experimental data decay curve */
41  std::vector<double> _weighted_residuals; /**< Vector of weighted residuals */
42  std::string _score_type = "default"; /**< Type of score to calculate */
43 public:
44  /**
45  * Get the model decay curve.
46  * \return Pointer to the model decay curve
47  */
48  DecayCurve* get_model();
49  /**
50  * Set the model decay curve.
51  * \param v Pointer to the model decay curve
52  */
53  void set_model(DecayCurve* v);
54  /**
55  * Get the experimental data decay curve.
56  * \return Pointer to the experimental data decay curve
57  */
58  DecayCurve* get_data();
59  /**
60  * Set the experimental data decay curve.
61  * \param v Pointer to the experimental data decay curve
62  */
63  void set_data(DecayCurve* v);
64 
65 private:
66  /**
67  * Update the vector of weighted residuals.
68  */
69  void update_weighted_residuals();
70 
71 public:
72  /**
73  * Get the vector of weighted residuals.
74  * \return Reference to the vector of weighted residuals
75  */
76  std::vector<double>& get_weighted_residuals();
77  /**
78  * Calculate the score based on the specified scoring type.
79  * \param start Start index of the range of data points to consider (default: 0)
80  * \param stop Stop index of the range of data points to consider (default: -1, i.e., all points)
81  * \param score_type Type of score to calculate (default: nullptr, i.e., use the current score type)
82  * \return The calculated score
83  */
84  double get_score(int start = 0, int stop = -1, const char* score_type = nullptr);
85  /**
86  * Set the score type.
87  * \param v The score type to set
88  */
89  void set_score_type(std::string v);
90  /**
91  * Get the score type.
92  * \return The current score type
93  */
94  std::string get_score_type();
95  /**
96  * Set the model and experimental data decay curves, score type, and range of data points.
97  * \param model Pointer to the model decay curve
98  * \param data Pointer to the experimental data decay curve
99  * \param score_type Type of score to calculate (default: "poisson")
100  * \param start Start index of the range of data points to consider (default: 0)
101  * \param stop Stop index of the range of data points to consider (default: -1, i.e., all points)
102  */
103  void set(
104  DecayCurve* model, DecayCurve* data,
105  std::string score_type = "poisson",
106  int start = 0, int stop = -1
107  );
108  /**
109  * Evaluate and return the score.
110  * \param model Pointer to the model decay curve (default: nullptr, i.e., use the current model)
111  * \return The calculated score
112  */
113  double score(DecayCurve* model = nullptr);
114 
115  /**
116  * @brief Constructs a DecayScore object with the specified model, experimental data, score type, and range of data points.
117  * @param model Pointer to the model decay curve
118  * @param data Pointer to the experimental data decay curve
119  * @param score_type Type of score to calculate (default: "poisson")
120  * @param start Start index of the range of data points to consider (default: 0)
121  * @param stop Stop index of the range of data points to consider (default: -1, i.e., all points)
122  */
123  DecayScore(
124  DecayCurve* model = nullptr,
125  DecayCurve* data = nullptr,
126  std::string score_type = "poisson",
127  int start = 0,
128  int stop = -1
129  );
130 
131  /**
132  * @brief Destroys the DecayScore object and frees any allocated memory.
133  */
134  ~DecayScore() override {
135  delete _default_data;
136  delete _default_model;
137  }
138 
139 
140 };
141 
143 
144 IMPBFF_END_NAMESPACE
145 
146 
147 #endif //IMPBFF_DECAYSCORE_H
~DecayScore() override
Destroys the DecayScore object and frees any allocated memory.
Definition: DecayScore.h:134
void set(int start=0, int stop=-1)
Set the start and stop indices of the decay range.
A more IMP-like version of the std::vector.
Definition: Vector.h:50
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
Represents an inspected range of fluorescence decay.
Definition: DecayRange.h:33
Defines inspected range of fluorescence decay.
Class for scoring model fluorescence decay.
Definition: DecayScore.h:34
Class for fluorescence decay curves.
Class for fluorescence decay curves.
Definition: DecayCurve.h:38