【TrackMate】“Found 10 spots” is displayed on Log but “[SparseLAPTracker] The spot collection is empty” is displayed on Errors

trackmate
Tags: #<Tag:0x00007fa3046ef100>

#1

I analyzed this image on TrackMate with Jython.
Found 10 spots is displayed on Log but [SparseLAPTracker] The spot collection is empty is displayed on Errors.
What should I do?
I confirmed that the particle tracking got well on TrackMate with GUI.

Image
https://share.iii.kyushu-u.ac.jp/public/eSRMQA5IX82A4XoB1Vxj-vmkA766D3Yydjngv2nexLNI

Script

from ij import IJ, ImagePlus, ImageStack
import fiji.plugin.trackmate.Settings as Settings
import fiji.plugin.trackmate.Model as Model
import fiji.plugin.trackmate.SelectionModel as SelectionModel
import fiji.plugin.trackmate.TrackMate as TrackMate
import fiji.plugin.trackmate.Logger as Logger
import fiji.plugin.trackmate.detection.DetectorKeys as DetectorKeys
import fiji.plugin.trackmate.detection.DogDetectorFactory as DogDetectorFactory
import fiji.plugin.trackmate.tracking.sparselap.SparseLAPTrackerFactory as SparseLAPTrackerFactory
import fiji.plugin.trackmate.tracking.LAPUtils as LAPUtils
import fiji.plugin.trackmate.visualization.hyperstack.HyperStackDisplayer as HyperStackDisplayer
import fiji.plugin.trackmate.features.FeatureFilter as FeatureFilter
import fiji.plugin.trackmate.features.FeatureAnalyzer as FeatureAnalyzer
import fiji.plugin.trackmate.features.spot.SpotContrastAndSNRAnalyzerFactory as SpotContrastAndSNRAnalyzerFactory
import fiji.plugin.trackmate.action.ExportStatsToIJAction as ExportStatsToIJAction
import fiji.plugin.trackmate.io.TmXmlReader as TmXmlReader
import fiji.plugin.trackmate.action.ExportTracksToXML as ExportTracksToXML
import fiji.plugin.trackmate.io.TmXmlWriter as TmXmlWriter
import fiji.plugin.trackmate.features.ModelFeatureUpdater as ModelFeatureUpdater
import fiji.plugin.trackmate.features.SpotFeatureCalculator as SpotFeatureCalculator
import fiji.plugin.trackmate.features.spot.SpotContrastAndSNRAnalyzer as SpotContrastAndSNRAnalyzer
import fiji.plugin.trackmate.features.spot.SpotIntensityAnalyzerFactory as SpotIntensityAnalyzerFactory
import fiji.plugin.trackmate.features.track.TrackSpeedStatisticsAnalyzer as TrackSpeedStatisticsAnalyzer
import fiji.plugin.trackmate.util.TMUtils as TMUtils

import sys
from ij import IJ, WindowManager

#Get currently selected image
imp = WindowManager.getCurrentImage()
#imp = IJ.openImage(‘http://fiji.sc/samples/FakeTracks.tif’)
#imp.show()

#-------------------------
#Instantiate model object
#-------------------------

model = Model()

#Set logger
model.setLogger(Logger.IJ_LOGGER)

#------------------------
#Prepare settings object
#------------------------

settings = Settings()
settings.setFrom(imp)

#Configure detector
settings.detectorFactory = DogDetectorFactory()
settings.detectorSettings = {
DetectorKeys.KEY_DO_SUBPIXEL_LOCALIZATION : True,
DetectorKeys.KEY_RADIUS : 10.0,
DetectorKeys.KEY_TARGET_CHANNEL : 1,
DetectorKeys.KEY_THRESHOLD : 0.01,
DetectorKeys.KEY_DO_MEDIAN_FILTERING : False,
}

#Configure 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’]= 2

#Add the analyzers for some spot features.
#You need to configure TrackMate with analyzers that will generate
#the data you need.
#Here we just add two analyzers for spot, one that computes generic
#pixel intensity statistics (mean, max, etc…) and one that computes
#an estimate of each spot’s SNR.
#The trick here is that the second one requires the first one to be in
#place. Be aware of this kind of gotchas, and read the docs.
settings.addSpotAnalyzerFactory(SpotIntensityAnalyzerFactory())
settings.addSpotAnalyzerFactory(SpotContrastAndSNRAnalyzerFactory())

#Add an analyzer for some track features, such as the track mean speed.
settings.addTrackAnalyzer(TrackSpeedStatisticsAnalyzer())

settings.initialSpotFilterValue = 1

print(str(settings))

#----------------------
#Instantiate trackmate
#----------------------

trackmate = TrackMate(model, settings)

#------------
#Execute all
#------------

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

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

#----------------
#Display results
#----------------

model.getLogger().log(‘Found ’ + str(model.getTrackModel().nTracks(True)) + ’ tracks.’)

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

#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(’’)
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.
x=spot.getFeature(‘POSITION_X’)
y=spot.getFeature(‘POSITION_Y’)
t=spot.getFeature(‘FRAME’)
q=spot.getFeature(‘QUALITY’)
snr=spot.getFeature(‘SNR’)
mean=spot.getFeature(‘MEAN_INTENSITY’)
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))

Log

Computation done in 2 ms.
Starting spot filtering process.
Starting tracking process.
Starting detection process using 4 threads.
Detection processes 4 frames simultaneously and allocates 1 thread per frame.
Found 10 spots.
Starting initial filtering process.
Computing spot features.
Computation done in 2 ms.
Starting spot filtering process.
Starting tracking process.

Errors

Started trackmate.py at Mon May 28 12:00:12 JST 2018
Traceback (most recent call last):
File “/Users/Hajime/Desktop/afm_temp/trackmate.py”, line 107, in
sys.exit(str(trackmate.getErrorMessage()))
SystemExit: Tracking process failed:
[SparseLAPTracker] The spot collection is empty.

at org.python.core.PySystemState.exit(PySystemState.java:1505)
at sun.reflect.GeneratedMethodAccessor59.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:188)
at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:206)
at org.python.core.PyObject.call(PyObject.java:497)
at org.python.core.PyObject.call(PyObject.java:501)
at org.python.core.PyMethod.call(PyMethod.java:141)
at org.python.pycode._pyx52.f$0(/Users/Hajime/Desktop/afm_temp/trackmate.py:125)
at org.python.pycode._pyx52.call_function(/Users/Hajime/Desktop/afm_temp/trackmate.py)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at org.python.core.builtin.eval(builtin.java:497)
at org.python.core.builtin.eval(builtin.java:501)
at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259)
at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:57)
at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
at org.scijava.thread.DefaultThreadService$3.call(DefaultThreadService.java:238)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

GUI
















How can I get the values of some objects with Trackmate?
#2

In the script you use an initialSpotFilter value of 1. Try to put it to 0.
I refer to this line in the script:

settings.initialSpotFilterValue = 1

#3

Thank you for your reply.
It worked well.
I appreciate for your help.