trackpy.motion.compute_drift

trackpy.motion.compute_drift(traj, smoothing=0, pos_columns=None)

Return the ensemble drift, xy(t).

Parameters:
trajDataFrame

trajectories, including position columns, ‘frame’, and ‘particle’

smoothinginteger, optional

Smooth the drift using a forward-looking rolling mean over this many frames. Default: 0.

pos_columnslist, optional

The names of the position columns. Default [‘y’, ‘x’] or [‘z’, ‘y’, ‘x’] if ‘z’ is present in traj.

Returns:
driftDataFrame(pos_columns, index=frame)

Examples

>>> compute_drift(traj).plot()
>>> compute_drift(traj, 0, ['x', 'y']).plot() # not smoothed, equivalent to default.
>>> compute_drift(traj, 15).plot() # Try various smoothing values.
>>> drift = compute_drift(traj, 15) # Save good drift curves.
>>> corrected_traj = subtract_drift(traj, drift) # Apply them.