trackpy.locate

trackpy.locate(raw_image, diameter, minmass=None, maxsize=None, separation=None, noise_size=1, smoothing_size=None, threshold=None, invert=False, percentile=64, topn=None, preprocess=True, max_iterations=10, filter_before=None, filter_after=None, characterize=True, engine='auto')

Locate Gaussian-like blobs of some approximate size in an image.

Preprocess the image by performing a band pass and a threshold. Locate all peaks of brightness, characterize the neighborhoods of the peaks and take only those with given total brightness (“mass”). Finally, refine the positions of each peak.

Parameters:
raw_imagearray (any dimensions)

Image used for final characterization. Ideally, pixel values of this image are not rescaled, but it can also be identical to image.

imagearray (same size as raw_image)

Processed image used for centroid-finding and most particle measurements.

diameterodd integer or tuple of odd integers

This may be a single number or a tuple giving the feature’s extent in each dimension, useful when the dimensions do not have equal resolution (e.g. confocal microscopy). The tuple order is the same as the image shape, conventionally (z, y, x) or (y, x). The number(s) must be odd integers. When in doubt, round up.

minmassfloat

The minimum integrated brightness. This is a crucial parameter for eliminating spurious features. Recommended minimum values are 100 for integer images and 1 for float images. Defaults to 0 (no filtering). .. warning:: The mass value is changed since v0.3.0 .. warning:: The default behaviour of minmass has changed since v0.4.0

maxsizefloat

maximum radius-of-gyration of brightness, default None

separationfloat or tuple

Minimum separation between features. Default is diameter + 1. May be a tuple, see diameter for details.

noise_sizefloat or tuple

Width of Gaussian blurring kernel, in pixels Default is 1. May be a tuple, see diameter for details.

smoothing_sizefloat or tuple

The size of the sides of the square kernel used in boxcar (rolling average) smoothing, in pixels Default is diameter. May be a tuple, making the kernel rectangular.

thresholdfloat

Clip bandpass result below this value. Thresholding is done on the already background-subtracted image. By default, 1 for integer images and 1/255 for float images.

invertboolean

This will be deprecated. Use an appropriate PIMS pipeline to invert a Frame or FramesSequence. Set to True if features are darker than background. False by default.

percentilefloat

Features must have a peak brighter than pixels in this percentile. This helps eliminate spurious peaks.

topninteger

Return only the N brightest features above minmass. If None (default), return all features above minmass.

preprocessboolean

Set to False to turn off bandpass preprocessing.

max_iterationsinteger

max number of loops to refine the center of mass, default 10

filter_beforeboolean

filter_before is no longer supported as it does not improve performance.

filter_afterboolean

This parameter has been deprecated: use minmass and maxsize.

characterizeboolean

Compute “extras”: eccentricity, signal, ep. True by default.

engine{‘auto’, ‘python’, ‘numba’}
Returns:
DataFrame([x, y, mass, size, ecc, signal, raw_mass])

where “x, y” are appropriate to the dimensionality of the image, mass means total integrated brightness of the blob, size means the radius of gyration of its Gaussian-like profile, ecc is its eccentricity (0 is circular), and raw_mass is the total integrated brightness in raw_image.

See also

batch

performs location on many images in batch

minmass_v03_change

to convert minmass from v0.2.4 to v0.3.0

minmass_v04_change

to convert minmass from v0.3.x to v0.4.x

Notes

Locate works with a coordinate system that has its origin at the center of pixel (0, 0). In almost all cases this will be the top-left pixel: the y-axis is pointing downwards.

This is an implementation of the Crocker-Grier centroid-finding algorithm. [1]

References

[1]

Crocker, J.C., Grier, D.G. http://dx.doi.org/10.1006/jcis.1996.0217