R helper functions for MSD analysis