【问题标题】:ImageJ/Fiji: Iteration through and printing in results tableImageJ/Fiji:在结果表中迭代和打印
【发布时间】:2013-10-07 11:55:59
【问题描述】:

我的 Jython-Fiji 插件有问题:

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

在我看来,这通常应该添加一个新列(名为 S),其中包含 s 的值。不幸的是,只有最后一个 s 值显示在该列中,而该列的所有其他行都用 0 填充。我确实错过了一些东西,但目前我不知道是什么。提前谢谢你!

【问题讨论】:

    标签: python jython imagej


    【解决方案1】:

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

    然后,我将ResultsTable.addValue() 函数调用替换为ResultsTable.setValue(),并添加了当前行参数。详情请见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")
    

    希望对您有所帮助。

    【讨论】:

    • 就是这样!非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多