2013-10-07 36 views
0

我有我的Jython的斐济插件的问题:的ImageJ /斐济:迭代通过,并在结果表打印

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这应该在我的oppinion添加新列(名为S)与值秒。不幸的是,只有最后一个值出现在列中,而此列中的所有其他行都填充了0.我肯定错过了某些内容,但此刻我不知道该怎么做。提前感谢您!

回答

1

为了使您的代码运行,我必须在开始时添加import mathrow=0

然后,我用ResultsTable.setValue()替换ResultsTable.addValue()函数调用,添加当前行参数。有关详细信息,请参阅API documentation

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") 

希望有所帮助。

+0

这就是它!非常感谢。 –