# Is step detection the correct approach to this problem? what if not?

I'm looking for some advice on where and what to start reading for learning to solve this.

I've the time series of the position coordinates (x,y) of an animal in an open field (just a cage). I want to detect the time instants when the animal stops or starts "walking" (i.e.: moving from one place to another, not in the same place). I thought it couldnt be so difficult, but I'm finding some trouble solving it.

So, I'm looking for the times from which the signal will be flat, or the instant where the signal starts changing from flatness:

I think this thing may be related with step detection but I'm not sure. I would start with just one coordinate for simplicity. Is seems that step detection could be what im looking for, but: a. my signal "baseline" will be different every time. the animal will move and stop somewhere else, and so. b. the signal can be VERY "noisy" since the animal could and will move a lot while staying in the same place (ie: grooming) c. this changes can be whether slow or fast, and I need both.

Firstly, i ll be glad if i can solve this problem for just one coordinate, although I will have to look for this changes in the two coordinate system.

so, my questions are: 1. is step detection a good aproach to this problem? what else if not? 2. any suggestion in doing this for both (x,y) coordinates?

EDIT: I get (x,y) coordinates by acquiring an overhead image with a camera and tracking a led attached to the animal's head. Tracking is done by color filtering.

EDIT2: copy of the data:

https://www.dropbox.com/s/oph33szu891rgrl/data_sample.txt

https://www.dropbox.com/s/idulfdr965eeh7i/data_sample.mat

data format is (x,y,t)

EDIT3: I've been trying smoothing the data but it is not really what I expected. I need to clean not high frequencies but low amplitudes. The movements I look for can be either fast or slow, but with big amplitude. here, an example of signal with matlab function smooth() note that I'm looking for the green moments, which I lose when smoothing

• What sensor is used to estimate the position? May 23, 2014 at 12:39
• just edited with that information May 23, 2014 at 13:27
• Do you have a copy of the data? Filtering to get rid of spikes then looking for rapid changes in position would probably work. May 23, 2014 at 13:35
• I've just edited with link to a copy of the data. By filtering you mean smoothing as david say , right? and then look for derivative high values? May 23, 2014 at 13:59
• This answer to a related question might be helpful: dsp.stackexchange.com/questions/15661/… May 23, 2014 at 16:04

• Looking at the documentation for smooth, make sure you are defining the correct span - the number of samples you would want to average over. The default appears to use a very large span, which will eliminate the changes you want to detect. May 23, 2014 at 16:43