Login  Register

Error identifying Plot window

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Error identifying Plot window

Norbert Vischer
10 posts
When I run the macro below, I get an error after the first few runs.
getImageID does not correctly return the ID of the plot window. Is there any fix or work-around?

Norbert Vischer


run("Close All");
run("Blobs (25K)");
srcID = getImageID;

for (jj = 0; jj < 100; jj++){
        selectImage(srcID);
        yValues = newArray(2, 2.8, 4, 5.6, 8);
        Plot.create("Simple Plot", "X", "Y", yValues);
        Plot.show;
        plotID = getImageID;
        if (srcID == plotID)
                exit("Error: srcID == plotID; jj =" + jj);
        close;
}
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Error identifying Plot window

BenTupper
122 posts
Hi,

On Nov 27, 2011, at 6:28 PM, Norbert Vischer wrote:

> When I run the macro below, I get an error after the first few runs.
> getImageID does not correctly return the ID of the plot window. Is there any fix or work-around?
>
> Norbert Vischer
>
>
> run("Close All");
> run("Blobs (25K)");
> srcID = getImageID;
>
> for (jj = 0; jj < 100; jj++){
> selectImage(srcID);
> yValues = newArray(2, 2.8, 4, 5.6, 8);
> Plot.create("Simple Plot", "X", "Y", yValues);
> Plot.show;
> plotID = getImageID;
> if (srcID == plotID)
> exit("Error: srcID == plotID; jj =" + jj);
> close;
> }


I suspect that a plot window does not qualifies as an image window in the macro language.  Thus, the getImageID() and close() commands might not work as expected.

These modifications work on IJ 1.45m15 Mac OSX.  There may be a better way but I can't think of any just now.

run("Close All");
run("Blobs (25K)");
srcID = getImageID;

for (jj = 0; jj < 100; jj++){
        selectImage(srcID);
        yValues = newArray(2, 2.8, 4, 5.6, 8);
        Plot.create("Simple Plot", "X", "Y", yValues);
        Plot.show;
        //plotID = getImageID;
        //if (srcID == plotID)
        // exit("Error: srcID == plotID; jj =" + jj);
        selectWindow("Simple Plot"); // <--- use selectWindow(title) for non-images
        run("Close"); // <--- use run("Close") for non-images
}

Cheers,
Ben
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Error identifying Plot window

Rasband, Wayne (NIH/NIMH) [E]
1064 posts
In reply to this post by Norbert Vischer
On Nov 27, 2011, at 6:28 PM, Norbert Vischer wrote:

> When I run the macro below, I get an error after the first few runs.
> getImageID does not correctly return the ID of the plot window. Is there any fix or work-around?

There was a plot window timing problem that is fixed in the ImageJ 1.46b daily build.

-wayne

>
> Norbert Vischer
>
>
> run("Close All");
> run("Blobs (25K)");
> srcID = getImageID;
>
> for (jj = 0; jj < 100; jj++){
> selectImage(srcID);
> yValues = newArray(2, 2.8, 4, 5.6, 8);
> Plot.create("Simple Plot", "X", "Y", yValues);
> Plot.show;
> plotID = getImageID;
> if (srcID == plotID)
> exit("Error: srcID == plotID; jj =" + jj);
> close;
> }