Searching/lookup value in Results table

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

Searching/lookup value in Results table

AJBell
Dear list,

I have hit a problem writing a macro. In esscence, measurements are taken of ROI from multiple images and stored in a single Results table. Some of these values then need to be altered as part of a user feedback loop. When storing the measurements, the ROI name, as retrieved by the getInfo("roi.name") command is used as an identifier.

The table I end up with looks like the following, albeit with several thousand rows:

  Label        Area              IntDen
1 0172-0039 4.78000E2 1.45210E4
2 0173-0058 6.64000E2 1.93700E4
3 0174-0056 2.06000E2 2.64430E4

If I try to select a row based on the Label value using the following:

x = "0172-0039";
y= 600;
for(i=0; i<nResults; i++) {
        rowId = getResult("Label", i);
        if(rowId==x) {
                   setResult("Area", i, y);
       
        }
}

I get no return result. I added a print function before the If to see what value of rowId was being obtained, and was given NaN. Is there a way around the non-numeric error or is there an easier way to do what I would like to? Any help or suggestions would be welcome.

Andrew

Andrew Bell
Department of Infection, Immunity and Inflammation
Maurice Shock Medical Sciences Building
University of Leicester
University Road
Leicester
LE1 9HN
United Kingdom

Reply | Threaded
Open this post in threaded view
|

Re: Searching/lookup value in Results table

lechristophe
Hi Andrew,

you should use the macro command

getResultLabel(row);

to get the label of a given row ina Results table.

Christophe

On Mon, Jun 27, 2011 at 10:57, AJBell <[hidden email]> wrote:

>
> Dear list,
>
> I have hit a problem writing a macro. In esscence, measurements are taken of
> ROI from multiple images and stored in a single Results table. Some of these
> values then need to be altered as part of a user feedback loop. When storing
> the measurements, the ROI name, as retrieved by the getInfo("roi.name")
> command is used as an identifier.
>
> The table I end up with looks like the following, albeit with several
> thousand rows:
>
>        Label             Area                IntDen
> 1       0172-0039       4.78000E2       1.45210E4
> 2       0173-0058       6.64000E2       1.93700E4
> 3       0174-0056       2.06000E2       2.64430E4
>
> If I try to select a row based on the Label value using the following:
>
> x = "0172-0039";
> y= 600;
> for(i=0; i<nResults; i++) {
>        rowId = getResult("Label", i);
>        if(rowId==x) {
>                   setResult("Area", i, y);
>
>        }
> }
>
> I get no return result. I added a print function before the If to see what
> value of rowId was being obtained, and was given NaN. Is there a way around
> the non-numeric error or is there an easier way to do what I would like to?
> Any help or suggestions would be welcome.
>
> Andrew
>
> Andrew Bell
> Department of Infection, Immunity and Inflammation
> Maurice Shock Medical Sciences Building
> University of Leicester
> University Road
> Leicester
> LE1 9HN
> United Kingdom
>
>
>
> --
> View this message in context: http://imagej.588099.n2.nabble.com/Searching-lookup-value-in-Results-table-tp6519643p6519643.html
> Sent from the ImageJ mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Searching/lookup value in Results table

AJBell
Thank you for the reply. That works if I know the row number and want the row label, however what I have is the row label and not the row number.

lechristophe wrote
Hi Andrew,

you should use the macro command

getResultLabel(row);

to get the label of a given row ina Results table.

Christophe

On Mon, Jun 27, 2011 at 10:57, AJBell <[hidden email]> wrote:
>
> Dear list,
>
> I have hit a problem writing a macro. In esscence, measurements are taken of
> ROI from multiple images and stored in a single Results table. Some of these
> values then need to be altered as part of a user feedback loop. When storing
> the measurements, the ROI name, as retrieved by the getInfo("roi.name")
> command is used as an identifier.
>
> The table I end up with looks like the following, albeit with several
> thousand rows:
>
>        Label             Area                IntDen
> 1       0172-0039       4.78000E2       1.45210E4
> 2       0173-0058       6.64000E2       1.93700E4
> 3       0174-0056       2.06000E2       2.64430E4
>
> If I try to select a row based on the Label value using the following:
>
> x = "0172-0039";
> y= 600;
> for(i=0; i<nResults; i++) {
>        rowId = getResult("Label", i);
>        if(rowId==x) {
>                   setResult("Area", i, y);
>
>        }
> }
>
> I get no return result. I added a print function before the If to see what
> value of rowId was being obtained, and was given NaN. Is there a way around
> the non-numeric error or is there an easier way to do what I would like to?
> Any help or suggestions would be welcome.
>
> Andrew
>
> Andrew Bell
> Department of Infection, Immunity and Inflammation
> Maurice Shock Medical Sciences Building
> University of Leicester
> University Road
> Leicester
> LE1 9HN
> United Kingdom
>
>
>
> --
> View this message in context: http://imagej.588099.n2.nabble.com/Searching-lookup-value-in-Results-table-tp6519643p6519643.html
> Sent from the ImageJ mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Searching/lookup value in Results table

lechristophe
Andrew,

I meant, replace

rowId = getResult("Label", i);

by

rowId = getResultLabel(i);


in the original snippet you provided should affect the correct string
to rowId so you can test it for equivalence (be careful with string
comparisons) with your x variable.

Christophe


On Mon, Jun 27, 2011 at 12:23, AJBell <[hidden email]> wrote:
> rowId = getResult("Label", i);
Reply | Threaded
Open this post in threaded view
|

Re: Searching/lookup value in Results table

AJBell
I understand now. Thank you, that works perfectly.

Andrew

<quote author="lechristophe">
Andrew,

I meant, replace

rowId = getResult("Label", i);

by

rowId = getResultLabel(i);


in the original snippet you provided should affect the correct string
to rowId so you can test it for equivalence (be careful with string
comparisons) with your x variable.

Christophe