Login  Register

Re: The runMacro command doesn't "see" the ROI manager

Posted by Rasband, Wayne (NIH/NIMH) [E] on Jul 15, 2015; 7:04pm
URL: http://imagej.273.s1.nabble.com/The-runMacro-command-doesn-t-see-the-ROI-manager-tp5013572p5013580.html

> On Jul 15, 2015, at 10:42 AM, Avital Steinberg <[hidden email]> wrote:
>
> Hi,
> I'm running a program which has to run in batch mode, and I am using an
> additional macro by calling runMacro. The problem is that within the macro,
> the number of ROIs in the ROI manager is zero, while before and after
> running the macro, there are ROIs in the ROI manager. The problem is that
> the macro doesn't "see" the ROI manager.
>
> This happens only in the batch mode, but when I try to set the batch mode
> to false only for this part of the program, it doesn't solve the problem. I
> tried explicitly opening the image with the ROIs and using the command
> "from ROI manager" to solve this problem, but the problem wasn't solved.
>
> Does anyone have any idea how to solve this problem?

You can work around this problem by opening the ROI Manager before entering batch mode. For example, this macro

 run("ROI Manager...");
 setBatchMode(true);
 run("Blobs (25K)");
 setAutoThreshold("Default");
 roiManager("reset");
 run("Analyze Particles...", "add");
 print("count1="+roiManager("count"));
 runMacro("ShowCount.ijm");

outputs

 count1=64
 count2=64

but it outputs

 count1=64
 count2=0

if you close the ROI Manager, remove the first line [run("ROI Manager…”)] and run it again.

wayne


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html