trackpy.proximity

trackpy.proximity(features, pos_columns=None)

Find the distance to each feature’s nearest neighbor.

Parameters:

features : DataFrame

pos_columns : list of column names

[‘x’, ‘y’] by default

Returns:

proximity : DataFrame

distance to each particle’s nearest neighbor, indexed by particle if ‘particle’ column is present in input

Examples

Find the proximity of each particle to its nearest neighbor in every frame.

>>> prox = t.groupby('frame').apply(proximity).reset_index()
>>> avg_prox = prox.groupby('particle')['proximity'].mean()

And filter the trajectories...

>>> particle_nos = avg_prox[avg_prox > 20].index
>>> t_filtered = t[t['particle'].isin(particle_nos)]