QTrk
Functions
Debugging

Debug API functions available to LabVIEW. More...

Functions

CDLL_EXPORT void DLL_CALLCONV qtrk_set_logfile_path (const char *path)
 
CDLL_EXPORT void DLL_CALLCONV qtrk_get_computed_config (QueuedTracker *qtrk, QTrkComputedConfig *cc, ErrorCluster *err)
 
CDLL_EXPORT void DLL_CALLCONV qtrk_set_pixel_calib_factors (QueuedTracker *qtrk, float offsetFactor, float gainFactor, ErrorCluster *e)
 Set pixel calibration factors. More...
 
CDLL_EXPORT void DLL_CALLCONV qtrk_set_pixel_calib (QueuedTracker *qtrk, LVArray3D< float > **offset, LVArray3D< float > **gain, ErrorCluster *e)
 Set pixel calibration images. More...
 
CDLL_EXPORT void DLL_CALLCONV qtrk_dump_memleaks ()
 
CDLL_EXPORT void qtrk_get_profile_report (QueuedTracker *qtrk, LStrHandle str)
 
CDLL_EXPORT void qtrk_enable_zlut_cmpprof (QueuedTracker *qtrk, bool enable, ErrorCluster *e)
 
CDLL_EXPORT void qtrk_get_zlut_cmpprof (QueuedTracker *qtrk, LVArray2D< float > **output, ErrorCluster *e)
 
CDLL_EXPORT int qtrk_get_debug_image (QueuedTracker *qtrk, int id, LVArray2D< float > **data, ErrorCluster *e)
 
CDLL_EXPORT void qtrk_compute_fisher (LVArray2D< float > **lut, QTrkSettings *cfg, vector3f *pos, LVArray2D< float > **fisherMatrix, LVArray2D< float > **inverseMatrix, vector3f *xyzVariance, int Nsamples, float maxPixelValue)
 
CDLL_EXPORT void qtrk_test_array_passing (int n, LVArray< float > **flt1D, LVArray2D< float > **flt2D, LVArray< int > **int1D, LVArray2D< int > **int2D)
 
CDLL_EXPORT void qtrk_simulate_tracking (QueuedTracker *qtrk, int nsmp, int beadIndex, vector3f *centerPos, vector3f *range, vector3f *outBias, vector3f *outScatter, float photonsPerWell, ErrorCluster *e)
 
CDLL_EXPORT void DLL_CALLCONV qtrk_generate_gaussian_spot (LVArray2D< float > **image, vector2f *pos, float sigma, float I0, float Ibg, int applyNoise)
 
CDLL_EXPORT void DLL_CALLCONV qtrk_generate_image_from_lut (LVArray2D< float > **image, LVArray2D< float > **lut, float *LUTradii, vector2f *position, float z, float M, float sigma_noise)
 

Detailed Description

Debug API functions available to LabVIEW.

Function Documentation

§ qtrk_compute_fisher()

CDLL_EXPORT void qtrk_compute_fisher ( LVArray2D< float > **  lut,
QTrkSettings cfg,
vector3f pos,
LVArray2D< float > **  fisherMatrix,
LVArray2D< float > **  inverseMatrix,
vector3f xyzVariance,
int  Nsamples,
float  maxPixelValue 
)

Definition at line 514 of file lv_queuetrk_api.cpp.

516 {
517  QTrkComputedConfig cc (*cfg);
518  ImageData lutImg( (*lut)->elem, (*lut)->dimSizes[1], (*lut)->dimSizes[0] );
519  SampleFisherMatrix fm(maxPixelValue);
520  Matrix3X3 mat = fm.ComputeAverageFisher(*pos, Nsamples, vector3f(1,1,1), vector3f(1,1,1)*0.001f, cfg->width, cfg->height, [&](ImageData&out, vector3f pos) {
521  GenerateImageFromLUT(&out, &lutImg, cc.zlut_minradius,cc.zlut_maxradius, pos);
522  });
523 
524  if (fisherMatrix) {
525  ResizeLVArray2D( fisherMatrix, 3, 3);
526  for (int i=0;i<9;i++)
527  (*fisherMatrix)->elem[i] = mat[i];
528  }
529 
530  if (inverseMatrix) {
531  Matrix3X3 inv = mat.Inverse();
532  ResizeLVArray2D( inverseMatrix, 3, 3);
533  for (int i=0;i<9;i++)
534  (*inverseMatrix)->elem[i] = inv[i];
535  }
536 
537  if (xyzVariance)
538  *xyzVariance = mat.Inverse().diag();
539 }
int width
Width of regions of interest to be handled. Typically equals height (square ROI). ...
Definition: qtrk_c_api.h:106
int height
Height of regions of interest to be handled. Typically equals width (square ROI). ...
Definition: qtrk_c_api.h:107
Matrix3X3 Inverse() const
Definition: utils.h:298
vector3f diag() const
Definition: utils.h:277
void ResizeLVArray2D(LVArray2D< T > **&d, int rows, int cols)
Definition: labview.h:98
Structure for derived settings computed from base settings in QTrkSettings.
Definition: qtrk_c_api.h:189
vector3< float > vector3f
Definition: std_incl.h:114

§ qtrk_dump_memleaks()

CDLL_EXPORT void DLL_CALLCONV qtrk_dump_memleaks ( )

Definition at line 501 of file lv_queuetrk_api.cpp.

502 {
503 #ifdef USE_MEMDBG
504  _CrtDumpMemoryLeaks();
505 #endif
506 }

§ qtrk_enable_zlut_cmpprof()

CDLL_EXPORT void qtrk_enable_zlut_cmpprof ( QueuedTracker qtrk,
bool  enable,
ErrorCluster e 
)

Definition at line 430 of file lv_queuetrk_api.cpp.

431 {
432  if (ValidateTracker(qtrk, e, "enable zlut cmpprof"))
433  qtrk->EnableRadialZLUTCompareProfile(enable);
434 }
bool ValidateTracker(QueuedTracker *tracker, ErrorCluster *e, const char *funcname)
Verify the referenced tracker is a valid QueuedTracker instance.
virtual void EnableRadialZLUTCompareProfile(bool enabled)=0
Set a flag to enable saving of error curves.

§ qtrk_generate_gaussian_spot()

CDLL_EXPORT void DLL_CALLCONV qtrk_generate_gaussian_spot ( LVArray2D< float > **  image,
vector2f pos,
float  sigma,
float  I0,
float  Ibg,
int  applyNoise 
)

Definition at line 477 of file lv_queuetrk_api.cpp.

478 {
479  ImageData img((*image)->elem, (*image)->dimSizes[1], (*image)->dimSizes[0]);
480 
481  GenerateGaussianSpotImage(&img, *pos, sigma, I0, Ibg);
482 
483  if (applyNoise)
484  ApplyPoissonNoise(img,1);
485 }
void GenerateGaussianSpotImage(ImageData *img, vector2f pos, float sigma, float I0, float Ibg)
Definition: utils.cpp:421
void ApplyPoissonNoise(ImageData &img, float poissonMax, float maxval)
Definition: utils.cpp:432

§ qtrk_generate_image_from_lut()

CDLL_EXPORT void DLL_CALLCONV qtrk_generate_image_from_lut ( LVArray2D< float > **  image,
LVArray2D< float > **  lut,
float *  LUTradii,
vector2f position,
float  z,
float  M,
float  sigma_noise 
)

Definition at line 487 of file lv_queuetrk_api.cpp.

489 {
490  ImageData img((*image)->elem, (*image)->dimSizes[1], (*image)->dimSizes[0]);
491  ImageData zlut((*lut)->elem, (*lut)->dimSizes[1], (*lut)->dimSizes[0]);
492 
493  vector3f pos (position->x, position->y, z);
494  GenerateImageFromLUT(&img, &zlut, LUTradii[0], LUTradii[1], pos);
495  //img.normalize();
496  if(sigma_noise>0)
497  ApplyGaussianNoise(img, sigma_noise);
498 }
void ApplyGaussianNoise(ImageData &img, float sigma)
Definition: utils.cpp:454
void GenerateImageFromLUT(ImageData *image, ImageData *zlut, float minradius, float maxradius, vector3f pos, bool splineInterp, int oversampleSubdiv)
Definition: utils.cpp:354

§ qtrk_get_computed_config()

CDLL_EXPORT void DLL_CALLCONV qtrk_get_computed_config ( QueuedTracker qtrk,
QTrkComputedConfig cc,
ErrorCluster err 
)

Definition at line 95 of file lv_queuetrk_api.cpp.

96 {
97  if (ValidateTracker(qtrk, err, "get computed config"))
98  *cc = qtrk->cfg;
99 }
bool ValidateTracker(QueuedTracker *tracker, ErrorCluster *e, const char *funcname)
Verify the referenced tracker is a valid QueuedTracker instance.
QTrkComputedConfig cfg
The settings used by this instance of QueuedTracker.

§ qtrk_get_debug_image()

CDLL_EXPORT int qtrk_get_debug_image ( QueuedTracker qtrk,
int  id,
LVArray2D< float > **  data,
ErrorCluster e 
)

Definition at line 75 of file lv_queuetrk_api.cpp.

76 {
77  int w,h;
78  if (ValidateTracker(qtrk, e, "qtrk_get_debug_image")) {
79  float* img;
80  if (qtrk->GetDebugImage(id, &w,&h, &img)) {
81  ResizeLVArray2D(data, h, w);
82  for (int i=0;i<w*h;i++) (*data)->elem[i]=img[i];
83  delete[] img;
84  return 1;
85  }
86  }
87  return 0;
88 }
bool ValidateTracker(QueuedTracker *tracker, ErrorCluster *e, const char *funcname)
Verify the referenced tracker is a valid QueuedTracker instance.
virtual bool GetDebugImage(int ID, int *w, int *h, float **pData)
Get the debug image for a specific thread.
void ResizeLVArray2D(LVArray2D< T > **&d, int rows, int cols)
Definition: labview.h:98

§ qtrk_get_profile_report()

CDLL_EXPORT void qtrk_get_profile_report ( QueuedTracker qtrk,
LStrHandle  str 
)

Definition at line 508 of file lv_queuetrk_api.cpp.

509 {
510  SetLVString(str, qtrk->GetProfileReport().c_str());
511 }
void SetLVString(LStrHandle str, const char *text)
virtual std::string GetProfileReport()
Get the output of performance profiling.

§ qtrk_get_zlut_cmpprof()

CDLL_EXPORT void qtrk_get_zlut_cmpprof ( QueuedTracker qtrk,
LVArray2D< float > **  output,
ErrorCluster e 
)

Definition at line 418 of file lv_queuetrk_api.cpp.

419 {
420  if (ValidateTracker(qtrk, e, "get zlut compare profiles"))
421  {
422  int cnt,planes,rsteps;
423  qtrk->GetRadialZLUTSize(cnt,planes,rsteps);
424  ResizeLVArray2D(output, cnt, planes);
425 
426  qtrk->GetRadialZLUTCompareProfile((*output)->elem);
427  }
428 }
virtual void GetRadialZLUTSize(int &count, int &planes, int &radialsteps)=0
Get the dimensions of the radial lookup table data.
bool ValidateTracker(QueuedTracker *tracker, ErrorCluster *e, const char *funcname)
Verify the referenced tracker is a valid QueuedTracker instance.
virtual void GetRadialZLUTCompareProfile(float *dst)=0
Get saved error curve.
void ResizeLVArray2D(LVArray2D< T > **&d, int rows, int cols)
Definition: labview.h:98

§ qtrk_set_logfile_path()

CDLL_EXPORT void DLL_CALLCONV qtrk_set_logfile_path ( const char *  path)

Definition at line 90 of file lv_queuetrk_api.cpp.

91 {
92  dbgsetlogfile(path);
93 }
void dbgsetlogfile(const char *path)
Definition: utils.cpp:49

§ qtrk_set_pixel_calib()

CDLL_EXPORT void DLL_CALLCONV qtrk_set_pixel_calib ( QueuedTracker qtrk,
LVArray3D< float > **  offset,
LVArray3D< float > **  gain,
ErrorCluster e 
)

Set pixel calibration images.

The offset and gain provided will be used to scale incoming images to reduce background influence.

Definition at line 185 of file lv_queuetrk_api.cpp.

186 {
187  if (ValidateTracker(qtrk, e, "set pixel calibration images")) {
188  int count, planes, radialSteps;
189  qtrk->GetRadialZLUTSize(count, planes, radialSteps);
190 
191  float *offset_data = 0, *gain_data = 0;
192 
193  if((*offset)->dimSizes[0] != 0) {
194  if (qtrk->cfg.width != (*offset)->dimSizes[2] || qtrk->cfg.height != (*offset)->dimSizes[1]) {
195  ArgumentErrorMsg(e, SPrintf("set_pixel_calib: Offset images passed with invalid dimension (%d,%d)", (*offset)->dimSizes[2], (*offset)->dimSizes[1]));
196  return;
197  }
198  if (count != (*offset)->dimSizes[0]) {
199  ArgumentErrorMsg(e, SPrintf("set_pixel_calib: Expecting offset to have %d images (same as ZLUT). %d given", count, (*offset)->dimSizes[0]));
200  return;
201  }
202  offset_data = (*offset)->elem;
203  }
204 
205  if((*gain)->dimSizes[0] != 0) {
206  if (qtrk->cfg.width != (*gain)->dimSizes[2] || qtrk->cfg.height != (*gain)->dimSizes[1]) {
207  ArgumentErrorMsg(e, SPrintf("set_pixel_calib: Gain images passed with invalid dimension (%d,%d)", (*gain)->dimSizes[2], (*gain)->dimSizes[1]));
208  return;
209  }
210  if (count != (*gain)->dimSizes[0]) {
211  ArgumentErrorMsg(e, SPrintf("set_pixel_calib: Expecting gain to have %d images (same as ZLUT). %d given", count, (*gain)->dimSizes[0]));
212  return;
213  }
214  gain_data = (*gain)->elem;
215  }
216 
217  qtrk->SetPixelCalibrationImages(offset_data, gain_data);
218  }
219 }
virtual void GetRadialZLUTSize(int &count, int &planes, int &radialsteps)=0
Get the dimensions of the radial lookup table data.
int width
Width of regions of interest to be handled. Typically equals height (square ROI). ...
Definition: qtrk_c_api.h:106
bool ValidateTracker(QueuedTracker *tracker, ErrorCluster *e, const char *funcname)
Verify the referenced tracker is a valid QueuedTracker instance.
int height
Height of regions of interest to be handled. Typically equals width (square ROI). ...
Definition: qtrk_c_api.h:107
void ArgumentErrorMsg(ErrorCluster *e, const std::string &msg)
QTrkComputedConfig cfg
The settings used by this instance of QueuedTracker.
virtual void SetPixelCalibrationImages(float *offset, float *gain)=0
Set the pixel calibration images.
std::string SPrintf(const char *fmt,...)
Definition: utils.cpp:132

§ qtrk_set_pixel_calib_factors()

CDLL_EXPORT void DLL_CALLCONV qtrk_set_pixel_calib_factors ( QueuedTracker qtrk,
float  offsetFactor,
float  gainFactor,
ErrorCluster e 
)

Set pixel calibration factors.

The offset and gain factors provided will be used to scale incoming images to reduce background influence.

Use together with qtrk_set_pixel_calib. If manual factors are not given, 1.0 (no change) is used as default.

Definition at line 178 of file lv_queuetrk_api.cpp.

179 {
180  if (ValidateTracker(qtrk, e, "set pixel calib factors")) {
181  qtrk->SetPixelCalibrationFactors(offsetFactor, gainFactor);
182  }
183 }
bool ValidateTracker(QueuedTracker *tracker, ErrorCluster *e, const char *funcname)
Verify the referenced tracker is a valid QueuedTracker instance.
virtual void SetPixelCalibrationFactors(float offsetFactor, float gainFactor)=0
Set the pixel calibration factors.

§ qtrk_simulate_tracking()

CDLL_EXPORT void qtrk_simulate_tracking ( QueuedTracker qtrk,
int  nsmp,
int  beadIndex,
vector3f centerPos,
vector3f range,
vector3f outBias,
vector3f outScatter,
float  photonsPerWell,
ErrorCluster e 
)

Definition at line 584 of file lv_queuetrk_api.cpp.

585 {
586  if (ValidateTracker(qtrk, e, "qtrk_simulate_tracking")) {
587 
588  int nZLUT, nPlanes, nRadialSteps;
589  qtrk->GetRadialZLUTSize(nZLUT, nPlanes, nRadialSteps);
590 
591  float* lut = new float[nZLUT*nPlanes*nRadialSteps];
592  qtrk->GetRadialZLUT(lut);
593 
594  ImageData img = ImageData::alloc(qtrk->cfg.width,qtrk->cfg.height);
595  ImageData zlut;
596  zlut.data = & lut [nRadialSteps*nPlanes*beadIndex];
597  zlut.w = nRadialSteps;
598  zlut.h = nPlanes;
599 
600  // Generate images
601  std::vector<vector3f> positions(nsmp);
602  for (int i=0;i<nsmp;i++) {
603  vector3f pos = *centerPos + *range * vector3f(rand_uniform<float>(), rand_uniform<float>(), rand_uniform<float>());
604  positions[i]=pos;
605  GenerateImageFromLUT( &img, &zlut, qtrk->cfg.zlut_minradius, qtrk->cfg.zlut_maxradius, pos);
606  ApplyPoissonNoise(img, photonsPerWell);
607  qtrk->ScheduleLocalization((uchar*)img.data, sizeof(float)*img.w, QTrkFloat,i,i,0,beadIndex);
608  }
609 
610  img.free();
611 
612  qtrk->Flush();
613  while (!qtrk->IsIdle());
614 
615  LocalizationResult* results=new LocalizationResult[nsmp];
616  qtrk->FetchResults(results, nsmp);
617  vector3f sumBias, sumScatter;
618  for (int i=0;i<nsmp;i++) {
619  vector3f truepos = positions [ results[i].job.frame ];
620  vector3f diff = results[i].pos - truepos;
621  sumBias += diff;
622  }
623  vector3f meanBias = sumBias / nsmp;
624  for (int i=0;i<nsmp;i++) {
625  vector3f truepos = positions [ results[i].job.frame ];
626  vector3f diff = results[i].pos - truepos;
627  diff -= meanBias;
628  sumScatter += diff*diff;
629  }
630  *outScatter = sqrt (sumScatter / nsmp);
631  *outBias = sumBias;
632  }
633 }
float zlut_minradius
Distance in pixels from the bead center from which to start sampling profiles. Default 1...
Definition: qtrk_c_api.h:135
virtual void GetRadialZLUTSize(int &count, int &planes, int &radialsteps)=0
Get the dimensions of the radial lookup table data.
64 bit float
Definition: qtrk_c_api.h:37
int width
Width of regions of interest to be handled. Typically equals height (square ROI). ...
Definition: qtrk_c_api.h:106
virtual void Flush()=0
Stop waiting for more jobs to do, and just process the current batch.
bool ValidateTracker(QueuedTracker *tracker, ErrorCluster *e, const char *funcname)
Verify the referenced tracker is a valid QueuedTracker instance.
void GenerateImageFromLUT(ImageData *image, ImageData *zlut, float minradius, float maxradius, vector3f pos, bool splineInterp, int oversampleSubdiv)
Definition: utils.cpp:354
virtual void GetRadialZLUT(float *dst)=0
Get the radial lookup tables used for z tracking.
Structure for job results.
Definition: qtrk_c_api.h:67
int height
Height of regions of interest to be handled. Typically equals width (square ROI). ...
Definition: qtrk_c_api.h:107
vector3< T > sqrt(const vector3< T > &a)
Definition: std_incl.h:112
uint frame
Frame number this ROI belongs to.
Definition: qtrk_c_api.h:56
static TImageData alloc(int w, int h)
Definition: utils.h:110
virtual bool IsIdle()=0
Test to see if the tracker is idle.
virtual void ScheduleLocalization(void *data, int pitch, QTRK_PixelDataType pdt, const LocalizationJob *jobInfo)=0
Add a job to the queue to be processed. A job entails running the required algorithms on a single reg...
LocalizationJob job
Job metadata. See LocalizationJob.
Definition: qtrk_c_api.h:68
QTrkComputedConfig cfg
The settings used by this instance of QueuedTracker.
void free()
Definition: utils.h:111
int h
Definition: utils.h:81
vector3< float > vector3f
Definition: std_incl.h:114
virtual int FetchResults(LocalizationResult *results, int maxResults)=0
Fetch available results.
float zlut_maxradius
Max radius in pixels of the sampling circle.
Definition: qtrk_c_api.h:200
unsigned char uchar
Definition: std_incl.h:130
int w
Definition: utils.h:81
T * data
Definition: utils.h:80
void ApplyPoissonNoise(ImageData &img, float poissonMax, float maxval)
Definition: utils.cpp:432

§ qtrk_test_array_passing()

CDLL_EXPORT void qtrk_test_array_passing ( int  n,
LVArray< float > **  flt1D,
LVArray2D< float > **  flt2D,
LVArray< int > **  int1D,
LVArray2D< int > **  int2D 
)

Definition at line 559 of file lv_queuetrk_api.cpp.

560 {
561  for (int i=0;i<(*int2D)->dimSizes[0];i++)
562  {
563  for (int j=0;j<(*int2D)->dimSizes[1];j++)
564  {
565  dbgprintf("%d\t", (*int2D)->get(i, j));
566  }
567  dbgprintf("\n");
568  }
569 
570  ResizeLVArray(flt1D, n);
571  ResizeLVArray(int1D, n);
572  ResizeLVArray2D(flt2D, n/2,n);
573  ResizeLVArray2D(int2D, n/2,n);
574  for (int i=0;i<n;i++) {
575  (*int1D)->elem[i]=(i+1)*i;
576  (*flt1D)->elem[i]=sqrtf(i);
577  for (int j=0;j<n/2;j++) {
578  (*int2D)->get(j, i) = j*2+i;
579  (*flt2D)->get(j, i) = j*2+i;
580  }
581  }
582 }
void ResizeLVArray(LVArrayND< T, N > **&d, int *dims)
Definition: labview.h:118
void ResizeLVArray2D(LVArray2D< T > **&d, int rows, int cols)
Definition: labview.h:98
void dbgprintf(const char *fmt,...)
Definition: utils.cpp:149