Pipeline for cell tracking using cellpose for segmentation and Trackmate for tracking

Hi!
I saw a cool pipeline on @romainGuiet Twitter post that combines Cellpose with Trackmate. I am working on cardiomyocyte (yes under some conditions they are quite mobile) migration. I plan to use published Stardist TrackMate pipeline (Automated cell tracking using StarDist and TrackMate), but already see problems as CMs are not always very star convex. I believe your cellpose would be more suitable for segmentation.

I am wondering maybe could someone has Cellpose-Trackmate scripts/pipelines and could share with me.

2 Likes

Hi @JuliusB ,

Thank you for your kind words!

You’ll need to :

You’ll find on Zenodo:

  1. DPC-dataset to play with #Cellpose and the code below :
// Dataset : DPC_timelapse_05h.tif
// https://zenodo.org/record/4700067/files/DPC_timelapse_05h.tif?download=1
imageName = getTitle()
//close("\\Others");
roiManager("reset");

// Use Cellpose to get cells segmentation
// it requires :
// - a working Cellpose environment (either conda or venv)
// - the Cellpose wrapper (PTBIOP update site)
run("Cellpose Advanced", "diameter=30 cellproba_threshold=0.0 flow_threshold=0.4 model=cyto nuclei_channel=-1 cyto_channel=1 dimensionmode=2D");

// Cellpose generates Label image, let convert them to ROIs
// it requires LaRoMe (PTBIOP update site)
run("Label image to ROIs", "");

// Use TrackMate to track the ROIs
// requires to add script to Fiji directory (PTBIOP update site)
run("Run TrackMate from RoiManager", "framegap=3 linkdistance=30 gapdistance=60.0 allowsplit=true splitdistance=80.0 ");

// TrackMate script, renamed ROIs accordingly to track they belong to
// use this information to fill ROIs with color 
// requires LaRoMe (PTBIOP update site)
selectWindow(imageName);
//run("Remove Overlay");
run("ROIs to Measurement Image", "column_name=Pattern pattern=Track-(\\d*):.*");
resetMinAndMax();
run("glasbey inverted");

you should get something like this :

DPC_timelapse_5h_AND_patternTracks

  1. H2B-dataset to play with #StarDist and the code below :
// Dataset : H2BmCherry_timelapse_05h.tif
//dataset : https://zenodo.org/record/4700067/files/H2BmCherry_timelapse_05h.tif?download=1
imageName = getTitle()
close("\\Others");
roiManager("reset");

// Here we calculate the Square Root of the image
// to improve detection of dividing cells by StarDist 
run("Square Root", "stack");

// Recommended dataset : 
//Use StarDist
run("Command From Macro", "command=[de.csbdresden.stardist.StarDist2D], args=['input':'"+imageName+"'], 'modelChoice':'Versatile (fluorescent nuclei)', 'normalizeInput':'true', 'percentileBottom':'1.0', 'percentileTop':'99.8', 'probThresh':'0.3', 'nmsThresh':'0.4', 'outputType':'ROI Manager', 'nTiles':'1', 'excludeBoundary':'2', 'roiPosition':'Automatic', 'verbose':'false', 'showCsbdeepProgress':'false', 'showProbAndDist':'false'], process=[false]");

// Use TrackMate to track the ROIs
// requires to add script to Fiji directory (PTBIOP update site)
run("Run TrackMate from RoiManager", "framegap=3 linkdistance=30 gapdistance=60.0 allowsplit=true splitdistance=80.0 ");

// TrackMate script, renamed ROIs accordingly to track they belong to
// use this information to fill ROIs with color 
// requires LaRoMe (PTBIOP update site)
selectWindow(imageName);
//run("Remove Overlay");
run("ROIs to Measurement Image", "column_name=Pattern pattern=Track-(\\d*):.*");
resetMinAndMax();
run("glasbey inverted");

you should get something like that:
H2B_timelapse_5h_AND_patternTracks

I hope it could be useful!

Cheers,

Romain

4 Likes

Thank you so much @romainGuiet! I am now eager to divide this task between my students and get data what is better to segment CMs: cellpose or stardist.

1 Like