point_fitting

The point_fitting module contains functions used in localizing single particles. for more info see the fitting gaussians or the finding local maxima tutorials.

The point_fitting module

point_fitting.find_maxima(image, size, threshold_method='threshold_mean')

Locates maxima in an image. See here

Parameters:
  • image – 2-dimensional image array.
  • size – int, size of the maxima and minimum filters used
  • threshold_method – string, type of thresholding filter used. Accepts any threshold_filter in the skimmage.filters module. Default is threshold_mean
Returns:

1D array of [(x,y),…] defining the locations of each maximum

Example:
>>> import smtools.point_fitting as pt
>>> import smtools.testdata as test
>>> im = test.single_max()
>>> print(pt.find_maxima(im,10))
[(17, 14)]
point_fitting.fit_routine(Image, points, bbox, err=2)
Fits a 2D gaussian function to 2D image array. “x”, “y”,
and “bbox” define an ROI fit by two_d_gaussian using scipy.optimaize.curve_fit
Parameters:
  • Image – 2D array containing ROI to be fit
  • points – 1D array of (x,y) points as tuples. accepts output directly from find_maxima
  • bbox – side-length of the ROI. if even, rounds up to next odd integer
  • err – int or float. Threshold for the error on the fit of the Gaussian mean. Applied to both the mean in x and y.
Returns:

1D array of optimal (x,y) positions from gaussian fit. If ROI falls (partially or otherwise) outside Image, or, if curve_fit raises RuntimeError or ValueError, or, if the error threshold is crossed, then return value is None.

Example:
>>> import smtools.point_fitting as pt
>>> import smtools.testdata as test
>>> im = test.single_max()
>>> x,y = pt.find_maxima(im,10)[0]
>>> fit = pt.fit_routine(im, [(x, y)], 10)
>>> print(Fit)
array([ 16.74464408, 14.28216362 ])