Posted by
Michael Schmid on
Nov 07, 2018; 11:36am
URL: http://imagej.273.s1.nabble.com/Get-total-counts-from-each-counter-in-Results-table-for-macro-tp5021419p5021425.html
Hi Alex,
(1) alt key: In Edit>Selection>Properties there is a checkbox
"Show point counts (shortcut: alt y)"
For me, alt-y (or ctrl-alt-y) works with multi-point selections, it
creates a ResultsTable and enters the counter.
(2) Why "Table.size-1":
In ImageJ, as in Java, almost everything is numbered starting with 0.
So, if you have four rows, they are 0, 1, 2, and 3. Java even counts the
months of a year from 0 (January) to 11 (December).
The only exception that I am aware of: Stack slices in ImageJ are
numbered starting with 1.
I guess that's because the slice number appears on the user interface,
e.g. as 1/20 in the top-left corner of the image for the first slice out
of 20.
It would be confusing to have a different slice index on the display and
for programming, so slice numbers for programming also start with 1.
If rows in a table correspond to stack slices, this leads to the
unfortunate situation that the row numbers are slice numbers minus one.
Michael
________________________________________________________________
On 07.11.18 12:17, Aleksandr Mironov wrote:
> Dear Wayne,
>
> Thank you! I have two questions.
>
> 1) This "alt" "Properties" is it something new and can be used only in
> macro? I tried to reproduce it manually pressing "alt" and clicking
> Properties - did not work but works in macro. Is it documented anywhere?
>
> 2) In your example table there are 4 rows (if I look into
> print(Table.size)) and you are extracting count totals from the 4th row.
> However the argument "Table.size-1" (in Table.get) is pointing to 3rd
> row. Am I missing something here?
>
> Sincerely,
> Alex
>
>
> On 07/11/2018 04:39, Wayne Rasband wrote:
>>> On Nov 6, 2018, at 11:43 AM, Aleksandr Mironov
>>> <
[hidden email]> wrote:
>>>
>>> Dear All,
>>>
>>> I am using Multipoint Tool to count events in some images. In Results
>>> table I got total counts and in Counter column these counts are
>>> assigned to specific counter. How I can extract total values from
>>> each counter with macro? Saying, I got Counters 0, 1 and 2 with
>>> different counts in each.
>> The following macro displays the counts in a table (using
>> Edit>Selection>Properties with alt key down) and then extracts and
>> prints the count totals from the last row of the table.
>>
>> setKeyDown("alt");
>> run("Properties... ");
>> headers = split(Table.headings,"\t");
>> for (i=1; i<headers.length; i++)
>> print(headers[i]+" = "+Table.get(headers[i],Table.size-1));
>>
>> For a table that looks like this
>>
>> Slice Ctr 0 Ctr 1 Ctr 2
>> 1 3 3 0
>> 2 0 3 4
>> 3 0 0 5
>> Total 3 6 9
>>
>> the macro outputs
>>
>> Ctr 0 = 3
>> Ctr 1 = 6
>> Ctr 2 = 9
>>
>> -wayne
>> --
>> 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