Export 2D TrackMate spots to ROI Manager via Jython scripting

Hello everyone!

I have managed to script Trackmate for my purposes (thank you @tinevez for the extensive documentation and examples!) and now would like to export the peaks or the spots detected as ImageJ ROIs.

I found the way to do this for 3D dataset here but my dataset is 2D + t. I tried to use the fact that the spots obtained via LogDetector is actually Trackmate Spots and tried to obtain the POSITION_T feature which returned NONE. When I print the features I just get RADIUS, QUALITY, POSITION_X, POSITION_Y, POSITION_Z. I then tried to loop through frames and compute spots at each time point and honestly this was not such a good idea.

Could someone point me to a correct way to export the peaks from 2D time-lapse to ImageJ Rois?

Thank you!

P.S On a side note, I also found that the Spots Features mentions POSITION_Z twice. I am not sure if it is a typo or it is intentional.

1 Like

Hello.

What does not work? The script in 3D should work for 2D as well no?

(thanks for finding the mistake in the javadoc:)

1 Like

Hi! Actually, I want the ROIs to be placed frame-wise. It is kind of added frame-wise if we consider each frame to be a slice but I find the output not convincing. Maybe I am understanding something wrong?

roi.setPosition(int(round(peak.getDoublePosition(2) / cal.pixelDepth))+1) in the script makes sure that the ROIs are placed at each slice. I checked the spots added to the ROI manager and I feel many spots are not correctly added. For example, frame 1- 5 in my data shows 5 huge spots. But in the ROI manager, I see that there are no spots added for frame 2 - 4 and directly frame 5. I have basically 5 big spots and 200 frames so ideally, I expect 200 x 5 ROIs in the ROI manager. Tracking them with Trackmate gives me such output without any problems. But the peaks detected are quite less. I changed the threshold for detection as well but it did not help as such.

I am sharing my dataset and code just in case. trackmate_test.zip (1.1 MB)

Thank you again for the support :slight_smile:

1 Like

Ok i suspect something might be off in the script. I cannot look into it before 2 weeks however. Please bear with me for some time

Best

1 Like

Sure :slight_smile: I will play around a little meanwhile, and post here if I achieve something.

2 Likes