Skip to contents

Main algorithm

Run CPLASS and manage the Metropolis-Hastings search.

CPLASS()
Run CPLASS on a single 2D trajectory
CPLASS_multistart()
Run CPLASS from multiple independent random starts and keep the best
MHsearch()
Metropolis-Hastings search over the changepoint space
FinalMH()
Collect a Metropolis-Hastings trace into flat vectors/lists

Convergence diagnostics

Check whether the stochastic search has stabilized.

check_convergence()
Check whether a single CPLASS chain has stopped improving
plot_convergence()
Plot a CPLASS chain's convergence trace

Piecewise-linear fitting

Continuous piecewise-linear MLE given a set of changepoints (Section 2.2 of the paper).

piecewise_linear_con()
Continuous piecewise-linear fit given a set of changepoints
build_j_inferred()
Broadcast per-segment states back onto the original observation grid

Criterion function and penalties

The penalized-likelihood criterion Phi(r) (Section 2.3).

CS()
Criterion function for a changepoint configuration
loglikelihood()
Gaussian log-likelihood from residual sum of squares
sSIC()
Strengthened Schwarz Information Criterion penalty
AICc()
Corrected AIC penalty
cp_to_r()
Convert a changepoint index vector to a 0/1 indicator vector
r_to_cp()
Convert a 0/1 changepoint indicator vector to changepoint indices

MCMC proposal mechanisms

The four changepoint-proposal types described in Section 2.4.

Cumulative Speed Allocation (CSA)

Duration-weighted speed summaries (Cook et al. 2025).

compute_csa()
Cumulative Speed Allocation (CSA)
csa_theoretical()
Theoretical CSA under a two-state (stationary/motile) kinetic model
plot_csa()
Plot Cumulative Speed Allocation curves
summarize_segments()
Stack segment summaries from a list of true (ground-truth) paths
summarize_segments_inferred()
Stack segment summaries from a list of CPLASS-inferred paths
summarize_segments_cutoff()
Stack segment summaries from inferred paths (cutoff-labeled states)
summarize_segments_test()
Stack segment summaries using a threshold-based test-state column

Visualization

plot_path_inferred()
Four-panel dashboard for a single CPLASS-segmented trajectory
plot_path_inferred_second_version()
Alternate 3-row layout for a single segmented trajectory
plot_path_inferred_xy()
Just the x-y panel of a segmented trajectory
plot_path_actual_and_inferred()
Side-by-side comparison of true vs. inferred segmentation
plot_msd()
Plot pathwise and ensemble MSD curves for a group, split by activity
get_plot_size()
Compute shared plot bounds across a list of ground-truth paths
get_plot_size_inferred()
Compute shared plot bounds across a list of inferred paths
get_one_plot_size()
Compute plot bounds for a single inferred path

Mean squared displacement

pathwise_MSD()
Pathwise mean squared displacement (MSD)
ensemble_MSD()
Ensemble (group-averaged) MSD

Utilities

fill_missing_data()
Fill gaps in an unevenly-sampled 2D trajectory
duration_of_difference()
Total duration over which true and inferred segmentations disagree on state
infer_states_speed_cutoff()
Classify inferred segments as motile/stationary by a speed cutoff
cplass cplass-package
cplass: Continuous Piecewise-Linear Approximation via Stochastic Search