Expected 2 args and using Results

I’m using Jython to program an ImageJ macro.
Here is the relevant bit of code:

from ij.measure import ResultsTable

print r

However, it tells me that it expects 2 arguments. I don’t see what the other argument could be. My larger issue is that I cannot find a way use data from the Results window in my macro using Jython.

I would greatly appreciate any help. Thanks!

The error message is a bit misleading here, and probably related to the way Jython handles methods of Java classes.

If you have a look at the javadoc of ResultsTable, you’ll notice that the method getRowAsString(int row) is not static, meaning that this method is only available on initialized instances of the class (i.e. on objects), not on the class itself.

Simply put, you’d need to tell ImageJ to get the current results table before you access its rows.

While you can do this using a static function like e.g. rt = ResultsTable.getResultsTable(), the easiest way is to use script parameters, as illustrated by the following script:

#@ ResultsTable rt
r = rt.getRowAsString(2)
print r

Thank you so, so, so much!! I’ve been having a lot of problems just because I didn’t know how to deal with static functions. I really appreciate it. You’ve saved me a lot of time and have really improved my day!
Have a wonderful day:grin: