trackpy.link¶
- trackpy.link(f, search_range, pos_columns=None, t_column='frame', memory=0, predictor=None, adaptive_stop=None, adaptive_step=0.95, neighbor_strategy=None, link_strategy=None, dist_func=None, to_eucl=None)¶
Link a DataFrame of coordinates into trajectories.
- Parameters:
- fDataFrame
The DataFrame must include any number of column(s) for position and a column of frame numbers. By default, ‘x’ and ‘y’ are expected for position, and ‘frame’ is expected for frame number. See below for options to use custom column names.
- search_rangefloat or tuple
the maximum distance features can move between frames, optionally per dimension
- pos_columnslist of str, optional
Default is [‘y’, ‘x’], or [‘z’, ‘y’, ‘x’] when ‘z’ is present in f
- t_columnstr, optional
Default is ‘frame’
- memoryinteger, optional
the maximum number of frames during which a feature can vanish, then reappear nearby, and be considered the same particle. 0 by default.
- predictorfunction, optional
Improve performance by guessing where a particle will be in the next frame. For examples of how this works, see the “predict” module.
- adaptive_stopfloat, optional
If not None, when encountering an oversize subnet, retry by progressively reducing search_range until the subnet is solvable. If search_range becomes <= adaptive_stop, give up and raise a SubnetOversizeException.
- adaptive_stepfloat, optional
Reduce search_range by multiplying it by this factor.
- neighbor_strategy{‘KDTree’, ‘BTree’}
algorithm used to identify nearby features. Default ‘KDTree’.
- link_strategy{‘recursive’, ‘nonrecursive’, ‘numba’, ‘hybrid’, ‘drop’, ‘auto’}
algorithm used to resolve subnetworks of nearby particles ‘auto’ uses hybrid (numba+recursive) if available ‘drop’ causes particles in subnetworks to go unlinked
- dist_funcfunction or
`sklearn.metrics.DistanceMetric`
instance, optional A custom python distance function or instance of the Scikit Learn DistanceMetric class. If a python distance function is passed, it must take two 1D arrays of coordinates and return a float. Must be used with the ‘BTree’ neighbor_strategy.
- to_euclfunction, optional
function that transforms a N x ndim array of positions into coordinates in Euclidean space. Useful for instance to link by Euclidean distance starting from radial coordinates. If search_range is anisotropic, this parameter cannot be used.
- Returns:
- DataFrame with added column ‘particle’ containing trajectory labels.
- The t_column (by default: ‘frame’) will be coerced to integer.
See also
Notes
This is an implementation of the Crocker-Grier linking algorithm. [1]
References
[1]Crocker, J.C., Grier, D.G. http://dx.doi.org/10.1006/jcis.1996.0217