Linear Motion LAP Tracker maximal amount of tracks

I am using ImageJ and Trackmate during a research to analyze spatters of a technical process.
As Tracker i use the Linear Motion LAP Algorithm, because the spatters have a very straight (no curves), roughly linear motion.

It works very well for the first part of my video but then i get some problems.

Like, it seems that there is a limit of trackable Tracks. In my case its 206 Tracks (without any filter) after 350 frames. And every Track afterwards can’t be tracked, even if its obvious that there should be a lot more tracks.

The Analysis is started with a jython script. I checked if i did any mistake in my script, so i changed just the part of configuring the tracker from:

settings.trackerFactory = KalmanTrackerFactory()
settings.trackerSettings = LAPUtils.getDefaultLAPSettingsMap()
settings.trackerSettings[‘KALMAN_SEARCH_RADIUS’] = 15.0
settings.trackerSettings[‘GAP_CLOSING_MAX_FRAME_GAP’] = 3
settings.trackerSettings[‘LINKING_MAX_DISTANCE’] = 15.0

to the Sparse LAP Tracker:

settings.trackerFactory = SparseLAPTrackerFactory()
settings.trackerSettings = LAPUtils.getDefaultLAPSettingsMap()
settings.trackerSettings[‘LINKING_MAX_DISTANCE’] = 15.0
settings.trackerSettings[‘GAP_CLOSING_MAX_DISTANCE’]= 15.0
settings.trackerSettings[‘MAX_FRAME_GAP’]= 3

and with that change i get more than 1000 Tracks depending on how many frames i analyze where i only got the 206 before with the Linear Motion LAP Tracker.
So in my opinion there is a issue with the Linear Motion LAP Algorithm, that you got a limit of tracks somehow.

Does anybody have a solution or any experience using the Linear Motion LAP Tracker for a high amount of tracks? Or is there another preferable Tracker Algorithm for straight, constant movements?

Thank you!

1 Like

Hi @bar_ger

Now this is a strange bug.
Could you share the data with me?

Bonjour @tinevez ! :slightly_smiling_face:

Thank you for answering. Of course i can share the data:

  • Here is a video of the spatters: Substack (1-6000).zip (17.1 MB)

  • And here is the important part of the jython code for analyzing the video in imageJ with TrackMate.

imp = WindowManager.getCurrentImage()

dims = imp.getDimensions() # default order: XYCZT : (width, height, channels, slices, frames)
if (dims[4] == 1): # Swap Z and T dimensions if T=1S
imp.setDimensions( dims[2],dims[4],dims[3] )


Instantiate model object


model = Model()

Set logger



Prepare settings object


settings = Settings()

Configure detector

settings.detectorFactory = LogDetectorFactory()
settings.detectorSettings = {
DetectorKeys.KEY_RADIUS : 6.0,
DetectorKeys.KEY_TARGET_CHANNEL : 1,
DetectorKeys.KEY_THRESHOLD : 0.25,

Add the analyzers for some spot features.


settings.initialSpotFilterValue = 0

Configure spot filters

filter1 = FeatureFilter(‘MIN_INTENSITY’, 30.0, False) #Filter for Spots in the melt pool

Configure tracker

settings.trackerFactory = KalmanTrackerFactory()
settings.trackerSettings = LAPUtils.getDefaultLAPSettingsMap()
settings.trackerSettings[‘KALMAN_SEARCH_RADIUS’] = 15.0
settings.trackerSettings[‘GAP_CLOSING_MAX_FRAME_GAP’] = 3
settings.trackerSettings[‘LINKING_MAX_DISTANCE’] = 15.0
#settings.trackerFactory = SparseLAPTrackerFactory()
#settings.trackerSettings = LAPUtils.getDefaultLAPSettingsMap()
#settings.trackerSettings[‘LINKING_MAX_DISTANCE’] = 15.0
#settings.trackerSettings[‘GAP_CLOSING_MAX_DISTANCE’]= 15.0
#settings.trackerSettings[‘MAX_FRAME_GAP’]= 3

Add an analyzer for some track features, such as the track mean speed

settings.addSpotAnalyzerFactory( SpotMultiChannelIntensityAnalyzerFactory() )

Configure track filters

#filter2 = FeatureFilter(‘TRACK_DISPLACEMENT’, 50.0, True)
#settings.initialSpotFilterValue = 1
filter2 = FeatureFilter(‘TRACK_MEAN_SPEED’, 2.5, True) #filter very slow spatters

filter3 = FeatureFilter(‘MEAN_TRACK_INTENSITY01’, 150.0, False) #filter tracks in the melt pool


Instantiate trackmate

trackmate = TrackMate(model, settings)


Execute all

ok = trackmate.checkInput()
if not ok:

ok = trackmate.process()
if not ok:


Display results


model.getLogger().log(‘Found ’ + str(model.getTrackModel().nTracks(True)) + ’ tracks.’)
selectionModel = SelectionModel(model)
displayer = HyperStackDisplayer(model, selectionModel, imp)

The feature model, that stores edge and track features.

fm = model.getFeatureModel()

for id in model.getTrackModel().trackIDs(True):

# Fetch the track feature from the feature model.
v = fm.getTrackFeature(id, 'TRACK_MEAN_SPEED')
model.getLogger().log('Track ' + str(id) + ': mean velocity = ' + str(v) + ' ' + model.getSpaceUnits() + '/' + model.getTimeUnits())
track = model.getTrackModel().trackSpots(id)
for spot in track:
    sid = spot.ID()
    # Fetch spot features directly from spot. 
    model.getLogger().log('\tspot ID = ' + str(sid) + ': x='+str(x)+', y='+str(y)+', t='+str(t)+', q='+str(q) + ', snr='+str(snr) + ', mean = ' + str(mean))

I still have the mentioned issue with the linear motion tracker. Doesn’t matter if i run the script or click through the GUI. It always stops tracking after a certain amount of frames/tracks. With the simple LAP Tracker it works fine!

I can totally reproduce the bug, thanks!

I guess it is linked somehow to the fact that there are no spots at frame 1576 where it stops.

I will investigate.

1 Like

I refined a bit the diagnosis:

It seems that this tracker is unable to initiate new tracks in a frame if there are no living tracks at said frame.
In your movie, this is what happens. At frame 1576 there no living tracks anymore, and the tracker is not able to initiate new ones, so it effectively ends tracking at this frame.
I could reproduce this weird behavior on synthetic data.
Now onward to the code!

BTW I don’t know what you are working on but if it is not cool nothing is cool.

I created an issue about it:

Look at this beauty:
@bar_ger I made a quick time movie about the results. It is really beautiful but I cannot upload it to the forum. Can I upload it to youtube and ink it here? Or do you wish not to disclose it too much?

I think I have found and fixed the bug btw.

1 Like

Great! Yes it’s fine if you link it here. I am looking forward to see your movie!


Can you tell me what it is and who / institution should be acknowledged on YouTube?

It’s a research during my Master Thesis at the University of Stuttgart and the process is in the field of welding. The aim is to gain knowledge about the spatters. Especially their amount, the behavior and their origin. :slightly_smiling_face:

Et voilà


haha in two weeks you won’t see such nice fireworks!

1 Like


I have found the source of the bug and fixed it (hopefully, I always say that and then comes ironic life lessons).
The fix is here:

It looks small, and it is indeed. But this issue was entangled with others, that were treated separately first.

There should be a new TrackMate release this Friday, probably 5.1.0 that will ship the fix.

Thanks for reporting and helping!

Thank you, too. For helping and implementing this great tool!

1 Like

Can I make a tweet with the movie?
WHO should I acknowledge?

Sure! I don’t have an twitter account, so Thomas from the University of Stuttgart is fine!