TrackMate v5.2.0 released: Export tracking results to a label image

This release adds a new action that can export the tracking data to a label image.

A new 16-bit image is generated, of same dimension and size that of the input image. The label image has one channel, with black background (0 value) everywhere, except where there are spots. Each spot is painted with a uniform integer value equal to the trackID it belongs to.

Spots that do not belong to tracks are painted with a unique integer larger than the last trackID in the dataset.

An option panel is proposed to the user:

  • If Export spots as dots i selected, spots will be painted as single dots instead of ellipsoids.
  • If Export only spots in tracks is selected, only the spots belonging to visible tracks will be painted. Otherwise, spots not belonging to a track will be painted with a unique ID, different from the track IDs and different for each spot.

Screen Shot 2020-01-10 at 09 10 27

Screen Shot 2020-01-10 at 09 10 32

The action can be called from a script. For instance in Jython:

from fiji.plugin.trackmate import Model
from fiji.plugin.trackmate import Settings
from fiji.plugin.trackmate import TrackMate
from fiji.plugin.trackmate import SelectionModel
from fiji.plugin.trackmate import Logger
from fiji.plugin.trackmate.detection import LogDetectorFactory
from fiji.plugin.trackmate.tracking.sparselap import SparseLAPTrackerFactory
from fiji.plugin.trackmate.tracking import LAPUtils
from ij import IJ
import fiji.plugin.trackmate.visualization.hyperstack.HyperStackDisplayer as HyperStackDisplayer
import fiji.plugin.trackmate.features.FeatureFilter as FeatureFilter
import sys
import fiji.plugin.trackmate.features.track.TrackDurationAnalyzer as TrackDurationAnalyzer
from  fiji.plugin.trackmate.action import LabelImgExporter

imp = IJ.openImage('http://fiji.sc/samples/FakeTracks.tif')
imp.show()

model = Model()
settings = Settings()
settings.setFrom(imp)
settings.detectorFactory = LogDetectorFactory()
settings.detectorSettings = { 
    'DO_SUBPIXEL_LOCALIZATION' : True,
    'RADIUS' : 2.5,
    'TARGET_CHANNEL' : 1,
    'THRESHOLD' : 0.,
    'DO_MEDIAN_FILTERING' : False,
}
filter1 = FeatureFilter('QUALITY', 30, True)
settings.addSpotFilter(filter1)
settings.trackerFactory = SparseLAPTrackerFactory()
settings.trackerSettings = LAPUtils.getDefaultLAPSettingsMap() # almost good enough
settings.trackerSettings['ALLOW_TRACK_SPLITTING'] = True
settings.trackerSettings['ALLOW_TRACK_MERGING'] = True
settings.addTrackAnalyzer(TrackDurationAnalyzer())
filter2 = FeatureFilter('TRACK_DISPLACEMENT', 10, True)
settings.addTrackFilter(filter2)
trackmate = TrackMate(model, settings)

ok = trackmate.checkInput()
if not ok:
    sys.exit(str(trackmate.getErrorMessage()))
    
ok = trackmate.process()
if not ok:
    sys.exit(str(trackmate.getErrorMessage()))

selectionModel = SelectionModel(model)
displayer =  HyperStackDisplayer(model, selectionModel, imp)
displayer.render()
displayer.refresh()

exportSpotsAsDots = False
exportTracksOnly = False
lblImg = LabelImgExporter.createLabelImagePlus( trackmate, exportSpotsAsDots, exportTracksOnly )
lblImg.show()

This work was commissioned by Sébastien Tosi, so that TrackMate can be used and tested on the Biaflows platform.
BIAFLOWS helps comparing bio image analysis workflows by benchmarking them on annotated datasets and simplifying their reproducible deployment.
Check this: https://biaflows.neubias.org/

5 Likes