Setting A Result by Label

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

Setting A Result by Label

Wilson R S (AT)
Hi Listers,

I am using a number of different macro to create custom measurements. However I wish to set these measurement in the same row if they are from the same image. I am using the macro code below:

break=false;
i=0;
n=0;
while (i<nResults && break!=true)
{
                label=getResult("Label",i);
                if (label == title)
                {
                                n=i;
                                break=true;
                }else{
                                n=nResults;
                                i++;
                }
}

setResult("Label", n, title);
setResult("Measurement", n, Measurement);

Where title is the title/label of the of the current image, and Measurement is some calculated number.
The macro (should) check all row of the results table and if the current label exists set the measurement to the corresponding row, if the label does not exits  a new row should be created for the result.

In essence I do not want any label to appear twice in a single results table.

I hope I have been clear, any help would be much appreciated, or if someone knows of an easier/different way of doing this.

Thanks in advance.

Rhod
Reply | Threaded
Open this post in threaded view
|

Re: Setting A Result by Label

Wilson R S (AT)
Have cracked it.

Should have been using "label=getResultLabel(i);" instead of " label=getResult("Label",i);".

Rhod

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Wilson R S (AT)
Sent: 21 February 2011 11:45
To: [hidden email]
Subject: Setting A Result by Label

Hi Listers,

I am using a number of different macro to create custom measurements. However I wish to set these measurement in the same row if they are from the same image. I am using the macro code below:

break=false;
i=0;
n=0;
while (i<nResults && break!=true)
{
                label=getResult("Label",i);
                if (label == title)
                {
                                n=i;
                                break=true;
                }else{
                                n=nResults;
                                i++;
                }
}

setResult("Label", n, title);
setResult("Measurement", n, Measurement);

Where title is the title/label of the of the current image, and Measurement is some calculated number.
The macro (should) check all row of the results table and if the current label exists set the measurement to the corresponding row, if the label does not exits  a new row should be created for the result.

In essence I do not want any label to appear twice in a single results table.

I hope I have been clear, any help would be much appreciated, or if someone knows of an easier/different way of doing this.

Thanks in advance.

Rhod