movement icon indicating copy to clipboard operation
movement copied to clipboard

Methods to measure complexity of trajectories (paths) #406 Open

Open demoncoder-crypto opened this issue 8 months ago • 10 comments

This PR implements trajectory complexity measures for analyzing animal movement paths.

New features:

  • Added trajectory_complexity.py module with the following functions:
    • compute_straightness_index: Ratio of Euclidean distance to path length
    • compute_sinuosity: Local measure of path complexity using a sliding window
    • compute_angular_velocity: Rate of change in direction
    • compute_tortuosity: Measures path winding (fractal dimension and angular variance methods)
    • compute_directional_change: Quantifies total turning within a time window
  • Added comprehensive unit tests
  • Added example script demonstrating how to use the new functions
  • Updated init.py to expose the new functions

Fixes Issue #406

This PR addresses the need for methods to measure complexity of trajectories (paths).

I have not tested it thoroughly or implemented it properly right now. I just wanted to know if this is the issue what we were trying to solve and I am on the right track to solve it.

demoncoder-crypto avatar Mar 22 '25 07:03 demoncoder-crypto

@niksirbi So should i continue with this implementation and make it compatible with everything? Does it cover the functionality?

demoncoder-crypto avatar Mar 25 '25 16:03 demoncoder-crypto

@niksirbi So should i continue with this implementation and make it compatible with everything? Does it cover the functionality?

Hi @demoncoder-crypto, thanks for taking the time to contribute to movement!

From a cursory look, you've made a great start in this PR:

  • these metrics are exactly the kind of thing we need to solve #406
  • you have nicely described what each metric does in the docstrings
  • you've included tests

We will need to review the PR in detail, and also take a look at the relevant papers, but this might take some time given our increased workload at the moment. Nevertheless, we definitely want these metrics in movement and one of us will eventually get back to you with detailed feedback.

In the meantime, see if you can deal with some of the CI failures.

niksirbi avatar Mar 25 '25 17:03 niksirbi

Thanks For replying @niksirbi, I would love to fix CI failures but because the implementation is quite up in the air as I assumed that this would how the implementation would go. If I fix CI failures on half implemented solution I would have to go back and change everything from start. regarding the code and why did i make a certain change Please ask me anytime I am very happy to answer but I am still unsure if this is the path forward because there was nothing mentioned in Pull request by the initial person so I am not sure if this what they are looking for. Thanks once again means a lot.

demoncoder-crypto avatar Mar 25 '25 18:03 demoncoder-crypto

If I fix CI failures on half implemented solution I would have to go back and change everything from start.

You are right about that. That's why the usual workflow we'd recommend is the following:

  • Open a draft PR to get initial feedback (to gauge if it's in the right direction). At the draft PR stage you don't need to worry about CI failures too much
  • After the initial feedback stage, you may polish the PR and deal with CI
  • Once all CI checks pass, then mark the PR as "Ready to review"

You've done everything right, except that I'd rather have this as "Draft PR" for now.

I actually have a proposal on how to move forward with this more efficiently:

  • Convert this PR to draft, for the aforementioned reasons
  • I encourage you to open a separate PR, in which you implement only 1 of these metrics (pick one of the simpler ones, like "straightness index") and also include unit tests for that metric specifically.
  • We will review that one, polish it together, and hopefully merge it
  • Once we've established one metric, we can use that function as a "template" to implement the other metrics too. Reviewing the rest will be easier.

In general we try to make small changes in each PR, which makes both the implementation and the reviewing easier.

Let me know if this plan sounds good to you.

niksirbi avatar Mar 25 '25 18:03 niksirbi

That Sounds amazing, not only it would clearly define what we are working on but also gives us the room for improvement to execute it perfectly. Just let me know what issue is decided as a path to move forward and I will start implementing them slowly iterate over it. Thanks

demoncoder-crypto avatar Mar 25 '25 19:03 demoncoder-crypto

Great @demoncoder-crypto, I've started creating sub-issues to #406, starting with #517 for the straightness index, which I see you already started working on in #514.

The idea is that we will gradually create more sub-issues, one for each complexity metric that we think is worth implementing.

I've also converted this PR to draft. The individual smaller PRs will take precedence, and we will just keep this one around for reference.

niksirbi avatar Mar 26 '25 11:03 niksirbi

Hii @niksirbi, I’d love to contribute to this effort particularly in discussions and raised PRs and around implementing and testing individual metrics or helping clean up CI as the work progresses. Please let me know. Thanks

vtushar06 avatar Aug 02 '25 05:08 vtushar06

I appreciate your motivation @vtushar06, but this is currently not a priority as the team is focusing on other features. When we find the time to get back to this, we'll start by finalising PR #517 before attempting to implement other such metrics.

In any case, I'd rather have PRs completed by their original author whenever possible, assuming they are available when we turn our attention to path complexity metrics. I can ping you if/when we'll need additional support on this topic.

niksirbi avatar Aug 04 '25 15:08 niksirbi

Got it, thanks @niksirbi! Happy to help whenever needed.

vtushar06 avatar Aug 04 '25 15:08 vtushar06