Re: How to create a customised results table and add data to it within a macro

Posted by Michael Schmid on
URL: http://imagej.273.s1.nabble.com/How-to-create-a-customised-results-table-and-add-data-to-it-within-a-macro-tp5000701p5020404.html

Hi Stein,

the Table.* functions are currently under development; they are in the
daily build only.

The list of currently implemented commands is in the Release notes:
https://github.com/imagej/imagej1/blob/master/release-notes.html

    Table.create() - opens a new table
    Table.size() - number of rows in the table
    Table.title() - title of the current table
    Table.headings() - column headings as a tab-delimited string
    Table.get(columnName, rowIndex) - returns a numeric value
    Table.getString(columnName, rowIndex) - returns a string value
    Table.set(columnName, rowIndex, value) - sets numeric or string value
    Table.update() - updates table window
    Table.reset() - resets (clears) the table
    Table.applyMacro(macro) - applies macro code to table
    Table.rename(title1, title2) - renames a table
    Table.save(filePath) - saves the table
    Table.deleteRows(index1, index2) - deletes specified rows
    Table.deleteColumn(columnName) - deletes specified column
    Table.hideRowNumbers() - disables display of row numbers


You can also specify the title of a table, this argument goes last.

So e.g. the macro I had suggested last week has to be changed to:
   myName = "01.txt";
   Table.applyMacro("_='"+myName+" '+_", "Results");

If no title is given, the commands refer the main "Results" table or to
the current foreground window (if it has a table).
Inside the macro of 'apply macro', if no title is given, the Table
commands refer to the table processed by the macro.

Note that these commands are still experimental. Things may still
change, so you may have to adapt your macros in case of changes!


Michael
________________________________________________________________
On 09/04/2018 12:43, Stein Rørvik wrote:

> Table.applyMacro seems very useful, but I cannot see it documented in the
> https://imagej.nih.gov/ij/developer/macro/functions.html webpage?
> Are there any other Table.* functions implemented in ImageJ ?
>
> Stein
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Michael Schmid
> Sent: 28. mars 2018 18:51
> To: [hidden email]
> Subject: Re: How to create a customised results table and add data to it within a macro
>
> Hi Herbie & dschones,
>
> the first column with the 'Y123' etc. is the "row label", not a standard column. In a macro, you can get and set it with
>     getResultLabel(row) and
>     setResult("Label", row, string).
>
> With today's daily build (Help>Update ImageJ), you can also modify it without a loop over all rows:
>
>     myName = "01.txt";
>     Table.applyMacro("Results", "_='"+myName+" '+_");
>
> (Since the "row label" column has an empty name in this case, its name is mapped to an underscore as variable name.)
>
> This gives you a space, not a tab between the '01.txt' and the 'Y123'
>
> In principle, one could add a tab, but that would shift all columns to the right. The headers won't get shifted, and I don't think that one could also shift the headers.
>
> By the way, you can have Strings and numbers mixed in one column, but it won't help you here. E.g., if there is a column "X123", this works:
>     setResult("X123", 1, "hello");
>
>
> Michael
> ________________________________________________________________
>
>
> On 28/03/2018 17:58, Herbie wrote:
>> Would it be ok to have the filename in a new first column:
>>
>>                 X936      X937      X938
>> 01.txt  Y516
>> 01.txt  Y517
>> 01.txt  Y518
>> 01.txt  Y519
>> 01.txt  Y520
>>
>> 02.txt  Y516
>> 02.txt  Y517
>> 02.txt  Y518
>> 02.txt  Y519
>> 02.txt  Y520
>>
>> or something like:
>>
>>        X936_01.txt X937_01.txt X938_01.txt X936_02.txt X937_02.txt
>> X938_02.txt (watch for line breaks)
>> Y516
>> Y517
>> Y518
>> Y519
>> Y520
>>
>> or something along these lines:
>>
>> 01.txt  X936  X937  X938  02.txt  X936  X937  X938
>> Y516                      Y516
>> Y517                      Y517
>> Y518                      Y518
>> Y519                      Y519
>> Y520                      Y520
>>
>>
>> AFAIK it is not possible to have numbers and letters in the same column
>> except in the column headers.
>>
>> Please be aware of the fact that ImageJ is not a spread-sheet program,
>> but serves for image processing in the first place.
>>
>> Regards
>>
>> Herbie
>>
>> ::::::::::::::::::::::::::::::::::::::
>> Am 28.03.18 um 17:35 schrieb dschones:
>>> Hi Herbie,
>>>
>>> I'll just leave the generation of the results as they are and give the
>>> reference to the way I found getting the filename into first line of the
>>> results.txt
>>>
>>> https://askubuntu.com/questions/1019727/inserting-file-name-in-first-line-of-merged-txt-files
>>>
>>> <https://askubuntu.com/questions/1019727/inserting-file-name-in-first-line-of-merged-txt-files>
>>>
>>>
>>> Good afternoon! :)
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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