Dear all (probably Wayne),
In the case the Labels option is activated within the RoiManager, the Java method getSelectedIndexes() of the RoiManager class will then be returning the indexes of all the ROIs within the RoiManager and this independently whether they had been selected or not. And when the Labels option is desactivated, the getSelectedIndexes() method is then working as expected. My best regards, Philippe Philippe CARL Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie 74 route du Rhin 67401 ILLKIRCH Tel : +33(0)3 68 85 42 89 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
> On Aug 28, 2020, at 6:56 PM, CARL Philippe (LBP) <[hidden email]> wrote:
> > Dear all (probably Wayne), > In the case the Labels option is activated within the RoiManager, the Java method getSelectedIndexes() of the RoiManager class will then be returning the indexes of all the ROIs within the RoiManager and this independently whether they had been selected or not. > And when the Labels option is desactivated, the getSelectedIndexes() method is then working as expected. I am unable to reproduce this problem using the following JavaScript code: img = IJ.createImage("Untitled", "8-bit black", 400, 400, 1); img.show(); rm = RoiManager.getRoiManager(); rm.reset(); for (i=0; i<5; i++) { roi = OvalRoi.create(i*70, i*70, 70, 70); rm.addRoi(roi); } rm.setSelectedIndexes([2,4]); rm.runCommand(img,"Show All with labels"); indexes = rm.getSelectedIndexes(); for (i=0; i<indexes.length; i++) print(i+" "+indexes[i]); This is the output: 0 2 1 4 -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Wayne,
I fully validate your findings in the case I try to use your proposed javascript code. Nevertheless, I'm still able to reproduce my described issue in the case I generate a "more tricky version of it". And in order to do this, I first launch the following code: img = IJ.createImage("Untitled", "8-bit black", 400, 400, 1); img.show(); rm = RoiManager.getRoiManager(); for (i = 0; i < 5; i++) { roi = OvalRoi.create(i * 70, i * 70, 70, 70); rm.addRoi(roi); } rm.runCommand (img, "Show All with labels"); IJ.run (img, "Select None", ""); var indexesOfSelectedRoisAsArray = new Array(); for (i = 0; i < rm.getCount(); i++) indexesOfSelectedRoisAsArray[i] = i; rm.setSelectedIndexes(indexesOfSelectedRoisAsArray); Then when I manually select even only one (gives the same by selecting 2, 3,...) ROI(s) within the RoiManager and launch the following (second) code: rm = RoiManager.getRoiManager(); indexes = rm.getSelectedIndexes(); for (i = 0; i < indexes.length; i++) print(i + " " + indexes[i]); The data of all the ROIs within the RoiManager will be printed out. Even pushing the "Deselect" button before launching the second code won't make the deal, but deactivating the "Labels" option will make it. At last, this issue only happens in the case you manually select the ROIs, i.e. by using your proposed "rm.setSelectedIndexes([2,4])" the code will be working as well as it should. I guess this may probably be a quite tricky bug, thus I thank you very much in advance for looking into it and wish you good luck! Have a nice evening and take care, Philippe ----- Le 29 Aoû 20, à 4:14, Wayne Rasband [hidden email] a écrit : > On Aug 28, 2020, at 6:56 PM, CARL Philippe (LBP) <[hidden email]> wrote: > > Dear all (probably Wayne), > In the case the Labels option is activated within the RoiManager, the Java method getSelectedIndexes() of the RoiManager class will then be returning the indexes of all the ROIs within the RoiManager and this independently whether they had been selected or not. > And when the Labels option is desactivated, the getSelectedIndexes() method is then working as expected. I am unable to reproduce this problem using the following JavaScript code: img = IJ.createImage("Untitled", "8-bit black", 400, 400, 1); img.show(); rm = RoiManager.getRoiManager(); rm.reset(); for (i=0; i<5; i++) { roi = OvalRoi.create(i*70, i*70, 70, 70); rm.addRoi(roi); } rm.setSelectedIndexes([2,4]); rm.runCommand(img,"Show All with labels"); indexes = rm.getSelectedIndexes(); for (i=0; i<indexes.length; i++) print(i+" "+indexes[i]); This is the output: 0 2 1 4 -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Wayne,
I come back concerning the issue I described lower. Would you have a suggestion on how I could proceed to locate the issue? What makes things even more difficult is that after having selected only one ROI within the ROI Manager and launching the following Javascript code: rm = RoiManager.getRoiManager(); indexes = rm.getSelectedIndexes(); for (i = 0; i < indexes.length; i++) print(i + " " + indexes[i]); The data of all the ROIs within the RoiManager will be printed out. But if I simply relaunch the the code a second time the rm.getSelectedIndexes() will then be working as expected. Or is the solution to simply add two lines: indexes = rm.getSelectedIndexes(); within my code? My best regards, Philippe ----- Mail original ----- De: "CARL Philippe, LBP" <[hidden email]> À: "imagej" <[hidden email]> Envoyé: Samedi 29 Août 2020 19:41:29 Objet: Re: Issue with the RoiManager getSelectedIndexes() method Dear Wayne, I fully validate your findings in the case I try to use your proposed javascript code. Nevertheless, I'm still able to reproduce my described issue in the case I generate a "more tricky version of it". And in order to do this, I first launch the following code: img = IJ.createImage("Untitled", "8-bit black", 400, 400, 1); img.show(); rm = RoiManager.getRoiManager(); for (i = 0; i < 5; i++) { roi = OvalRoi.create(i * 70, i * 70, 70, 70); rm.addRoi(roi); } rm.runCommand (img, "Show All with labels"); IJ.run (img, "Select None", ""); var indexesOfSelectedRoisAsArray = new Array(); for (i = 0; i < rm.getCount(); i++) indexesOfSelectedRoisAsArray[i] = i; rm.setSelectedIndexes(indexesOfSelectedRoisAsArray); Then when I manually select even only one (gives the same by selecting 2, 3,...) ROI(s) within the RoiManager and launch the following (second) code: rm = RoiManager.getRoiManager(); indexes = rm.getSelectedIndexes(); for (i = 0; i < indexes.length; i++) print(i + " " + indexes[i]); The data of all the ROIs within the RoiManager will be printed out. Even pushing the "Deselect" button before launching the second code won't make the deal, but deactivating the "Labels" option will make it. At last, this issue only happens in the case you manually select the ROIs, i.e. by using your proposed "rm.setSelectedIndexes([2,4])" the code will be working as well as it should. I guess this may probably be a quite tricky bug, thus I thank you very much in advance for looking into it and wish you good luck! Have a nice evening and take care, Philippe ----- Le 29 Aoû 20, à 4:14, Wayne Rasband [hidden email] a écrit : > On Aug 28, 2020, at 6:56 PM, CARL Philippe (LBP) <[hidden email]> wrote: > > Dear all (probably Wayne), > In the case the Labels option is activated within the RoiManager, the Java method getSelectedIndexes() of the RoiManager class will then be returning the indexes of all the ROIs within the RoiManager and this independently whether they had been selected or not. > And when the Labels option is desactivated, the getSelectedIndexes() method is then working as expected. I am unable to reproduce this problem using the following JavaScript code: img = IJ.createImage("Untitled", "8-bit black", 400, 400, 1); img.show(); rm = RoiManager.getRoiManager(); rm.reset(); for (i=0; i<5; i++) { roi = OvalRoi.create(i*70, i*70, 70, 70); rm.addRoi(roi); } rm.setSelectedIndexes([2,4]); rm.runCommand(img,"Show All with labels"); indexes = rm.getSelectedIndexes(); for (i=0; i<indexes.length; i++) print(i+" "+indexes[i]); This is the output: 0 2 1 4 -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |