R-script for MSD analysis