Posted by
Romain Guiet on
Sep 24, 2015; 11:50am
URL: http://imagej.273.s1.nabble.com/ROI-Manager-count-0-although-ROI-Manager-has-ROIs-tp5014427p5014439.html
Hi Martin ,
I noticed a weird behavior like this a while ago (when i tried to rename the ROIs). I identified that it was due to the absence of an existing ROImanager window before entering the "batch mode" using setBatchMode(true).
Instead of closing the ROImanager window if it's open, I would recommend to reset it using the function roiManager("Reset"). Actually if there no roiManager window opened, the problem will still be there, so you should open one before entering the batch mode.
So you can replace :
if (isOpen("ROI Manager")) {
selectWindow("ROI Manager");
run("Close");
}
by :
roiManager("Reset"); // it will reset ,or create, the roiManager window
so the begining of your code willl be :
run("Close All");
roiManager("Reset");
setBatchMode(true);
Cheers,
Romain
---------------------------------------------------------------
Dr. Romain Guiet
Bioimaging and Optics Platform (PT-BIOP)
Ecole Polytechnique Fédérale de Lausanne (EPFL)
Faculty of Life Sciences
Station 19, AI 0140
CH-1015 Lausanne
Phone: [+4121 69] 39629
http://biop.epfl.ch/---------------------------------------------------------------
________________________________________
De : ImageJ Interest Group [
[hidden email]] de la part de Martin Höhne [
[hidden email]]
Envoyé : mercredi 23 septembre 2015 20:25
À :
[hidden email]
Objet : ROI Manager count=0 although ROI Manager has ROIs
Dear all,
the macro below illustrates a problem with the ROI Manager. Although it is
open and populated with ROIs the roi-count is zero.
I´m sure it has something to do with batch mode, but I´m not sure if the
behaviour is expected or a bug.
Best,
Martin
//macro start----------------------------------------------------
/*
* Part 1: identify small particles and add their outline to overlay of the
original image
* this part works fine
* Part 2: identify large particles and allow the user to view the results
with Show/Hide the ROIs
* this part does not work as expected
*
* Problems are in line 61 (minor) and 66 (severe)
*/
run("Close All");
if (isOpen("ROI Manager")) {
selectWindow("ROI Manager");
run("Close");
}
setBatchMode(true);
//open Cell Colony image and make a binarized copy
run("Cell Colony (31K)");
original=getImageID;
run("Duplicate...", "title=bin");
run("Make Binary");
binary=getImageID;
setOption("BlackBackground", false);
// Part 1: identify small particles and add their outline to overlay of the
original image
// this part works fine
run("Analyze Particles...", "size=1-44 exclude add");
//add outlines to overlay
roiManager("Show None");
//rois=roiManager("Count");
//combine all identified ROIs into one ROI
a1=newArray(roiManager("Count"));
for (i=0; i<a1.length; i++){
a1[i]=i;
}
roiManager("Select", a1);
roiManager("Combine");
roiManager("Add");
//add combined ROI to overlay of original
selectImage(original);
roiManager("Select", (a1.length));//this is the combined ROI
roiManager("Set Color", "blue");
run("Add Selection...");// to overlay
// Part 2: identify large particles and allow the user to view the results
with Show/Hide the ROIs
// this part does not work as expected
selectImage(binary);
run("Select None");
roiManager("Reset");
run("ROI Manager...");
run("Analyze Particles...", "size=45-Infinity exclude add");
selectImage(original);
//the complete macro should run in batch mode, however at this point I´d
like the user
//to have a look at the selected particles
setBatchMode("Show");
roiManager("Show All");// Problem #1: this line seems to have no effect.
//The ROIs are only shown after deselecting/reselecting "Show All" in
the ROI Manager
waitForUser("Display/hide large particles by selecting/deselecting \n -Show
All- in the ROI Manager\n \nContinue with OK");
setBatchMode("Hide");
print("There are "+ roiManager("Count")+" ROIs in the ROI Manager");
// Problem #2: although the ROI Manager is visible and populated with ROIs
the count is zero?
exit;
//macro end----------------------------------------------------------
--
View this message in context:
http://imagej.1557.x6.nabble.com/ROI-Manager-count-0-although-ROI-Manager-has-ROIs-tp5014427.htmlSent from the ImageJ mailing list archive at Nabble.com.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html