19 bool _is_valid_sgsr =
false;
23 std::vector<double> _probability_ch1;
26 std::vector<double> _amplitudes;
48 std::vector<double>
pF;
76 double background_ch1=0.0,
77 double background_ch2=0.0,
78 std::vector<double>
pF = std::vector<double>()
100 void append(
double amplitude,
double probability_ch1) {
101 _is_valid_sgsr =
false;
102 _amplitudes.push_back(amplitude);
103 _probability_ch1.push_back(probability_ch1);
110 _is_valid_sgsr =
false;
112 _probability_ch1.clear();
122 *n_output = _amplitudes.size();
123 *output_view = _amplitudes.data();
134 _is_valid_sgsr =
false;
135 for(
int i = 0; i < n_input; i++)
136 _amplitudes.emplace_back(input[i]);
149 _histogram_function = cb;
164 auto* t = (
double *) malloc(
_S1S2.size() *
sizeof(double));
165 for(
unsigned int i = 0; i <
_S1S2.size(); i++)
183 _is_valid_sgsr =
false;
185 _probability_ch1.clear();
186 int n_components = n_input / 2;
187 for(
int i=0; i < n_components; i++){
188 double amplitude = input[2 * i];
189 double probability_green = input[(2 * i) + 1];
190 _amplitudes.emplace_back(amplitude);
191 _probability_ch1.emplace_back(probability_green);
202 *n_output = _probability_ch1.size();
203 *output_view = _probability_ch1.data();
214 _probability_ch1.clear();
215 _is_valid_sgsr =
false;
216 for(
int i = 0; i < n_input; i++)
217 _probability_ch1.emplace_back(input[i]);
232 int n = (int)_amplitudes.size() * 2;
233 auto temp = (
double*) malloc(
sizeof(
double) * n);
234 for(
unsigned int i=0; i < _amplitudes.size(); i++){
235 temp[2 * i] = _amplitudes[i];
236 temp[2 * i + 1] = _probability_ch1[i];
248 void setPF(
double *input,
int n_input){
249#ifdef VERBOSE_TTTRLIB
250 std::clog <<
"-- Setting pF " << std::endl;
252 _is_valid_sgsr =
false;
253 pF.assign(input, input + n_input);
262 void getPF(
double** output_view,
int* n_output){
263 *n_output =
pF.size();
264 *output_view =
pF.data();
296 double **histogram_x,
int *n_histogram_x,
297 double **histogram_y,
int *n_histogram_y,
298 double x_max=1000.0,
double x_min=0.01,
int n_bins=81,
300 std::vector<double> s1s2 = std::vector<double>(),
302 bool skip_zero_photon=
true,
303 std::vector<double> amplitudes = std::vector<double>(),
304 std::vector<double> probabilities_ch1 = std::vector<double>()
335 double** s1s2,
int* dim1,
int* dim2,
336 double** ps,
int* dim_ps,
337 int** tttr_indices,
int* n_tttr_indices,
338 std::vector<int> channels_1,
339 std::vector<int> channels_2,
340 int maximum_number_of_photons,
341 int minimum_number_of_photons,
342 double minimum_time_window_length
359 std::vector<double> &S1S2,
360 std::vector<double> &
pF,
362 double background_ch1,
363 double background_ch2,
364 std::vector<double> &p_ch1,
365 std::vector<double> &litudes
382 std::vector<double> &S1S2,
383 const std::vector<double> &F1F2,
385 double background_ch1,
386 double background_ch2
402 std::vector<double> &return_p,
434 _is_valid_sgsr =
false;
459 this->_n_2d_min = nmin;
460 _is_valid_sgsr =
false;
482 _is_valid_sgsr =
false;
506 _is_valid_sgsr =
false;
519 return _is_valid_sgsr;
Definition PdaCallback.h:4
Photon Distribution Analysis class for computing histograms.
Definition Pda.h:14
void setPF(double *input, int n_input)
Set the probability P(F).
Definition Pda.h:248
void get_probability_spectrum_ch1(double **output, int *n_output)
Get the theoretical probability spectrum of detecting a photon in the first channel.
Definition Pda.h:231
double get_ch1_background() const
Get the background in the green channel.
Definition Pda.h:470
void set_probabilities_ch1(double *input, int n_input)
Sets the theoretical probabilities for detecting a species in the first channel.
Definition Pda.h:213
double get_ch2_background() const
Get the background in the second channel.
Definition Pda.h:493
void set_probability_spectrum_ch1(double *input, int n_input)
Definition Pda.h:182
unsigned int _n_2d_min
Minimum number of photons.
Definition Pda.h:35
double _bg_ch1
Background in the first channel (in FRET green channel)
Definition Pda.h:38
void set_min_number_of_photons(unsigned int nmin)
Set the minimum number of photons in the S1S2 matrix.
Definition Pda.h:458
unsigned int get_min_number_of_photons() const
Get the minimum number of photons in the S1S2 matrix.
Definition Pda.h:445
Pda(int hist2d_nmax=300, int hist2d_nmin=5, double background_ch1=0.0, double background_ch2=0.0, std::vector< double > pF=std::vector< double >())
Constructor for creating a new Pda object.
Definition Pda.h:73
void set_max_number_of_photons(unsigned int nmax)
Set the maximum number of photons in the S1S2 matrix.
Definition Pda.h:431
void clear_probability_ch1()
Clears the model and removes all species from the Pda object.
Definition Pda.h:109
void evaluate()
Computes the S1S2 histogram.
bool is_valid_sgsr() const
Check if the S1S2 histogram is valid.
Definition Pda.h:518
static void S1S2_pF(std::vector< double > &S1S2, std::vector< double > &pF, unsigned int Nmax, double background_ch1, double background_ch2, std::vector< double > &p_ch1, std::vector< double > &litudes)
Calculates p(G,R) for several ratios using the same P(F).
void set_ch1_background(double bg)
Set the background in the first channel.
Definition Pda.h:481
unsigned int get_max_number_of_photons() const
Get the maximum number of photons in the S1S2 matrix.
Definition Pda.h:417
void set_callback(PdaCallback *cb)
Set the callback (cb) for the computation of a 1D histogram.
Definition Pda.h:148
void set_amplitudes(double *input, int n_input)
Sets the amplitudes of the species.
Definition Pda.h:132
static void conv_pF(std::vector< double > &S1S2, const std::vector< double > &F1F2, unsigned int Nmax, double background_ch1, double background_ch2)
Convolves the fluorescence matrix F1F2 with the background to yield the signal matrix S1S2.
std::vector< double > _S1S2
Definition Pda.h:45
void get_probabilities_ch1(double **output_view, int *n_output)
Returns the amplitudes of the species.
Definition Pda.h:201
void get_1dhistogram(double **histogram_x, int *n_histogram_x, double **histogram_y, int *n_histogram_y, double x_max=1000.0, double x_min=0.01, int n_bins=81, bool log_x=true, std::vector< double > s1s2=std::vector< double >(), int n_min=-1, bool skip_zero_photon=true, std::vector< double > amplitudes=std::vector< double >(), std::vector< double > probabilities_ch1=std::vector< double >())
Computes a 1D histogram from the 2D counting array of the two channels.
std::vector< double > pF
Probability P(F) of having a certain amount of photons.
Definition Pda.h:48
static void poisson_0toN(std::vector< double > &return_p, int start_idx, double lam, int return_dim)
Writes a Poisson distribution with an average lam for 0..N into a vector starting at a specified inde...
void get_S1S2_matrix(double **output, int *n_output1, int *n_output2)
Definition Pda.h:162
void set_ch2_background(double br)
Set the background in the second channel.
Definition Pda.h:504
double _bg_ch2
Background in the second channel (in FRET red channel)
Definition Pda.h:41
void append(double amplitude, double probability_ch1)
Appends a species to the Pda object.
Definition Pda.h:100
void get_amplitudes(double **output_view, int *n_output)
Returns the amplitudes of the species.
Definition Pda.h:121
unsigned int _n_2d_max
Maximum number of photons in the SgSr histogram.
Definition Pda.h:32
void set_valid_sgsr(bool v)
Set the S1S2 histogram validity (for testing purposes).
Definition Pda.h:530
void getPF(double **output_view, int *n_output)
Get the probability P(F).
Definition Pda.h:262
static void compute_experimental_histograms(TTTR *tttr_data, double **s1s2, int *dim1, int *dim2, double **ps, int *dim_ps, int **tttr_indices, int *n_tttr_indices, std::vector< int > channels_1, std::vector< int > channels_2, int maximum_number_of_photons, int minimum_number_of_photons, double minimum_time_window_length)
Computes experimental histograms.
Time-Tagged Time-Resolved (TTTR) data class.
Definition TTTR.h:195