How to convert log window to table

Hi everyone!

I am having a problem writing a macro in ImageJ. There is a table (Log window) with one column of numbers (2, 4, 6 rows, etc.). I need to transform this table as shown in the picture. It is necessary that the odd lines be written in one column, and the even ones in the second. Is there some way to do this?

Thanks.
Alex

Hi @AlexBereg

if you print your value pairs into one line you can copy&paste the content of the Log window directly to Excel.

Here is a short example:

t1 = 0.099
t2 = 6

IJ.log(t1 + "\t " + t2)

Note: The two values are separated by a tabulator AND a space because the \t sign will not be displayed in the Log window.

Maybe this is a starter.

Hi Alexey,
Yes this is possible, but if you somehow control what’s initially going to the log, it would be easier to output that directly to a Table (just saw Peter reply :wink: ).

Anyway, here’s a macro that does this:

s=split(getInfo("log"));
Table.create("LogTable");
for (i=0;i<s.length;i+=2) {
Table.set(fromCharCode(65+i/2),0,s[i]); 
Table.set(fromCharCode(65+i/2),1,s[i+1]); 
}

Jerome.

Sorry the version I sent was transposed, here the correct version:

s=split(getInfo("log"));
Table.create("LogTable");
for (i=0;i<s.length;i+=2) {
Table.set("A",i/2,s[i]); 
Table.set("B",i/2,s[i+1]); 
}

1 Like

Thank you so much! This is exactly I asked about! It works properly.

1 Like