ResultTable does not show the expected columns

Hi guys,

i use the following code to setup the ParticleAnalyzer in a python script, but the resulttable finally only shows 6 columns:

Label - Area - Perim - IntDen - RawIntDen - Slice

I am wondering what my mistake is here. I would expect much more columns.

Cheers, Sebi

....
options = PA.SHOW_ROI_MASKS \
	+ PA.SHOW_RESULTS \
	+ PA.DISPLAY_SUMMARY \

measurements = PA.STACK_POSITION \
	     + PA.LABELS \
	     + PA.AREA \
	     + PA.PERIMETER \
	     + PA.CIRCULARITY \
	     + PA.SHAPE_DESCRIPTORS \
	     + PA.FERET

results = ResultsTable()
p = PA(options, measurements, results, MINSIZE, MAXSIZE, MINCIRCULARITY, MAXCIRCULARITY)
....

Here is a complete and runnable JavaScript example, created using the command recorder, that works as expected:

   imp = IJ.openImage("http://wsr.imagej.net/images/blobs.gif");
   IJ.setAutoThreshold(imp, "Default");
   IJ.run("Set Measurements...", "area perimeter shape feret's stack display");
   IJ.run(imp, "Analyze Particles...", "display clear summarize");

The reason for this is that you’re using two redundant parameters (see source code):

Measurements.CIRCULARITY: 8192
Measurements.SHAPE_DESCRIPTORS: 8192

The combination of parameters works by combining bits for each one:

     1 AREA -----------------------------+
     2 MEAN ----------------------------+|
     4 STD_DEV ------------------------+||
     8 MODE --------------------------+|||
    16 MIN_MAX ----------------------+||||
    32 CENTROID --------------------+|||||
    64 CENTER_OF_MASS -------------+||||||
   128 PERIMETER -----------------+|||||||
   256 LIMIT --------------------+||||||||
   512 RECT --------------------+|||||||||
  1024 LABELS -----------------+||||||||||
  2048 ELLIPSE ---------------+|||||||||||
  4096 INVERT_Y -------------+||||||||||||
  8192 SHAPE_DESCRIPTORS ---+|||||||||||||
 16384 FERET  -------------+||||||||||||||
0x8000 INTEGRATED_DENSITY +|||||||||||||||
   =====================  ||||||||||||||||
   Binary representation  0110010010000001

This explains why you get the Integrated density instead of the desired measurements, Circularity and Feret.
The following Python snippet illustrates the difference:

from java.lang import Integer
from ij.plugin.filter import ParticleAnalyzer as PA

measurementsWrong = PA.STACK_POSITION \
	     + PA.LABELS \
	     + PA.AREA \
	     + PA.PERIMETER \
	     + PA.CIRCULARITY \
	     + PA.SHAPE_DESCRIPTORS \
	     + PA.FERET

measurementsCorrect = PA.STACK_POSITION \
	     + PA.LABELS \
	     + PA.AREA \
	     + PA.PERIMETER \
	     + PA.SHAPE_DESCRIPTORS \
	     + PA.FERET

print measurementsWrong, " : ", Integer.toBinaryString(measurementsWrong)
print measurementsCorrect, " : ", Integer.toBinaryString(measurementsCorrect)

which prints:

Wrong:   1082497  :  100001000010010000001
Correct: 1074305  :  100000110010010000001

I agree that it’s easier and less error prone to use the IJ helper class.

However, in the past I had to use the low-level approach (calling ParticleAnalyzer directly) because in an ExtendedPluginFilter using GenericDialogs with Preview functionality, calling IJ.run(...) would trigger premature recording of an incomplete command in the Macro recorder.

2 Likes

Thanks for the help. I was not aware of that redundancy. Now it works just fine, when I remove PA.CIRCULARITY and just use PA.SHAPE_DESCRIPTORS.

Sebi