Posted by
Straub, Volko A. (Dr.) on
Jul 28, 2015; 12:15pm
URL: http://imagej.273.s1.nabble.com/Getting-a-list-of-indexes-of-selected-ROIs-tp5013762p5013779.html
Thanks Avital and Kees for your comments and suggestions. As a workaround, I was thinking along similar lines to Kees' suggestion to write a function to select a series of ROIs - thanks to the code you have posted I won't have to write it myself.
Thanks,
Volko
________________________________________
From: ImageJ Interest Group [
[hidden email]] on behalf of Straatman, Kees (Dr.) [
[hidden email]]
Sent: 28 July 2015 12:42
To:
[hidden email]
Subject: Re: Getting a list of indexes of selected ROIs
Hi Volko,
I don't know how to get the indexes from the ROI manager when more than one ROI is selected but the code below collects the ROI indexes when they are selected one by one (directly in the ROI manager or on the image). It will add an extra selection to the ROI manager which you select when ready. At the end this is deleted again
----------------------- Code --------------------------------------
// Maximum number of selected ROIs
n=newArray(roiManager("count"));
c= roiManager("count");
// Fill array with -1 otherwise they will have the value 0
for (i=0;i<roiManager("count");i++)
n[i] = -1;
// add extra selection to ROI manager to stop selection
makeRectangle(0, 0, 1, 1);
roiManager("Add");
roiManager("Deselect");
// Select the ROIs of interest
waitForUser("Select your first ROI, click \"OK\" and continue to select ROIs.\nWhen ready select the last ROI in the ROI manager");
for (i=0; i<=roiManager("count");i++){
if(roiManager("index")<c){
n[i] = roiManager("index");
do{
wait(500);
new = roiManager("index");
}while((n[i]==new)||(new==-1))
}
else i=roiManager("count")+1;
}
Array.print(n);
// Delete extra added ROI
roiManager("select", roiManager("count")-1);
roiManager("Delete");
--------------------------------Code ---------------------------------
Best wishes
Kees
________________________________________
From: ImageJ Interest Group [
[hidden email]] on behalf of Straub, Volko A. (Dr.) [
[hidden email]]
Sent: 27 July 2015 16:27
To:
[hidden email]
Subject: Getting a list of indexes of selected ROIs
I am trying to get a list of the indexes if multiple ROIs are selected in the ROI manager to use in a macro. The function roiManager("index") returns the index of the first selected ROI, but is there a way to obtain the number and indexes of multiple selected ROIs? I noticed that the RoiManager class has a getIndexes() function. Is there a way to use that function in a macro? I thought there was, but searching the documentation, I don't seem to be able to find the right information.
Any advice/pointers would be very welcome.
Thanks,
Volko
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html