(TrackMate) Information about intensity does not exist in spot.getFeatures()

Hi, I wrote a TrackMate(v5.0.2) script in Python to do particle tracking automatically by referring the official document.
I want to extract an information about intensities(mean, max, etc.) but those things were not included in spot.getFeatures() nor in something like spot.getFeature("MEAN_INTENSITY")

Running a example below, print(spot.getFeatures()) returns a list of following information.
{VISIBILITY: 1.0, RADIUS: 0.125, QUALITY: 169.98529052734375, POSITION_T: 887.0, POSITION_X: 25.219311690527075, POSITION_Y: 22.962385025024446, FRAME: 887.0, POSITION_Z: 0.0}
↑information about intensities are somehow not included in here.

print(spot.getFeature("MEAN_INTENSITY")) returns None.
Passing featurename included in spot.getFeatures() returns a information that I want.

Does anyone know how to fix this problem?
Thank you in advance.

# Abbreviated imports

imp = IJ.openImage(filename)

#----------------------------
# Create the model object now
#----------------------------
# Some of the parameters we configure below need to have
# a reference to the model at creation. So we create an
# empty model now.
model = Model()
    
# Send all messages to ImageJ log window.
model.setLogger(Logger.IJ_LOGGER)

#------------------------
# Prepare settings object
#------------------------
settings = Settings()
settings.setFrom(imp)

# Configure detector - We use the Strings for the keys
settings.detectorFactory = LogDetectorFactory()
# some detectorSettings here

# Configure tracker - We want to allow merges and fusions
settings.trackerFactory = SparseLAPTrackerFactory()
# some trackerSettings here

#-------------------
# Instantiate plugin
#-------------------
trackmate = TrackMate(model, settings)
#--------
# Process
#--------
ok = trackmate.checkInput()
if not ok:
    sys.exit(str(trackmate.getErrorMessage()))
ok = trackmate.process()
if not ok:
    sys.exit(str(trackmate.getErrorMessage()))
		
for id in model.getTrackModel().trackIDs(True):
    tracks = model.getTrackModel().trackSpots(id)
    for spot in tracks:
        print(spot.getFeatures()) # returns a list of spot features.
        print(spot.geFeature("MEAN_INTENSITY")) # returns None

Hi,

Try adding this before instantiating Trackmate:

settings.addSpotAnalyzerFactory(SpotIntensityAnalyzerFactory())

It’s taken from the example here: https://github.com/fiji/TrackMate/blob/7eda4995900469bbec0516f1d32cdbd9f3d84fd4/scripts/ExampleScript_3.py

This should be the same script as on the imagej wiki, but the page seems down…

2 Likes

Thank you very much for the reply!
I will report the results tomorrow :wink:

It worked! I was overlooking something very important…
I really appreciate it!!!

1 Like