Tagging the parent cell for results from ImageJ Analyze Particles

I have image fields with a couple of cells each and am segmenting objects and generating ROIs within them. When I make measurements I get ROIs across the image and would like to know which cell they come from.

The closest thing to what I want might be to use [Count Masks] with the nuclei and use that information in some way, but I’m not sure how? I also feel that counting objects within cells is is a common enough workflow that there’s probably an easier way to do it. What is the canonical way of tagging measurements per cell?

Here is an ImageJ1 macro example of the segmentation I’m trying to do using the bundled HeLa image:

// Open example image with 4 cells.
run("HeLa Cells (1.3M, 48-bit RGB)");
// Segment nuclei.
run("Duplicate...", "title=dna duplicate channels=3");
setAutoThreshold("MaxEntropy dark");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Analyze Particles...", "size=5-Infinity circularity=0.10-1.00 show=[Count Masks] exclude clear");
rename("nuclei");
close("dna");
// Segment RNAi.
selectWindow("hela-cells.tif");
run("Duplicate...", "title=tritc duplicate channels=1");
run("Duplicate...", "title=tritc_mask duplicate channels=1");
run("Subtract Background...", "rolling=20");
setAutoThreshold("Otsu dark");
run("Convert to Mask");
run("Watershed");
run("Analyze Particles...", "size=5-100 pixel circularity=0.20-1.00 show=Masks exclude clear");
rename("rnai");
close("tritc_mask");
// Overlap masks.
imageCalculator("Multiply create", "rnai","nuclei");
rename("rnai_in_nuclei");
// Overlap with original data.
imageCalculator("AND create", "rnai_in_nuclei","tritc");
rename("rnai_segmented");
run("ROI Manager...");
roiManager("Show All");
setAutoThreshold("Otsu");
run("Analyze Particles...", " display exclude clear add");

This produces 28 ROI’s but the results table doesn’t tell me which of the 4 cells is the “parents” of each ROI.

Hi @omsai

I suggest you look at the Speckle Inspector in the BioVoxxel toolbox!

Thanks for the suggestion @lmurphy!

Unfortunately it looks like the Speckle Inspector won’t work for my specific case because there’s a bug with the “redirect measurements to” feature of the Speckle Inspector. If I set use that “redirect measurements to” drop-down, it prevents me from using Analyze Particles anymore unless I restart FIJI. Specifically Analyze Particles complains it does not have a “Redirect image” option (because it indeed doesn’t). So I can’t run the macro on all of my images.

For what it’s worth here is the revised code using the HeLa example image:

// Close all windows for now to make re-running the macro easier.
close("*");
// Open example image with 4 cells.
run("HeLa Cells (1.3M, 48-bit RGB)");
// Segment nuclei.
run("Duplicate...", "title=dna duplicate channels=3");
setAutoThreshold("MaxEntropy dark");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Analyze Particles...", "size=5-Infinity circularity=0.10-1.00 show=Masks exclude clear");
selectWindow("Mask of dna");
rename("nuclei");
run("Convert to Mask");
close("dna");
// Segment RNAi.
selectWindow("hela-cells.tif");
run("Duplicate...", "title=tritc duplicate channels=1");
run("Duplicate...", "title=tritc_mask duplicate channels=1");
run("Subtract Background...", "rolling=20");
setAutoThreshold("Otsu dark");
run("Convert to Mask");
run("Watershed");
run("Analyze Particles...", "size=5-100 pixel circularity=0.20-1.00 show=Masks exclude clear");
rename("rnai");
run("Convert to Mask");
close("tritc_mask");
// Run Biovoxxel speckle inspector
run("Speckle Inspector", "big=nuclei small=rnai redirect=None exclude roi speckle statistic individual_roi");

I’ve gone back to CellProfiler which is easier for this type of object analysis.

CellProfiler pipeline attached for the interested: cpproj.cppipe (26.9 KB) It has 15 modules and I use the same ImageJ HeLa sample image:

hela-cells0000.tif (672.5 KB)
hela-cells0001.tif (672.5 KB)
hela-cells0002.tif (672.5 KB)

$ grep '^[[:graph:]]' cpproj.cppipe | sed 's#:.*##' | tail -n +11
CorrectIlluminationCalculate
CorrectIlluminationApply
CorrectIlluminationCalculate
CorrectIlluminationApply
IdentifyPrimaryObjects
IdentifyPrimaryObjects
IdentifyPrimaryObjects
MaskObjects
MaskObjects
RelateObjects
RelateObjects
MaskObjects
MeasureObjectIntensity
MeasureObjectIntensity
ExportToSpreadsheet

To run CellProfiler I installed these 4 Debian system packages:

  • libmariadbclient-dev (mysql.h, etc needed by python-mysql)
  • libmariadb-dev-compat (for mysql_config needed by python-mysql)
  • default-jdk (for javac needed by javabridge)
  • python-wxgtk3.0 (for wx)

Also installed CellProfiler from source because of https://github.com/CellProfiler/CellProfiler/issues/3734

1 Like