Jython macro for multi-channel TrackMate analysis

Dear All,

I’m rather new to jython macros, but since trackmate seems to be making a very good use of them I’m trying to give it a go. I’d like to address a somewhat discussed task of multi-channel intensity measurement with one of the channels dedicated to tracking and rest for measurements. I know of TrackMate-extras that implements SpotMultiChannelIntensityAnalyzer(). I was trying to use it the same way as SpotIntensityAnalyzerFactory() as outlined in https://imagej.net/Scripting_TrackMate by

settings.addSpotAnalyzerFactory(SpotMultiChannelIntensityAnalyzer())

But it seems to be not the right way. Does anyone have any usage example for SpotMultiChannelIntensityAnalyzer() ? Thanks in advance.

1 Like

Most of the Jython examples date back to the time where Jython was the most powerful language available in Fiji. Nowadays there are many alternatives (see the Scripting page), and newbies without prior knowledge of Python might have an easier time using Groovy: its syntax is much more similar to the IJ1 Macro language (and to Java, for that matter), and it offers very powerful syntactic constructs.

Here’s an example Groovy script to call TrackMate (you’ll find the TrackMate calls are essentially identical to the ones you use in Jython):


You need to add the AnalyzerFactory, not the Analyzer. Something along these lines should work:

  • in Python:
from fiji.plugin.trackmate.extra.spotanalyzer import SpotMultiChannelIntensityAnalyzerFactory
settings.addSpotAnalyzerFactory(SpotMultiChannelIntensityAnalyzerFactory())
  • in Groovy:
import fiji.plugin.trackmate.extra.spotanalyzer.SpotMultiChannelIntensityAnalyzerFactory
settings.addSpotAnalyzerFactory(new SpotMultiChannelIntensityAnalyzerFactory())
1 Like

And here is a Jython script that wraps all this together. Derived from @imagejan post:

And here is what I get from it (single channel image, actually the FakeTracks.tif image):

TrackMate completed successfully.
Found 133 spots in 5 tracks.

   Spot_ID   Track_ID      Frame          X          Y          Z         C1
      5861          0          0       64.0        4.0        0.0       41.8
      5852          0          1       64.1        6.2        0.0       41.5
      5843          0          2       64.1       10.0        0.0       41.0
      5859          0          3       63.6       12.6        0.0       50.4
      5847          0          4       62.4       16.3        0.0       52.9
      5845          0          5       59.5       19.5        0.0       51.3
      5868          0          6       59.7       19.5        0.0       52.1
      5854          0          7       57.6       21.6        0.0       48.1
      5866          0          8       57.5       22.5        0.0       51.5
      5849          0          9       61.8       25.4        0.0       51.8
      5857          0         10       62.6       29.6        0.0       49.4
      5864          0         11       62.6       33.5        0.0       53.0
      5874          0         12       62.5       36.5        0.0       48.1
      5896          0         13       62.6       38.6        0.0       50.1
      5871          0         14       62.5       40.7        0.0       52.4
      5877          0         15       64.0       46.4        0.0       62.5
      5881          0         16       63.5       51.6        0.0       50.9
      5889          0         17       63.7       55.5        0.0       52.3
      5885          0         18       61.6       57.5        0.0       54.0
      5893          0         19       59.4       62.5        0.0       48.5
      5904          0         20       59.4       67.6        0.0       51.5
      5908          0         21       59.6       72.4        0.0       52.9
      5912          0         22       59.4       76.6        0.0       54.5
      5900          0         23       59.5       78.5        0.0       54.0
      5916          0         24       59.5       79.5        0.0       50.6
      5920          0         25       59.5       79.5        0.0       51.4
      5862          1          0      116.3      116.4        0.0       46.4
      5853          1          1      116.2      116.3        0.0       47.3
      5844          1          2      116.2      116.1        0.0       47.0
      5860          1          3      116.4      116.1        0.0       47.6
      5848          1          4      116.5      115.9        0.0       46.2
      5846          1          5      116.3      116.3        0.0       47.7
      5869          1          6      116.3      116.1        0.0       45.8
      5855          1          7      116.5      116.0        0.0       46.8
      5867          1          8      116.4      116.0        0.0       48.9
      5851          1          9      116.3      116.1        0.0       47.9
      5858          1         10      116.2      115.9        0.0       47.7
      5865          1         11      116.3      115.9        0.0       47.1
      5875          1         12      116.3      116.0        0.0       46.2
      5897          1         13      116.3      116.3        0.0       48.8
      5872          1         14      116.3      116.1        0.0       46.1
      5878          1         15      116.3      116.1        0.0       48.7
      5882          1         16      116.5      116.0        0.0       46.9
      5890          1         17      116.5      116.1        0.0       49.0
      5886          1         18      116.3      115.9        0.0       46.3
      5894          1         19      116.2      116.0        0.0       45.2
      5905          1         20      116.4      115.9        0.0       44.8
      5909          1         21      116.4      116.1        0.0       47.9
      5913          1         22      116.3      116.1        0.0       46.3
      5901          1         23      116.1      116.0        0.0       49.3
      5917          1         24      116.3      115.8        0.0       47.5
      5921          1         25      116.4      116.1        0.0       50.6
      5924          1         26      116.4      116.1        0.0       47.0
      5935          1         27      116.4      116.3        0.0       47.4
      5927          1         28      116.2      116.1        0.0       49.0
      5930          1         29      116.4      116.1        0.0       43.5
      5937          1         30      116.4      116.0        0.0       48.6
      5932          1         31      116.3      116.0        0.0       46.1
      5945          1         32      116.3      115.9        0.0       47.7
      5941          1         33      116.3      116.3        0.0       49.6
      5943          1         34      116.3      116.1        0.0       46.4
      5939          1         35      116.3      116.1        0.0       47.1
      5949          1         36      116.4      116.2        0.0       50.8
      5947          1         37      116.2      115.0        0.0       37.6
      5954          1         38      116.3      116.0        0.0       47.2
      5957          1         39      116.2      116.0        0.0       48.1
      5966          1         40      116.4      116.1        0.0       45.6
      5951          1         41      116.2      116.1        0.0       48.1
      5961          1         42      116.3      116.2        0.0       48.6
      5964          1         43      116.4      116.0        0.0       45.7
      5962          1         44      116.4      116.0        0.0       46.6
      5969          1         45      116.3      115.9        0.0       47.2
      5959          1         46      116.3      116.3        0.0       48.5
      5971          1         47      116.3      116.2        0.0       49.0
      5973          1         48      116.3      116.0        0.0       47.9
      5975          1         49      116.3      116.1        0.0       47.3
      5850          2          9       52.3       25.6        0.0       51.2
      5856          2         10       49.4       28.4        0.0       49.4
      5863          2         11       48.5       29.6        0.0       53.6
      5873          2         12       45.5       32.5        0.0       50.6
      5895          2         13       42.4       34.4        0.0       52.2
      5870          2         14       39.6       37.4        0.0       51.7
      5876          2         15       36.5       41.6        0.0       50.5
      5879          2         16       32.2       44.4        0.0       51.1
      5887          2         17       27.5       46.5        0.0       47.8
      5883          2         18       23.5       49.6        0.0       50.1
      5891          2         19       17.4       47.4        0.0       46.6
      5902          2         20       12.4       44.5        0.0       49.5
      5906          2         21        9.5       40.5        0.0       51.7
      5910          2         22        9.5       36.6        0.0       51.7
      5898          2         23        9.4       32.5        0.0       49.9
      5914          2         24        9.5       27.5        0.0       49.1
      5918          2         25        9.4       22.5        0.0       51.3
      5922          2         26        9.7       17.5        0.0       53.1
      5933          2         27       13.5       14.5        0.0       52.6
      5925          2         28       18.7       12.5        0.0       46.5
      5928          2         29       22.7       10.5        0.0       51.1
      5880          3         16       41.8       47.7        0.0       49.0
      5888          3         17       41.5       51.5        0.0       51.6
      5884          3         18       41.6       54.6        0.0       48.5
      5892          3         19       41.7       56.6        0.0       51.0
      5903          3         20       41.5       59.5        0.0       53.8
      5907          3         21       41.5       63.5        0.0       51.0
      5911          3         22       41.6       67.6        0.0       52.8
      5899          3         23       41.5       71.5        0.0       48.9
      5915          3         24       41.6       75.6        0.0       52.4
      5919          3         25       44.5       79.4        0.0       49.8
      5923          3         26       50.6       82.5        0.0       84.3
      5934          3         27       51.4       86.6        0.0       52.2
      5926          3         28       51.6       91.5        0.0       52.9
      5929          3         29       51.3       93.2        0.0       43.1
      5936          3         30       51.6       97.7        0.0       50.5
      5931          3         31       51.5       98.5        0.0       52.2
      5944          3         32       51.4      100.6        0.0       45.8
      5940          3         33       51.6      102.5        0.0       52.5
      5942          3         34       51.7      103.5        0.0       50.2
      5938          3         35       51.6      104.5        0.0       51.4
      5948          3         36       51.5      107.5        0.0       49.0
      5946          3         37       51.5      108.5        0.0       50.7
      5953          3         38       51.6      111.5        0.0       49.8
      5956          3         39       51.5      114.5        0.0       52.7
      5967          3         40       51.4      117.4        0.0       50.5
      5952          3         41       51.5      120.6        0.0       53.2
      5955          4         39      108.3       18.5        0.0       50.5
      5965          4         40      108.4       23.5        0.0       46.4
      5950          4         41      108.4       27.5        0.0       53.6
      5960          4         42      108.5       31.4        0.0       50.7
      5963          4         43      108.5       35.5        0.0       53.3
      5968          4         45      108.4       39.4        0.0       54.0
      5958          4         46      108.5       43.6        0.0       49.7
      5970          4         47      108.4       47.6        0.0       51.1
      5972          4         48      108.5       51.4        0.0       51.5
      5974          4         49      108.5       55.5        0.0       53.1
3 Likes

I put this script in the TrackMate distribution and on the wiki:

5 Likes