soft-matter / trackpy

Python particle tracking toolkit
http://soft-matter.github.io/trackpy
Other
441 stars 131 forks source link

Feature request: Prediction with Wiener filter #693

Open CakeUser321 opened 2 years ago

CakeUser321 commented 2 years ago

Hi,

firstly, I would like to thank for this magnificent package. We use it for flow measurements and it works great.

Recently, I read a paper2 about the algorithm behind 3D-ShakeTheBox 1 flow measurements. Apparently, they use a Wiener filter for predicting the next position of a particle as well as for smoothing the trajectory 2. For our application, being able to use this technique would very helpful. There is already open-source software that has implemented it (Paper: 3, Code: 4).

The code of the predictor should be here: https://github.com/JHU-NI-LAB/OpenLPT_Shake-The-Box/blob/52b4da553f713dd759fb54e4c930e05d37e15ebe/ShakeTheBox/src/srcSTB/BackSTB.cpp#L411

Do you think it would be much effort to implement this in trackpy? As far as I know, the current predictors only take into account the last one or two points of the trajectory.

nkeim commented 2 years ago

This is a great idea! The person who implements it will probably have to be you or someone else who is motivated to use it for their research. Trackpy does some of the work already; you can write a class that inherits tp.predict.NullPredict and keeps a buffer of positions in the last n frames (the way that tp.predict._RecentVelocityPredict does). Then you will need to loop over each particle to update the filter.

The next part will be making it fast, if you have a lot of particles. There's a wider community who can help with that. Speaking generally, for this part it helps tremendously to have some tests that validate that the Wiener filter prediction is working correctly, which makes it possible to for a non-expert to quickly check whether their optimized code is valid.