del delta["frame"]
delta.reset_index("particle", drop=True, inplace=True)
delta.reset_index("frame", drop=False, inplace=True)
dx = delta.groupby("frame").mean()
if smoothing > 0:
dx = pd.rolling_mean(dx, smoothing, min_periods=0)
x = dx.cumsum(0)[pos_columns]
return x
def subtract_drift(traj, drift=None, inplace=False):
After Change
f_diff = f_sort[list(pos_columns) + ["particle", "frame"]].diff()
// Rename the frame column and insert the original frame column back in.
f_diff.rename(columns={"frame": "frame_diff"}, inplace=True)
f_diff["frame"] = f_sort["frame"]
// Compute the per frame averages. Keep only deltas of the same particle,
// and between frames that are consecutive, and of the same particle.