Hi everyone,
I'm programming in Imagej by using the macro recorder and built-in macro functions. I'm doing well, but reached a dead-end in on of my macros. The problem is that I can't select two ROIS I've stored in the ROI manager and keep them selected at the same time so I can operate with them (by doing an AND between them, for example). I have already tried (amongst others) the macro command "setKeyDown("shift")", but wouldn't work properly. I've 15 ROIS stored in a five image stack (but might be more in the future) and I should be able to do at least double-selections of ROIs that need not to be contiguous (i.e., its index difference may be greater than 1). Can anyone help me? Thank you very much in advance. **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en su caso los ficheros adjuntos, pueden contener información protegida para el uso exclusivo de su destinatario. Se prohíbe la distribución, reproducción o cualquier otro tipo de transmisión por parte de otra persona que no sea el destinatario. Si usted recibe por error este correo, se ruega comunicarlo al remitente y borrar el mensaje recibido. **CONFIDENTIALITY NOTICE** This email communication and any attachments may contain confidential and privileged information for the sole use of the designated recipient named above. Distribution, reproduction or any other use of this transmission by any party other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender and delete all copies. |
I really don't understand why the problem hasn't been fixed yet. Several posts have been made about the same problem that you are experiencing (including a post by me). What's also odd is that, from what I can tell, the multiple select capability used to work in an older version of imageJ.
Anyway, here are the only solutions that have been offered: 1) Hack with javascript. script = "manager = RoiManager.getInstance();\n" + "rois = manager.getRoisAsArray();\n" + "roi1 = new ShapeRoi(rois[" + j + "]);\n" + "roi2 = new ShapeRoi(rois[" + k + "]);\n" + "combined = roi1.and(roi2);\n" + "if (combined.getLength() != 0)\n" + "manager.addRoi(combined);\n"; eval("script", script); 2) Create a plugin and use Java libraries instead. I recommend option 2. I originally started making a program as a macro. It completely wasn't worth it. I thought I would save time by avoiding the low level details, but the macro language is very incomplete and even a little buggy. For example, even if you do implement the script hack, you will quickly find out that the script hack will not work in batch mode. I created a hack so that it would semi-work in batch mode....but it's really not worth the headache. Good luck!
|
In reply to this post by Soriano.Joaquim
Hi Joaquim,
Try: roiManager("Select", 0); setKeyDown("shift"); roiManager("Select", 1); This will select 2 ROI.You can add more ROI by duplicating the last 2 lines. Hope this solves your problem Kees ________________________________________ From: ImageJ Interest Group [[hidden email]] On Behalf Of Soriano.Joaquim [[hidden email]] Sent: 01 June 2011 16:28 To: [hidden email] Subject: multiple ROI selection in ROI manager Hi everyone, I'm programming in Imagej by using the macro recorder and built-in macro functions. I'm doing well, but reached a dead-end in on of my macros. The problem is that I can't select two ROIS I've stored in the ROI manager and keep them selected at the same time so I can operate with them (by doing an AND between them, for example). I have already tried (amongst others) the macro command "setKeyDown("shift")", but wouldn't work properly. I've 15 ROIS stored in a five image stack (but might be more in the future) and I should be able to do at least double-selections of ROIs that need not to be contiguous (i.e., its index difference may be greater than 1). Can anyone help me? Thank you very much in advance. **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en su caso los ficheros adjuntos, pueden contener información protegida para el uso exclusivo de su destinatario. Se prohíbe la distribución, reproducción o cualquier otro tipo de transmisión por parte de otra persona que no sea el destinatario. Si usted recibe por error este correo, se ruega comunicarlo al remitente y borrar el mensaje recibido. **CONFIDENTIALITY NOTICE** This email communication and any attachments may contain confidential and privileged information for the sole use of the designated recipient named above. Distribution, reproduction or any other use of this transmission by any party other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender and delete all copies. |
Thank you very much for your response, but I'm afraid it didn't work though.
I had already checked the "setKeyDown("shift")" command but it seems it doesn't work when using the roiManager (or mabe I do not know how to make it work). Does anyone has the same problem? Any other posible solution? Bests. -----Mensaje original----- De: ImageJ Interest Group en nombre de Straatman, Kees R. (Dr.) Enviado el: mié 01/06/2011 21:05 Para: [hidden email] Asunto: Re: multiple ROI selection in ROI manager Hi Joaquim, Try: roiManager("Select", 0); setKeyDown("shift"); roiManager("Select", 1); This will select 2 ROI.You can add more ROI by duplicating the last 2 lines. Hope this solves your problem Kees ________________________________________ From: ImageJ Interest Group [[hidden email]] On Behalf Of Soriano.Joaquim [[hidden email]] Sent: 01 June 2011 16:28 To: [hidden email] Subject: multiple ROI selection in ROI manager Hi everyone, I'm programming in Imagej by using the macro recorder and built-in macro functions. I'm doing well, but reached a dead-end in on of my macros. The problem is that I can't select two ROIS I've stored in the ROI manager and keep them selected at the same time so I can operate with them (by doing an AND between them, for example). I have already tried (amongst others) the macro command "setKeyDown("shift")", but wouldn't work properly. I've 15 ROIS stored in a five image stack (but might be more in the future) and I should be able to do at least double-selections of ROIs that need not to be contiguous (i.e., its index difference may be greater than 1). Can anyone help me? Thank you very much in advance. **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en su caso los ficheros adjuntos, pueden contener información protegida para el uso exclusivo de su destinatario. Se prohíbe la distribución, reproducción o cualquier otro tipo de transmisión por parte de otra persona que no sea el destinatario. Si usted recibe por error este correo, se ruega comunicarlo al remitente y borrar el mensaje recibido. **CONFIDENTIALITY NOTICE** This email communication and any attachments may contain confidential and privileged information for the sole use of the designated recipient named above. Distribution, reproduction or any other use of this transmission by any party other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender and delete all copies. **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en su caso los ficheros adjuntos, pueden contener información protegida para el uso exclusivo de su destinatario. Se prohíbe la distribución, reproducción o cualquier otro tipo de transmisión por parte de otra persona que no sea el destinatario. Si usted recibe por error este correo, se ruega comunicarlo al remitente y borrar el mensaje recibido. **CONFIDENTIALITY NOTICE** This email communication and any attachments may contain confidential and privileged information for the sole use of the designated recipient named above. Distribution, reproduction or any other use of this transmission by any party other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender and delete all copies. |
In reply to this post by Krs5
I have just realize what's going on.
When selecting a single ROI by using "roiManager("Select", 0);" the "0"-ROI is shown at your image and also at the roiManager (i.e. the title of the roi is highlighted in blue at the roiManager). Whenever you run something similar to: roiManager("Select", 0); setKeyDown("shift"); roiManager("Select", 1); The "0" and "1" ROIs are displayed at the same time on your image or stack. However, they are not activated at the roiManager (i.e. the title of both ROIs are not highlighted in blue, but only one of them). So when trying to operate whit them (doing an AND, for example), the roiManager will show you an error message("More than one item must be selected, or none"). So it seems that what I really need is being able to keep two ROIs activated at the same time at the roiManagerwhat (i.e. with both titles highlighted at the same time), so I can further operate with them. Does anyone know how to do so? Please remeber that in order to fully work, both rois should not need to be contiguous, I mean, I shoud be able to select roi 1 and 3 withouth having to select roi 2. Thanks!!! -----Mensaje original----- De: ImageJ Interest Group en nombre de Straatman, Kees R. (Dr.) Enviado el: mié 01/06/2011 21:05 Para: [hidden email] Asunto: Re: multiple ROI selection in ROI manager Hi Joaquim, Try: roiManager("Select", 0); setKeyDown("shift"); roiManager("Select", 1); This will select 2 ROI.You can add more ROI by duplicating the last 2 lines. Hope this solves your problem Kees ________________________________________ From: ImageJ Interest Group [[hidden email]] On Behalf Of Soriano.Joaquim [[hidden email]] Sent: 01 June 2011 16:28 To: [hidden email] Subject: multiple ROI selection in ROI manager Hi everyone, I'm programming in Imagej by using the macro recorder and built-in macro functions. I'm doing well, but reached a dead-end in on of my macros. The problem is that I can't select two ROIS I've stored in the ROI manager and keep them selected at the same time so I can operate with them (by doing an AND between them, for example). I have already tried (amongst others) the macro command "setKeyDown("shift")", but wouldn't work properly. I've 15 ROIS stored in a five image stack (but might be more in the future) and I should be able to do at least double-selections of ROIs that need not to be contiguous (i.e., its index difference may be greater than 1). Can anyone help me? Thank you very much in advance. **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en su caso los ficheros adjuntos, pueden contener información protegida para el uso exclusivo de su destinatario. Se prohíbe la distribución, reproducción o cualquier otro tipo de transmisión por parte de otra persona que no sea el destinatario. Si usted recibe por error este correo, se ruega comunicarlo al remitente y borrar el mensaje recibido. **CONFIDENTIALITY NOTICE** This email communication and any attachments may contain confidential and privileged information for the sole use of the designated recipient named above. Distribution, reproduction or any other use of this transmission by any party other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender and delete all copies. **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en su caso los ficheros adjuntos, pueden contener información protegida para el uso exclusivo de su destinatario. Se prohíbe la distribución, reproducción o cualquier otro tipo de transmisión por parte de otra persona que no sea el destinatario. Si usted recibe por error este correo, se ruega comunicarlo al remitente y borrar el mensaje recibido. **CONFIDENTIALITY NOTICE** This email communication and any attachments may contain confidential and privileged information for the sole use of the designated recipient named above. Distribution, reproduction or any other use of this transmission by any party other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender and delete all copies. |
In reply to this post by Soriano.Joaquim
2011/6/1 Soriano.Joaquim <[hidden email]>:
> Thank you very much for your response, but I'm afraid it didn't work though. > I had already checked the "setKeyDown("shift")" command but it seems it doesn't work when using the roiManager (or mabe I do not know how to make it work). > Does anyone has the same problem? > Any other posible solution? > Bests. I understand you are now heavily invested into your macro. In my experience, long macros get complex very fast and at some point one hits the wall like you did now. I suggest rewriting it in a programming language like python: http://pacific.mpi-cbg.de/wiki/index.php/Jython_Scripting ... in which querying the RoiManager for its lists of ROIs is possible: http://pacific.mpi-cbg.de/wiki/index.php/Jython_Scripting#..._and_counting_particles.2C_and_measuring_their_areas ... and in which the entire ImageJ API is available. For example, to merge two ROIs: roi1 = ... roi2 = ... merged = ShapeRoi(roi1).or(roi2) See: http://rsb.info.nih.gov/ij/developer/api/ij/gui/ShapeRoi.html#or(ij.gui.ShapeRoi) Best, Albert -- http://albert.rierol.net http://www.ini.uzh.ch/~acardona/ |
In reply to this post by Soriano.Joaquim
On Jun 1, 2011, at 11:28 AM, Soriano.Joaquim wrote:
> Hi everyone, > I'm programming in Imagej by using the macro recorder and built-in macro functions. > I'm doing well, but reached a dead-end in on of my macros. > The problem is that I can't select two ROIS I've stored in the ROI manager and keep them selected at the same time so I can operate with them (by doing an AND between them, for example). > I have already tried (amongst others) the macro command "setKeyDown("shift")", but wouldn't work properly. > I've 15 ROIS stored in a five image stack (but might be more in the future) and I should be able to do at least double-selections of ROIs that need not to be contiguous (i.e., its index difference may be greater than 1). You can select multiple ROIs in the 1.45i daily build, which extends roiManager("select", index) to accept an array of indexes as the second argument. Here is an example macro that ANDs the first, third and fifth ROIs in the ROI Manager: roiManager("select", newArray(0,2,4)); roiManager("AND"); In JavaScript, it looks like: rm = RoiManager.getInstance(); rm.setSelectedIndexes([0,2,4]); rm.runCommand("AND"); Note that the selected ROIs are not highlighted in the ROI Manager list and roiManager("select", indexes), must be called just be before each command. -wayne |
It works perfectly!!!
Thank you very much!!! Thanks also to all people who bother to answer my mail!!! -----Mensaje original----- De: ImageJ Interest Group en nombre de Rasband, Wayne (NIH/NIMH) [E] Enviado el: jue 02/06/2011 6:09 Para: [hidden email] Asunto: Re: multiple ROI selection in ROI manager On Jun 1, 2011, at 11:28 AM, Soriano.Joaquim wrote: > Hi everyone, > I'm programming in Imagej by using the macro recorder and built-in macro functions. > I'm doing well, but reached a dead-end in on of my macros. > The problem is that I can't select two ROIS I've stored in the ROI manager and keep them selected at the same time so I can operate with them (by doing an AND between them, for example). > I have already tried (amongst others) the macro command "setKeyDown("shift")", but wouldn't work properly. > I've 15 ROIS stored in a five image stack (but might be more in the future) and I should be able to do at least double-selections of ROIs that need not to be contiguous (i.e., its index difference may be greater than 1). You can select multiple ROIs in the 1.45i daily build, which extends roiManager("select", index) to accept an array of indexes as the second argument. Here is an example macro that ANDs the first, third and fifth ROIs in the ROI Manager: roiManager("select", newArray(0,2,4)); roiManager("AND"); In JavaScript, it looks like: rm = RoiManager.getInstance(); rm.setSelectedIndexes([0,2,4]); rm.runCommand("AND"); Note that the selected ROIs are not highlighted in the ROI Manager list and roiManager("select", indexes), must be called just be before each command. -wayne **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en su caso los ficheros adjuntos, pueden contener información protegida para el uso exclusivo de su destinatario. Se prohíbe la distribución, reproducción o cualquier otro tipo de transmisión por parte de otra persona que no sea el destinatario. Si usted recibe por error este correo, se ruega comunicarlo al remitente y borrar el mensaje recibido. **CONFIDENTIALITY NOTICE** This email communication and any attachments may contain confidential and privileged information for the sole use of the designated recipient named above. Distribution, reproduction or any other use of this transmission by any party other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender and delete all copies. |
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
-----Mensaje original-----
De: ImageJ Interest Group en nombre de Rasband, Wayne (NIH/NIMH) [E] Enviado el: jue 02/06/2011 6:09 Para: [hidden email] Asunto: Re: multiple ROI selection in ROI manager On Jun 1, 2011, at 11:28 AM, Soriano.Joaquim wrote: > Hi everyone, > I'm programming in Imagej by using the macro recorder and built-in macro functions. > I'm doing well, but reached a dead-end in on of my macros. > The problem is that I can't select two ROIS I've stored in the ROI manager and keep them selected at the same time so I can operate with them (by doing an AND between them, for example). Hi! I've been trying the new roiManager("select", index) command in depth and I got to a extrange feature. This command does not work when executed inside brackets ({}), i.e. in either conditional statements, loops or as a part of a function. In such case the error: ',' expected in line 3. {roiManager("select", <newArray>(0,2));} is shown. Anybody knows what's going on??? > I have already tried (amongst others) the macro command "setKeyDown("shift")", but wouldn't work properly. > I've 15 ROIS stored in a five image stack (but might be more in the future) and I should be able to do at least double-selections of ROIs that need not to be contiguous (i.e., its index difference may be greater than 1). You can select multiple ROIs in the 1.45i daily build, which extends roiManager("select", index) to accept an array of indexes as the second argument. Here is an example macro that ANDs the first, third and fifth ROIs in the ROI Manager: roiManager("select", newArray(0,2,4)); roiManager("AND"); In JavaScript, it looks like: rm = RoiManager.getInstance(); rm.setSelectedIndexes([0,2,4]); rm.runCommand("AND"); Note that the selected ROIs are not highlighted in the ROI Manager list and roiManager("select", indexes), must be called just be before each command. -wayne **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en su caso los ficheros adjuntos, pueden contener información protegida para el uso exclusivo de su destinatario. Se prohíbe la distribución, reproducción o cualquier otro tipo de transmisión por parte de otra persona que no sea el destinatario. Si usted recibe por error este correo, se ruega comunicarlo al remitente y borrar el mensaje recibido. **CONFIDENTIALITY NOTICE** This email communication and any attachments may contain confidential and privileged information for the sole use of the designated recipient named above. Distribution, reproduction or any other use of this transmission by any party other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender and delete all copies. |
On Jun 2, 2011, at 12:44 PM, Soriano.Joaquim wrote:
> On Jun 1, 2011, at 11:28 AM, Soriano.Joaquim wrote: > >> Hi everyone, >> I'm programming in Imagej by using the macro recorder and built-in macro functions. >> I'm doing well, but reached a dead-end in on of my macros. >> The problem is that I can't select two ROIS I've stored in the ROI manager and keep them selected at the same time so I can operate with them (by doing an AND between them, for example). > Hi! > I've been trying the new roiManager("select", index) command in depth and I got to a extrange feature. > This command does not work when executed inside brackets ({}), i.e. in either conditional statements, loops or as a part of a function. In such case the error: > ',' expected in line 3. > {roiManager("select", <newArray>(0,2));} > is shown. > Anybody knows what's going on??? This bug is fixed in the 1.45i17 daily build. -wayne > >> I have already tried (amongst others) the macro command "setKeyDown("shift")", but wouldn't work properly. >> I've 15 ROIS stored in a five image stack (but might be more in the future) and I should be able to do at least double-selections of ROIs that need not to be contiguous (i.e., its index difference may be greater than 1). > > You can select multiple ROIs in the 1.45i daily build, which extends roiManager("select", index) to accept an array of indexes as the second argument. Here is an example macro that ANDs the first, third and fifth ROIs in the ROI Manager: > > roiManager("select", newArray(0,2,4)); > roiManager("AND"); > > In JavaScript, it looks like: > > rm = RoiManager.getInstance(); > rm.setSelectedIndexes([0,2,4]); > rm.runCommand("AND"); > > Note that the selected ROIs are not highlighted in the ROI Manager list and roiManager("select", indexes), must be called just be before each command. > > -wayne > > > **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en su caso los ficheros adjuntos, pueden contener información protegida para el uso exclusivo de su destinatario. Se prohíbe la distribución, reproducción o cualquier otro tipo de transmisión por parte de otra persona que no sea el destinatario. Si usted recibe por error este correo, se ruega comunicarlo al remitente y borrar el mensaje recibido. > **CONFIDENTIALITY NOTICE** This email communication and any attachments may contain confidential and privileged information for the sole use of the designated recipient named above. Distribution, reproduction or any other use of this transmission by any party other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender and delete all copies. |
Free forum by Nabble | Edit this page |