Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intersection Over Union (IoU) as feature penalty #238

Open
15bonte opened this issue Nov 18, 2022 · 5 comments
Open

Intersection Over Union (IoU) as feature penalty #238

15bonte opened this issue Nov 18, 2022 · 5 comments
Assignees
Labels
enhancement for-hire Issue that welcome a courageous developer wanted to contribute to TrackMate

Comments

@15bonte
Copy link

15bonte commented Nov 18, 2022

I was wondering if it was possible to add IoU as a feature penalty for the LAP tracker. Indeed, when working with cellpose and cells that do not really change between frames, it makes sense to consider the overlap between cells of consecutive frames.

Would it be something easy to add?

@tinevez tinevez added enhancement for-hire Issue that welcome a courageous developer wanted to contribute to TrackMate labels Nov 18, 2022
@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/overlap-tracker-in-trackmate-links-2-spots-in-the-same-frame/80680/6

@15bonte
Copy link
Author

15bonte commented Aug 8, 2023

Hi @tinevez,

As I am very interested in this feature, I may be motivated enough to try to implement it!

Yet, I would like to have your opinion on the best way to do so. Actually IoU would be quite different from other penalties since it is not a normalizeDiffTo between two spot features, but a score computed from the spot geometry.

My first idea would be to add a weight for this IoU penalty, set to 0 by default, and in computeLinkingCostFor add something like

final double iou_penalty = s0.computeIoU( s1 );
penalty += factor_iou * 1.5 * iou_penalty;

This computeIoU could be inspired by functions from the overlap tracker.

What is your opinion on this?

@tinevez
Copy link
Member

tinevez commented Aug 14, 2023

Excellent!

I think it would be wise not to make it a penalty, but a basic cost. For this I would do another tracker, separate from the ones that are based on distance. I don't think mixing distance and IoU would work well.

It should not be crazy hard to at least test the idea:
We can use the Jaqaman trackers (LAP and simple LAP) as basis. They use a CostFunction that can be derived to return the IoU instead of the distance. See:
https://github.com/trackmate-sc/TrackMate/blob/master/src/main/java/fiji/plugin/trackmate/tracking/jaqaman/costfunction/CostFunction.java

The quickest way to implement these modification is IMHO to subclass the SparseLAPFrameToFrameTracker tracker. One of the method returns the cost function. You can just substitute the new one in the child class, and it should give new a tracker based on the IoU.

https://github.com/trackmate-sc/TrackMate/blob/master/src/main/java/fiji/plugin/trackmate/tracking/jaqaman/SparseLAPFrameToFrameTracker.java#L270-L284

It's cool no? I mean, the extensibility.

@15bonte
Copy link
Author

15bonte commented Aug 21, 2023

Sounds clear!

I will try it in the days to come, and let you know if I have some issues.

Thanks a lot!

@15bonte
Copy link
Author

15bonte commented Aug 22, 2023

Hi @tinevez ,

I have created a pull request here: #277.

I tried to follow your advice, please tell me if anything should be modified. In particular the name may be improved, and there might be some code duplicated from the overlap tracker since I was not sure of the best place to store it.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement for-hire Issue that welcome a courageous developer wanted to contribute to TrackMate
Projects
Status: No status
Development

No branches or pull requests

3 participants