Posted by
Peter Haub on
URL: http://imagej.273.s1.nabble.com/Problem-with-ROI-Manager-in-BatchMode-tp3682680p3682687.html
Hi Winfried,
indeed there seems to be a problem.
I have reduce your code and found that opening a set of rois's with
'open' show the behaviour you described : Nothing happens! The
roiManager seems to be not available.
If the set of roi's is opened with roiManager("Open", "C:\\RoiSet.zip")
everything work as expected.
Pretty sure your problem relies on the same IJ internals.
Maybe somebody will have a look for it.
Regards,
Peter
ps: in core a ; is missing after run("Measure") .
**************** Here is my code **********************
setBatchMode(true);
open("C:\\test.tif");
// not working version
//open("C:\\RoiSet.zip");
// working version
roiManager("Open", "C:\\RoiSet.zip");
selectWindow("test.tif");
run("Select None");
m=(roiManager("count")-1);
for(r=0;r<=m;r++)
{
roiManager("deselect");
roiManager("select",r);
arg="enlarge="+2;
run("Fill", "slice");
}
setBatchMode("exit and display");
*****************************************************
On 31.10.2011 20:39, Winfried Wurm wrote:
> Dear ImageJ community,
>
> I´ve encountered some Problems by using the Batchmode together with the ROI Manager in my Macro. I wrote a Macro which counts Foci in a Binary Image, selects the Outline of the Focus in every Slice and adds it to the ROI Manager. The ROIs are than measured in a second Channel.
> The Macro works fine if setBatchMode(false). But when I turn it true, the Measurements are completely nonsense.
> I think that I´ve tracked the error down to the creation of the Selection in the second Channel. When I let the Macro fill the ROIs in the second Channel the ROI in every Slice has the shape of the ROI of the last added ROI, but are good when I manually select them in the ROI Manager afterwards or when BatchMode is turned off.
>
> Since the Macro is very long I will only add the part of the Code which I think makes the trouble, the measuring in the second Channel.
> At this point, the ROI Manager has a least two ROIs added.
>
>
> focus++;
> hc=false;
> selectWindow("cell.tif");
> run("Select None");
> m=(roiManager("count")-1);
> for(r=0;r<=m;r++)
> {
> roiManager("deselect");
> roiManager("select",r);
> arg="enlarge="+px;
> run("Enlarge...", arg);
> run("Measure")
> if(getResult("Max")==255)
> hc=true;
> run("Fill", "slice");
> }
> selectWindow("foci.tif");
> roiManager("Reset");
> if(hc==true)
> HC++;
> else
> EC++;
>
>
>
> Can anyone help me fix this Problem?
> Thx for Helping in advance
> Winfried Wurm
>