tttrlib
A library for time-tagged time resolved data
Loading...
Searching...
No Matches
ImageLocalization.h
Go to the documentation of this file.
1//#ifndef TTTRLIB_LOCALIZATION_H
2//#define TTTRLIB_LOCALIZATION_H
3//
4//#include <iostream>
5//#include <cmath>
6//#include <cinttypes> /* uint64, int64, etc */
7//
8//#include "i_lbfgs.h"
9//#include "LvArrays.h"
10//
11//
12//typedef struct {
13// double *data; //contains the data to be fitted
14// double *model;//initialise empty array that will contain the model
15// int xlen;
16// int ylen; // for 1D data, ylen is unused
17//} GaussDataType;
18//
19//
21//typedef struct {
22// char elliptical_circular; // circular ?
23// double background; // const BG input
24// char free_fixed; // with free or fixed BG ?
25// int maxNPeaks;
26// char fit2DGauss; // fit or just return cm's
27// char must_converge; // discard peaks for which LM has not converged
28//} OptsCluster;
29//
30//
33//typedef struct {
34// unsigned int imageID;
35// unsigned int pixelID;
36// double peak_x;
37// double peak_y;
38// double intensity;
39// double chi2;
40// int lm_message;
41// double std;
42// double sigma_x;
43// double sigma_y;
44// double background;
45// double max_x;
46// double max_y;
47// double Ncounts;
48//} ResultsCluster;
49//
52//typedef struct {
53// LVDoubleArray **subimage;
54// int osize;
55// LVDoubleArray **M;
56//} MGParam;
57//
58//
59//class localization {
60//
61//protected:
62//
63// /*!
64// *
65// check if var is within bounds
66// If out-of-bound, reset parameter to the middle of the bounds
67// * @param var
68// * @param min
69// * @param max
70// * @return
71// */
72// static inline double varinbounds(double var, double min, double max);
73//
74// /*!
75// check if var is below lower bound
76// if yes, reset to lower-bound + 1
77// * @param var
78// * @param min
79// * @return
80// */
81// static inline double varlowerbound(double var, double min);
82//
83// /*!
84// * overall -log-likelihood: Gauss2D
85// * @param data array can represent 1D or 2D data
86// * Poisson-statistics governed data. data should contain ints, but is kept double for flexibility
87// * @param model model to fit the data
88// * @param osize length of array
89// * @return
90// */
91// static inline double W2DG(double *data, double *model, int osize);
92//
93// /*!
94// * human-readable chisq_mle
95// * -2 * ln ( L ( C | M ) / L ( C | C ) )
96// *
97// * 2Istar value for human interpretation of result
98// * where L denotes the Likelihood, C the data and M the model.
99// * i.e. the found likelihood is devided by the likelihood if a 'perfect' solution is found.
100// * This function differs from twoIstar in the first to therms of the formula
101// * source: https://doi.org/10.1038/nmeth0510-338
102// * @param C Poisson-statistics governed data. data should contain ints, but is kept double for flexibility
103// * @param M model to fit the data
104// * @param osize length of array
105// * @return
106// */
107// static inline double twoIstar_G(double *C, double *M, int osize);
108//
109// /// vars = [x0 y0 A sigma ellipticity bg]
110// static int model2DGaussian(double *vars, double *model, int xlen, int ylen);
111//
112// /// function uses model2DGaussian function for constructor, see fit2DGaussian for parameter declaration
113// static int modelTwo2DGaussian(double *vars, double *model, int xlen, int ylen);
114//
115// //function uses model2DGaussian and model2DGaussian function for constructor, see fit2DGaussian for parameter declaration
116// static int modelThree2DGaussian(double *vars, double *model, int xlen, int ylen);
117//
118// /*
119// Function to minimize by bfgs object.
120// bfgs constructor needs function with arguments (double *, void*)
121// This function resets parameters within bounds, calculates model and gets goodness
122// Maybe these functionalities should be split up further?
123// */
124// static double target2DGaussian(double *vars, void *gdata);
125//
126//public:
127//
128// /*!
129// * fit2DGaussian initializes optimisation routine
130// *
131// * @param vars vars contains the parameters that are optimized and has length 18!
132// * 0: x0,
133// * 1: y0,
134// * 2: A0,
135// * 3: sigma,
136// * 4: ellipticity,
137// * 5: bg,
138// * 6: x1,
139// * 7: y1,
140// * 8: A1,
141// * 9: x2,
142// * 10: y2,
143// * 11: A2,
144// * 12: info, contains information from the fitting algorithm
145// * 13: wi_nowi, outdated
146// * 14: fit_bg, asks if background is fitted. 0 -> bg is fitted
147// * 15: ellipt_circ, determines if elliptical fits are allowed. 1-> eps is fixed.
148// * 16: model, determines the model to be used:
149// * 0: model2DGaussian
150// * 1: modelTwo2DGaussian
151// * 2: modelThree2DGaussian
152// * 17: reserved for two Istar value of optimised solutio
153// * @param data
154// * @param xlen
155// * @param ylen
156// * @return
157// */
158// static int fit2DGaussian(std::vector<double> vars, std::vector<std::vector<double>> &data);
159//
160// /*!
161// * double *image, // one frame
162// int size_x, int size_y, // image size
163// OptsCluster *options,
164// int Nimage,
165// int &Nall, // total number of peaks found
166// int &Ngood, // total number of good peaks found
167// int &Nconverged, // total number of converged peaks
168// int &Npeaks, // number of remaining peaks
169// void **presults, // see ResultsCluster definition
170// int wi_nowi, // weighted or no weights ?
171// int Npeaks_tmp, // number of found peaks
172// int *peak_x_tmp, // x coordinates of loaded peaks
173// int *peak_y_tmp, // y coordinates of loaded peaks
174// int input_estimated_bg, // with input or estimated bg value?
175// MGParam *p)
176// * @return
177// */
178// static int Gauss2D_analysis_Ani(
179// std::vector<std::vector<double>> &image, // one frame
180// OptsCluster *options,
181// int Nimage,
182// int &Nall, // total number of peaks found
183// int &Ngood, // total number of good peaks found
184// int &Nconverged, // total number of converged peaks
185// int &Npeaks, // number of remaining peaks
186// void **presults, // see ResultsCluster definition
187// int wi_nowi, // weighted or no weights ?
188// int Npeaks_tmp, // number of found peaks
189// int *peak_x_tmp, // x coordinates of loaded peaks
190// int *peak_y_tmp, // y coordinates of loaded peaks
191// int input_estimated_bg, // with input or estimated bg value?
192// MGParam *p);
193//
194//
195//};
196//
197//
198//#endif //TTTRLIB_LOCALIZATION_H