14
$\begingroup$

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:

$\endgroup$
6
  • 1
    $\begingroup$ I think you didn't use Permission -> "Public" when CloudDeploying your frames. $\endgroup$
    – Greg Hurst
    Commented Sep 3, 2019 at 19:29
  • 1
    $\begingroup$ @ChipHurst Thanks for that update, fixed! $\endgroup$
    – M.R.
    Commented Sep 3, 2019 at 20:14
  • 1
    $\begingroup$ Might be a relevant python based example: soft-matter.github.io/trackpy/v0.3.0/tutorial/walkthrough.html. We can use the python integration available in MMA to tinker with this examples. $\endgroup$ Commented Sep 3, 2019 at 23:10
  • $\begingroup$ Nothing new is in my answer to this question but it pertains to image tracking and might be useful to include as a resource. $\endgroup$ Commented Sep 4, 2019 at 1:34
  • $\begingroup$ am not able to get the object from wolframcloud. I always got Null object. Do you know why? $\endgroup$
    – Qiang Li
    Commented Sep 4, 2019 at 4:25

1 Answer 1

12
+125
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.