Adding Spot Features and Penalties to TrackMate

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding Spot Features and Penalties to TrackMate

Greg
Hi,

right now I use TrackMate in the following setup: I use a custom jython script to segment the images, so I do the segmentation/detection completely outside of TrackMate. Then, I construct a TrackMate Model following this nice guide here:

http://fiji.sc/Scripting_TrackMate#Manually_creating_a_model

After assembling all the Spots to the Model via model.addSpotTo(...), I initiate the automated tracking via

trackmate = TrackMate(model, settings)
trackmate.execTracking()

This works wonderfully, but I think I can improve the results by incorporating more Spot features from my custom detection.
My question is, how can I add further features to Spots besides x,y,z,radius and quality ? And how do I set the penalties for them? I know from the TrackMate gui that you can add other features like intensity and then assign factors for the link-cost computation. I can not figure out how to use the API to accomplish this. For example here http://javadoc.imagej.net/Fiji/fiji/plugin/trackmate/Spot.html
nothing is said about including other features as the default ones. Or this one here
http://fiji.sc/How_to_write_your_own_spot_feature_analyzer_algorithm_for_TrackMate#The_spot_analyzer
deals from my understanding more with the Detection than the Tracking itself ?

Any help appreciated !

Regards,
Greg
Reply | Threaded
Open this post in threaded view
|

Re: Adding Spot Features and Penalties to TrackMate

Greg
Hey,

just in case someone has a similar question, I finally figured it out how to add custom features and add them with a factor to the linking cost computation. It is actually very simple, I am using jython for the following. For adding features to spots just do (assuming s is of class trackmate.Spot):

s.putFeature(FeatureString, FeatureDouble) ,i.e.
 
s.putFeature('GemInt', 4232.5)

This is actually said in the API description http://javadoc.imagej.net/Fiji/fiji/plugin/trackmate/Spot.html , but I did not expect that one can create spot features on the fly just by using this 'putFeature' method on them.

The next step is to tell the Tracker which Feature to take into account and with what penalty factor, I figured that out by inspecting (aka printing) the settings.trackerSettings dictionary. So with settings a trackmate.Settings instance one can write:

settings.trackerSettings['LINKING_FEATURE_PENALTIES'] = {'RADIUS' : 1., 'GemInt' : 20.}

So here I added two spot features to the Tracker, the default feature 'RADIUS', which should be always there, and the custom spot feature which I called GemInt. The r.h.s of the assignment is a python dictionary which maps the feature keys to the factors entering the penalty for the link cost computation, note the dots behind the numbers to make sure that they are of type double, integers are for some reason not allowed.

If one does it in that way, there are no additional sanity checks. That means one carefully has to make sure, that all feature keys added to the Tracker settings are actually set for the spots, otherwise they seem to blow off the link cost to infinity and no tracks are found !

Regards,
Greg