Posted by
David Webster on
Apr 05, 2010; 8:28pm
URL: http://imagej.273.s1.nabble.com/eval-script-roi-contains-x-y-tp3688675p3688678.html
Douglas,
Line 1 probably refers to line 1 of the Javascripts code in the
eval("script", "roi.contains(x, y);");, i.e roi.contains(x, y);.
For what it's worth, the macro function documentation says that for
roiManager("select", index);"*index* must be greater than or equal zero."
So, index-- is probably wrong. This has nothing to do with your problem, but
will show up eventually.
I haven't tried running Javascript but gave it a quick look anyway. I tried
using Roi.contains(x,y) instead of roi.contains(x,y) but get the error
below:
"Error: Java class "ij.gui.Roi" has no public instance field or method named
"contains". (<Unknown source>#1) in <Unknown source> at line number 1.
I am interested to see what's going on, so I hope someone swho knows what
doing answers you.
David
On Mon, Apr 5, 2010 at 11:36 AM, Benn, Douglas K. <
[hidden email]
> wrote:
> Another query please.
>
> I wrote the following code to test the use of roi.contains(x,y) from within
> a macro. I have code before it which loads an image, thresholds, masks,
> outlines and opens roimanager. I also checked to see that the roi list is
> populated and the image displays the rois and a selection.
>
> When I run the code
>
> index =getNumber("Enter number of ROI", 0);
> index = index--;
> roiManager("select", index);
> x =getNumber("Cursor X", 0);
> y =getNumber("Cursor Y", 0);
> roi_flag =eval("script", "roi.contains(x, y);");
> if (roi_flag==true) print("roi flag=Inside\n");
> else print("roi flag=Outside\n");
>
> I get this output in my Log.
>
> ReferenceError: "roi" is not defined. (<Unknown source>#1) in <Unknown
> source> at line number 1
>
> Although it references line number 1 it is not line number 1 of my
> program.What am I doing wrong?
>
> Thanks.
>
> Douglas
> Dr Douglas K Benn, BDS, M.Phil., Ph.D., Dipl. Dental Radiology (Royal
> College of Radiologists, England).
> Professor
> Dept of General Dentistry
> Creighton University Dental School
> 2500 California Plaza
> Omaha
> Nebraska 68178
>
> Tel: (402)280 5025
> Fax: (402)280 5094
>