Because it uses a differences in speed from bin to bin to find a movement onset, it's not agnostic to the bin size. For example, with smaller bins, ds should be smaller because of the smaller timestep, but min_ds doesn't reflect this reliance on timestep.
I think the fix is simply to replace the calls to diff with calls to gradient, but I'm not sure how that would change the rest of the code right now.