2
$\begingroup$

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:

signal detail what I want to detect what I want to detect

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?

thanks in advance

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

enter image description here

$\endgroup$
  • $\begingroup$ What sensor is used to estimate the position? $\endgroup$ – geometrikal May 23 '14 at 12:39
  • $\begingroup$ just edited with that information $\endgroup$ – myradio May 23 '14 at 13:27
  • $\begingroup$ Do you have a copy of the data? Filtering to get rid of spikes then looking for rapid changes in position would probably work. $\endgroup$ – geometrikal May 23 '14 at 13:35
  • $\begingroup$ 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? $\endgroup$ – myradio May 23 '14 at 13:59
  • $\begingroup$ This answer to a related question might be helpful: dsp.stackexchange.com/questions/15661/… $\endgroup$ – Matt L. May 23 '14 at 16:04
1
$\begingroup$

First off, I would start by applying a smoothing/averaging filter to your position data. This will get rid of a lot of the noise from your stationary motion.

To answer your first question, step detection is the way to go, but it depends on how you're detecting the steps. The best way in my mind would be to look at the derivative, the speed, and detect periods of non-zero speed. If you've smoothed out your position data, this should result in periods of time where the animal is moving in one direction, rather than back and forth.

This approach makes two dimensional analysis fairly simple. Once you've calculated your x and y speeds, you can combine them to get an absolute speed, independent of direction. You can use the same detection approach to find the periods of motion, which should give you the answer you're looking for.

$\endgroup$
  • $\begingroup$ I tried smoothing but i lose high frequencies which is not what i want, right? I edited my post with an image $\endgroup$ – myradio May 23 '14 at 15:15
  • $\begingroup$ 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. $\endgroup$ – David K May 23 '14 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.