itasc.contact_analysis.dynamics.kinematics¶
Per-frame velocities, per-track motility summaries, and persistence times.
Pure NumPy over Trajectory lists; no I/O, no Qt. Three
public pieces:
instantaneous_table()— one row per(frame, cell_id): position, velocity, speed, and net displacement from the track’s start. Forward differences between consecutive present frames, divided by the real elapsed timeΔf · dtso gaps don’t inflate speed. A track’s last present frame has no forward step → NaN velocity/speed.track_summary_table()— one row per track: path length, net displacement, curvilinear / net speed, directionality (confinement) ratio, and the directional-autocorrelation persistence time.directional_autocorrelation()/fit_persistence_time()— the shared DAC machinery, reused for the ensemble curve inmsd-adjacent code (the dynamics store) and for each track’s own persistence time.
step directions use only real single-frame steps (Δf == 1); a step
spanning a gap is dropped from the direction statistics (its heading over the
gap is unreliable), though it still contributes to path length / speed.
Module attributes
Instantaneous per-(frame, cell) value columns (keys |
|
Ensemble directional-autocorrelation curve columns. |
|
Per-track summary value columns (key |
Functions
|
Add |
|
Turn accumulated sums/counts into |
|
Pooled DAC curve over all tracks → |
|
Fit |
|
Column-major |
|
|
|
Column-major per-track summary; tracks shorter than min_track_frames drop. |
- itasc.contact_analysis.dynamics.kinematics.INSTANTANEOUS_COLUMNS = ('x_um', 'y_um', 'vx_um_per_s', 'vy_um_per_s', 'speed_um_per_s', 'net_disp_um')¶
Instantaneous per-(frame, cell) value columns (keys
frame/cell_idare prepended by the store). Order is the on-disk order.
- itasc.contact_analysis.dynamics.kinematics.DAC_COLUMNS = ('lag_s', 'dac', 'n_samples', 'sem')¶
Ensemble directional-autocorrelation curve columns.
- itasc.contact_analysis.dynamics.kinematics.TRACK_COLUMNS = ('n_frames', 'n_gaps', 'frame_start', 'frame_end', 'duration_s', 'path_length_um', 'net_displacement_um', 'curvilinear_speed_um_per_s', 'net_speed_um_per_s', 'directionality_ratio', 'persistence_time_s')¶
Per-track summary value columns (key
cell_idprepended by the store).
- itasc.contact_analysis.dynamics.kinematics.instantaneous_table(trajectories, *, time_interval_s)[source]¶
Column-major
(frame, cell_id, …INSTANTANEOUS_COLUMNS)over all tracks.
- itasc.contact_analysis.dynamics.kinematics.track_summary_table(trajectories, *, time_interval_s, min_track_frames=3)[source]¶
Column-major per-track summary; tracks shorter than min_track_frames drop.
- itasc.contact_analysis.dynamics.kinematics.step_directions_by_frame(traj)[source]¶
start_frame -> unit step directionfor each real (Δf == 1) step.Zero-length steps (a stationary cell) have no defined direction and are skipped.
- Return type:
- Parameters:
traj (Trajectory)
- itasc.contact_analysis.dynamics.kinematics.accumulate_dac(dirs_by_frame, max_lag, sums, counts, sumsq=None)[source]¶
Add
û(f)·û(f+n)dot products into sums / counts, keyed by lag n.Reused for a single track (fresh accumulators → that track’s persistence time) and for the ensemble (shared accumulators across all tracks). Pass sumsq to also accumulate squared dot products (for the ensemble SEM).
- itasc.contact_analysis.dynamics.kinematics.ensemble_dac(trajectories, *, time_interval_s)[source]¶
Pooled DAC curve over all tracks →
(DAC_COLUMNS table, persistence_s).Each track contributes its real-step direction pairs up to its own span; the fitted ensemble persistence time uses the same recipe as the per-track one.
- itasc.contact_analysis.dynamics.kinematics.directional_autocorrelation(sums, counts)[source]¶
Turn accumulated sums/counts into
(lags, C, n_samples)arrays.lagsare integer frame lags1 … maxpresent in counts, sorted.
- itasc.contact_analysis.dynamics.kinematics.fit_persistence_time(lags_s, C)[source]¶
Fit
C = exp(-τ/P)over the leading positive run; returnP(s).Linear fit of
ln Cvsτacross the contiguousC > 0prefix (autocorrelation decays from 1, so the leading run is the signal).P = -1/slope. NaN when fewer than two positive points or a non-negative slope (no decay).