trackpy.static.proximity

trackpy.static.proximity(features, pos_columns=None)

Find the distance to each feature’s nearest neighbor.

Parameters:
featuresDataFrame
pos_columnslist of column names

[‘x’, ‘y’] by default

Returns:
proximityDataFrame

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)]