Results count in a separate table

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Results count in a separate table

Cyril Turiès
Dear ImageJ users,

When using the function getValue("results.count") with a separate table I am
not able to get the total number of lines displayed in this table.
I am working on a macro that has to be launched several times on various
images selected by user. Between two analyses the ResultsTable is cleared,
the image is closed and a table remains called "Morphometrie" with results
calculated from previous images.

I attached below the part of code that is problematic:



If you comment/uncomment lines 11 to 14 to mimic the behaviour of adding
lines to the "Morphometrie" table each time the macro is launched, you get a
results count remaining at 1 with 5 lines in the table.
If you uncomment all the lines at a time you get the correct number from
getValue("results.count").

Is there a way to count the lines that were previously printed in a table?

Thank you for your help.

Cyril



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Results count in a separate table

Michael Schmid
Hi Cyril,

as far as I could determine, ImageJ uses the table currently
named "Results" for the Results table macro commands.

If you have several Tables with different names, rename the one
that you want to use to "Results". E.g.

// if you want to keep the current Results table (if any),
// first rename it:
if (nResults > 0)
   IJ.renameResults("Results", "Results_tmp");
// now rename the table you like to "Results":
IJ.renameResults("Morphometrie", "Results");
   nLines = nResults();
// when done, rename it back
IJ.renameResults("Results", "Morphometrie");


Michael
________________________________________________________________
On 20/09/2017 11:15, Cyril Turiès wrote:

> Dear ImageJ users,
>
> When using the function getValue("results.count") with a separate
> table I am not able to get the total number of lines displayed in
> this table. I am working on a macro that has to be launched several
> times on various images selected by user. Between two analyses the
> ResultsTable is cleared, the image is closed and a table remains
> called "Morphometrie" with results calculated from previous images.
>
> I attached below the part of code that is problematic:
>
>
>
> If you comment/uncomment lines 11 to 14 to mimic the behaviour of
> adding lines to the "Morphometrie" table each time the macro is
> launched, you get a results count remaining at 1 with 5 lines in the
> table. If you uncomment all the lines at a time you get the correct
> number from getValue("results.count").
>
> Is there a way to count the lines that were previously printed in a
> table?
>
> Thank you for your help.
>
> Cyril

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Results count in a separate table

Cyril Turiès
This post was updated on .
Hi Michael,

Thank you for your solution.
It worked, instead of printing to a new table I had to set the calculations
to the Results table then rename it to keep values and switching from one
table to the other each time the macro is launched.

I added the code below just in case someone has the same issue.

var windowTabName="Data Table", prefix="IMG01", Sx="M", SL=35.3, S=2.1, A=1, B=2, C=3, D=4, E=5;
if (isOpen(windowTabName)) {
	IJ.renameResults(windowTabName, "Results");
	}
	col = newArray("Name", "Sx", "SL", "S", "A", "B", "C", "D", "E");
	a = newArray(prefix, Sx, SL, S, A, B, C, D, E);
	c = nResults;
	for (l=0; l<a.length; l++) {
			setResult(col[l], c, a[l]);
	}
	IJ.renameResults(windowTabName);
	run("Clear Results");

Regards,

Cyril

--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html