I have position vs time data for a subject walking on a treadmill that is moving at constant speed. Most of the time the subject is walking at the same speed as the treadmill, so the position is relatively constant and the speed (in terms of the position) is around zero. Sometimes, though, the subject stops walking and thus moves backward on the treadmill. Before the subject goes off the end of the treadmill, it starts walking again. I would like to extract all the times when this transition from not walking to walking again occurs. Below is a plot of velocity (pixels/second) over time (seconds) with all the peaks I'm talking about manually labeled:
I'm thinking I want to have a sort of moving window looking for periods where the average velocity is below a low threshold for a minimum length of time before then jumping up to an average velocity above a high threshold for a minimum length of time. I would want the times that correspond to the midpoint in the transition from low to high velocity. I'm just not sure how to implement something like that. I'm also working on making the data less noisy both in the position detection (refining the DeepLabCut network) and with filtering, but my main issue is finding these transition times.
edit: attached .m file with signal (100 samples/second)