trackpy.batch

trackpy.batch(frames, diameter, output=None, meta=None, processes='auto', after_locate=None, **kwargs)

Locate Gaussian-like blobs of some approximate size in a set of images.

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:
frameslist (or iterable) of images

The frames to process.

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.

output{None, trackpy.PandasHDFStore, SomeCustomClass}

If None, return all results as one big DataFrame. Otherwise, pass results from each frame, one at a time, to the put() method of whatever class is specified here.

metafilepath or file object

If specified, information relevant to reproducing this batch is saved as a YAML file, a plain-text machine- and human-readable format. By default, this is None, and no file is saved.

processesinteger or “auto”

The number of processes to use in parallel. If <= 1, multiprocessing is disabled. If “auto”, the number returned by os.cpu_count()` is used.

after_locatefunction

Specify a custom function to apply to the detected features in each processed frame. It must accept the following arguments:

  • frame_no: an integer specifying the number of the current frame.

  • features: a DataFrame containing the detected features.

Furthermore it must return a DataFrame like features.

**kwargs

Keyword arguments that are passed to the wrapped trackpy.locate. Refer to its docstring for further details.

Returns:
DataFrame([x, y, mass, size, ecc, signal])

where mass means total integrated brightness of the blob, size means the radius of gyration of its Gaussian-like profile, and ecc is its eccentricity (0 is circular).

See also

locate

performs location on a single image

Notes

This is a convenience function that wraps trackpy.locate (see its docstring for further details) and allows batch processing of multiple frames, optionally in parallel by using multiprocessing.