I have a problem with my Jython-Fiji Plugin:
IJ.run("Set Measurements...", "area centroid perimeter shape feret's area_fraction redirect=None decimal=6")
IJ.run("Analyze Particles...")
rt = ResultsTable.getResultsTable()
for roi in RoiManager.getInstance().getRoisAsArray():
a = rt.getValue("Feret", row)
b = rt.getValue("MinFeret", row)
nu= 1
L = 1
p = 1
row = row + 1
s = (math.pi/4) * (1/(nu*L)) * math.pow(a, 3) * math.pow(b, 3) / (math.pow(a, 2) + math.pow(a, 2))*p
rt.addValue("S", s)
rt.show("Results")
Normaly this should add a new column (named S) in my oppinion with the values of s. Unfortunatly only the last s value shows up in the column, while all other rows of this column are filled with 0. I definetly missed something, but at the moment I dont know what. Thanking you in advance!
To make your code run, I had to add import math
and row=0
at the beginning.
I then replaced the ResultsTable.addValue()
function call by ResultsTable.setValue()
with adding the current row parameter. See the API documentation for details.
import math
IJ.run("Set Measurements...", "area centroid perimeter shape feret's area_fraction redirect=None decimal=6")
IJ.run("Analyze Particles...")
rt = ResultsTable.getResultsTable()
row=0
for roi in RoiManager.getInstance().getRoisAsArray():
a = rt.getValue("Feret", row)
b = rt.getValue("MinFeret", row)
nu= 1
L = 1
p = 1
s = (math.pi/4) * (1/(nu*L)) * math.pow(a, 3) * math.pow(b, 3) / (math.pow(a, 2) + math.pow(a, 2))*p
rt.setValue("S", row, s)
row = row + 1
rt.show("Results")
Hope that helps.