trackmate-sc / TrackMate

TrackMate is your buddy for your everyday tracking.
https://imagej.net/plugins/trackmate
GNU General Public License v3.0
169 stars 76 forks source link

Implemented KalmanTrackerFF for fast flows as a separate method #296

Open Lollum89 opened 6 months ago

Lollum89 commented 6 months ago

NOTE: This new pull request is in substitution of #295. All the modifications are made in a new tracking method, KalmanTrackerFF, to avoid interfering with the existing one, as suggested by @tinevez .

In this version I made an improvement in the tracking of fast flows using the Kalman Tracker. Essentially, I added a new field in the tracker, which is called expectedMovement. It is an array, therefore representing the X;Y;Z displacement vector. In the fast flows, initiating a track is not optimal, as the spots might move a lot in a preferential direction. In the Jaquaman linking step of the tracker, the origin spots are moved by the expected movement vector, therefore moving them closer to the expected position of the target spots. This allows for a much smaller initial search radius, mitigating the issue of spurious tracks that are initiated in the wrong direction and must be terminated after 1 or 2 steps. The presence of these artifact tracks also impedes the initiation of the true tracks, therefore some visually very clear cases are ignored. After determining the relation between an origin and a target spot, the tracking can then proceed using the unmodified Kalman filter.

TrackMate capture of MASK_Result test4_trackingModLP

Lollum89 commented 6 months ago

Hello, the build error seems to be related to the SpotCollection class, and at first sight unrelated to the new code. Do you have any suggestion to aid me in the debugging?

Lollum89 commented 5 months ago

When compiling using maven in my system I do not get the error: image

whereas the same part of the code seems to fail here: image

tinevez commented 5 months ago

Weird.

Anyway I was thinking of another approach. How do you feel about making your tracker a TrackMate module? It would go in its own repo on which you would have full control, and would get a dedicated update site. A bit like TrackMate-StarDit What do you think?

Lollum89 commented 5 months ago

Thank you. I will look into that.

In the meantime, I found the warning: Redundant superinterface XYDataset for the type SpotCollectionDataset, already defined by ModelDataset

which sends me to these: image image

Lollum89 commented 5 months ago

I removed the tests for KalmanFF, which I created based on src/test/java/fiji/plugin/trackmate/tracking/Kalman/ . Maybe they were at the source of redundancy. Could you try again the build?

Lollum89 commented 5 months ago

Perfect. The tests are not needed for my contribution I think. If you agree I think this pull request is complete.

tinevez commented 5 months ago

Thanks :)

And about the idea of making it a dedicated module?

Lollum89 commented 5 months ago

It is definitely appealing. However I won't have time to dedicate to it until after July. Right now I am already using this implementation in my thesis which is due soon. I do plan to continue working on particle tracking in the future.

My future plans are to use not only a single value in all the domain, but also an expected velocity map. Also what you mentioned, augmenting it with optical flow to estimate the expected velocity.

tinevez commented 5 months ago

Yes in that case it is worthwhile to dedicate a module to it. We would try to rewrite the mother class to avoid duplicate code as well. Let's keep it this way for now, until the thesis defense. Then we will work together on migrating this PR to a proper module and new features.

Lollum89 commented 5 months ago

Perfect! Thank you for making this code open-source btw! It is allowing me to do a bunch of work.