Skip to content, Skip to search

Changes

Scripting TrackMate

3,290 bytes added, 07:38, 24 August 2012
no edit summary
displayer.refresh()
</source>
 
 
 
 
== Exporting results to the ISBI 2012 Tracking Challenge file formats ==
 
This example is similar to the previous one, except that it does not display the results, but exports them to a specialized XML file, made for the ISBI 2012 tracking challenge. Also note that we use a specialized logger that sends log messages to the IJ log window.
 
<source lang="python">
import fiji.plugin.trackmate.Settings;
import fiji.plugin.trackmate.TrackMateModel;
import fiji.plugin.trackmate.TrackMate_;
import fiji.plugin.trackmate.Logger;
import fiji.plugin.trackmate.segmentation.DogSegmenter;
import fiji.plugin.trackmate.tracking.SimpleFastLAPTracker;
import fiji.plugin.trackmate.visualization.hyperstack.HyperStackDisplayer;
import ij.IJ;
import java.io.File;
import fiji.plugin.trackmate.action.ISBIChallengeExporter;
# Get currently selected image
# imp = WindowManager.getCurrentImage()
imp = ij.IJ.openImage('http://fiji.sc/tinevez/TrackMate/FakeTracks.tif')
# imp.show()
#------------------------
# Prepare settings object
#------------------------
settings = fiji.plugin.trackmate.Settings(imp)
# Configure segmenter
settings.segmenter = fiji.plugin.trackmate.segmentation.DogSegmenter()
settings.segmenterSettings = fiji.plugin.trackmate.segmentation.LogSegmenterSettings()
settings.segmenterSettings.expectedRadius = 2.5
# Configure tracker
settings.tracker = fiji.plugin.trackmate.tracking.SimpleFastLAPTracker()
settings.trackerSettings = fiji.plugin.trackmate.tracking.LAPTrackerSettings()
print(str(settings))
#-----------------------------
# Instantiate model and plugin
#-----------------------------
model = fiji.plugin.trackmate.TrackMateModel()
model.setSettings(settings)
 
# We use IJ log window
model.setLogger(fiji.plugin.trackmate.Logger.IJ_LOGGER);
trackmate = fiji.plugin.trackmate.TrackMate_(model)
 
#---------------------
# Execute segmentation
#---------------------
print('Segmenting with parameters:')
print(str(settings.segmenter))
print(str(settings.segmenterSettings))
trackmate.execSegmentation()
print(str(model.getSpots()))
#--------------------------
# Execute initial filtering
#--------------------------
settings.initialSpotFilterValue = 3.6
print('Initial spot filtering with quality above ' + str(settings.initialSpotFilterValue))
trackmate.execInitialSpotFiltering()
print(str(model.getSpots()))
#--------------------------
# Execute spot filtering
#--------------------------
filter1 = fiji.plugin.trackmate.FeatureFilter('QUALITY', 20, True)
print('Spot filtering with ' + str(filter1))
settings.addSpotFilter(filter1)
trackmate.execSpotFiltering()
print(str(model.getFilteredSpots()))
#-----------------
# Execute tracking
#-----------------
print('Tracking with parameters:')
print(str(settings.tracker))
print(str(settings.trackerSettings))
trackmate.execTracking()
print('Found ' + str(model.getNTracks()) + ' tracks.')
#--------------------------------------------------------------
# Use an action to export the results to a specific xml format.
#--------------------------------------------------------------
 
file = java.io.File('E:/Users/JeanYves/Desktop/results.xml')
fiji.plugin.trackmate.action.ISBIChallengeExporter.exportToFile(model, file)
</source>
 
 
 
 
 
Emailconfirmed, incoming, administrator, uploaders
1,396
edits