code to help deal with time-lapse series