14

I have a video (tiff file) of cells under a microscope and I'd like to segment and track the location and sizes of them across time:

enter image description here

It has a hundred frames:

enter image description here

I've uploaded it here (now it is public):

frames = CloudGet @ "https://www.wolframcloud.com/obj/3b3ecc16-c9e8-4b2d-a824-35e8ea1307a7"

There are many great answers on how to segment cells and objects, but not to track them (probably because mma doesn't fully support videos yet).

There are three steps and I've stuck on all of them:

  1. Experiment for hyperparameters (AdaptiveBinarize, RingeFilter...)
  2. Find center-points / segmentations (MaxDetect, SelectComponents...)
  3. Track into next frame while adding/removing in-out of frame cells (ImageCorrepondingPoint, ImageFeatureTrack...)

How far I've gotten:

The first step is to find thresholding parameters for preprocessing and finding the cell loci (bright points). I always forget which is the best preprocessing combo to use...

frames = ImageAdjust /@ frames;
i1 = frames[[1]]; i2 = frames[[2]];
Manipulate[
 HighlightImage[i1, MaxDetect@ImageAdjust@RidgeFilter[i1, o]]
 , {o, .1, 10, 1}]

enter image description here

Then the segmentation

Manipulate[
 segments = 
  SelectComponents[WatershedComponents[GradientFilter[i2, gf], pts], 
   "Area", a1 < # < a2 &]; Colorize[segments]
 , {gf, 0.1, 2}, {a1, 1, 1000}, {a2, 1, 1000}]

enter image description here

But I get into cases like this:

Manipulate[
 b = Binarize[i, {0.7, 1}];
 markers = MaxDetect@ImageAdjust@RidgeFilter[i1, w];
 segments = 
  SelectComponents[
   b, (0 < #Area < 1000 && #Count > 
       c(*&& #AdjacentBorderCount\[Equal]0*)) &];
 circles = 
  ComponentMeasurements[
   segments, {"Centroid", "EquivalentDiskRadius"}];
 Show[HighlightImage[i, {Blue, markers}], 
  Graphics[{Red, Thick, Circle @@ # & /@ circles[[All, 2]]}]], {w, 1, 
  5}, {c, 0, 100}, SynchronousUpdating -> False
 ]

enter image description here

Help on canonicalizing this answer would cure many headaches :)

References:

This was the only post I've found that addressed moving cells:

M.R.
  • 31,425
  • 8
  • 90
  • 281

1 Answers1

12

You may use ImageFeatureTrack.

frames as in OP, then

tracks = Transpose@
  ImageFeatureTrack[frames, 
    MaxFeatures -> 200, 
    MaxFeatureDisplacement -> 1, 
    Tolerance -> 0.001];

There were 178 tracks found.

Dimensions@tracks
{178, 100}

However, not all tracks have values across all 100 frames.

FreeQ[Missing]@tracks
False

Starting locations are

HighlightImage[frames[[1]], {Blue, tracks[[All, 1]]}]

Mathematica graphics

Tracks are plotted by

ListLinePlot[tracks,
 AspectRatio -> 1,
 PlotRange -> All]

Mathematica graphics

Hope this helps.

Edmund
  • 42,267
  • 3
  • 51
  • 143