How to set "Display Label" items in "Set measurement" in Python

Background

I want to do “Set measurement of Display Label” in Python(Jython) Script.
The explanation of “Display Label”: https://imagej.nih.gov/ij/docs/menus/analyze.html

This code works fine and is sufficient for the analysis.

from ij import IJ
from ij import ImagePlus
from ij.plugin.frame import ColorThresholder
from ij.process import ImageProcessor
from ij.plugin import ImageCalculator
from ij.plugin.frame import RoiManager
from ij.measure import ResultsTable
from ij.plugin.filter import ParticleAnalyzer

IJ.run("Set Measurements...", "area mean standard modal min centroid center perimeter bounding fit shape feret's integrated median skewness kurtosis area_fraction stack display invert redirect=None decimal=2")

PA = ParticleAnalyzer(0 , 1043199 , rt, 10000, 300000, 0.2, 1.0)
PA.setRoiManager(rm)
PA.analyze(imp)

But I want to do “Set measurement” directly by ImageJ API.

I found some documents to relate to it but I could not find Display Label.

Could someone please tell me how to “Set Measurement” directly from the ImageJ API?

I would appreciate to tell me how to “Display Label” and so on.

If my English is difficult to understand, please tell me that. I rewrite about this.

Hi @Daniel_SFC,
The options are encoded as an integer corresponding to constants of the Measurements class, that you should sum up
So something like following should work

#@ ImagePlus imp
#@ ResultsTable table
from ij.measure.Measurements import *
from ij.plugin.filter import Analyzer

options = CENTER_OF_MASS + LABELS + CIRCULARITY # see https://imagej.nih.gov/ij/developer/api/ij/measure/Measurements.html
print "options=", options

Analyzer.setMeasurements(options)
print "Analyzer options", Analyzer.getMeasurements() # Check that the options are as we just set it, OK 

#myAnalyzer = Analyzer(imp, options, table) # alternative
myAnalyzer = Analyzer(imp)
myAnalyzer.measure()


table.show("Results")
1 Like

Thanks, it help my study.
Dan