Hi all,
I'm trying to figure out the ways to query if a selection is say an oval, rectangle or composite in a macro? I know i can do ROIManager>More>List to find out what Type each selection is but is the only way to extract this info through renaming the overlay elements table to "Results" then using getResultString on the Type column? If it is a composite i will then split this selection so i can process each area separately. But perhaps there is an alternative for what i want to do. I want to mark several selections on an image and add them to the manager using a tool that has a defined initial size but can be expanded freehand if necessary by left clicking and moving the mouse hence using the selection brush but the issue with it is it can produce composite or a single selection depending on if the user holds the shift key or not. So if the user has pressed shift i need to know that the selection is a composite and then split into separate selections for processing. If they have not held shift then the selection will be just one single marked area but the macro doesn't know which they've done unless i extract the overlay elements info. A paintbrush type tool which allows you to add multiple separate selections to the ROI manager would be useful if it doesn't somehow exist already? Thanks for the advice, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Matt,
the answer to your first question is easy and again can be found here: <https://imagej.nih.gov/ij/developer/macro/functions.html> or more specifically here: <https://imagej.nih.gov/ij/developer/macro/functions.html#selectionType> "selectionType() Returns the selection type, where 0=rectangle, 1=oval, 2=polygon, 3=freehand, 4=traced, 5=straight line, 6=segmented line, 7=freehand line, 8=angle, 9=composite and 10=point. Returns -1 if there is no selection. For an example, see the ShowImageInfo macro. " With regard to the previous and continuing question I really should like to know why you are so concentrated on overlays and the paintbrush tool. Why not, in the first place use selections? Best Herbie ::::::::::::::::::::::::::::::::::::::::::::: Am 07.12.16 um 16:22 schrieb PEARSON Matthew: > Hi all, > > I'm trying to figure out the ways to query if a selection is say an > oval, rectangle or composite in a macro? I know i can do > ROIManager>More>List to find out what Type each selection is but is > the only way to extract this info through renaming the overlay > elements table to "Results" then using getResultString on the Type > column? If it is a composite i will then split this selection so i > can process each area separately. > > But perhaps there is an alternative for what i want to do. I want to > mark several selections on an image and add them to the manager using > a tool that has a defined initial size but can be expanded freehand > if necessary by left clicking and moving the mouse hence using the > selection brush but the issue with it is it can produce composite or > a single selection depending on if the user holds the shift key or > not. So if the user has pressed shift i need to know that the > selection is a composite and then split into separate selections for > processing. If they have not held shift then the selection will be > just one single marked area but the macro doesn't know which they've > done unless i extract the overlay elements info. > > A paintbrush type tool which allows you to add multiple separate > selections to the ROI manager would be useful if it doesn't somehow > exist already? > > Thanks for the advice, > > Matt > > > -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute > of Genetics and Molecular Medicine (IGMM) University of Edinburgh > Crewe Road EH4 2XU > > > > > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by PEARSON Matthew
Hi all,
I think i have cracked my problem with the selection brush and in fact realise i'd asked a similar question a couple of years ago but then didn't pursue the idea. I can now get the selection brush to create selections around the image but the work flow for doing this seems a little strange. These are the steps that work for me: 1.) Left click on the image to create a circular selection with the selection brush 2.) Left click again anywhere on the image but not on the circular selection 3.) Press the b key (adds the first selection to the overlay i believe) 4.) I can now left click and add another circular selection on the image 5.) Repeat above for all selections then 5.) Image>Overlay>To ROI Manager (adds all the overlays as separate roi's) I'm not sure why i have to do step 2.) before i press b. Its not a big deal but would be good if you could just left click on the next area, perhaps there is good reason for this. Thanks, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU On 7 Dec 2016, at 15:22, PEARSON Matthew <[hidden email]<mailto:[hidden email]>> wrote: Hi all, I'm trying to figure out the ways to query if a selection is say an oval, rectangle or composite in a macro? I know i can do ROIManager>More>List to find out what Type each selection is but is the only way to extract this info through renaming the overlay elements table to "Results" then using getResultString on the Type column? If it is a composite i will then split this selection so i can process each area separately. But perhaps there is an alternative for what i want to do. I want to mark several selections on an image and add them to the manager using a tool that has a defined initial size but can be expanded freehand if necessary by left clicking and moving the mouse hence using the selection brush but the issue with it is it can produce composite or a single selection depending on if the user holds the shift key or not. So if the user has pressed shift i need to know that the selection is a composite and then split into separate selections for processing. If they have not held shift then the selection will be just one single marked area but the macro doesn't know which they've done unless i extract the overlay elements info. A paintbrush type tool which allows you to add multiple separate selections to the ROI manager would be useful if it doesn't somehow exist already? Thanks for the advice, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Matt,
I am not sure why you first add your selection to the overlay and then transfer it to the ROI manager. Whenever I have done things like this in the past, I simply added the selection directly to the ROI manager. This can be achieved by pressing ctrl-t. If you want to know/see whether a certain region has already been selected, just activate the show all option in the ROI manager to see the content of the ROI manager overlayed on the image. Hope this helps, Volko -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of PEARSON Matthew Sent: 08 December 2016 09:15 To: [hidden email] Subject: Re: Selection brush tool usage Hi all, I think i have cracked my problem with the selection brush and in fact realise i'd asked a similar question a couple of years ago but then didn't pursue the idea. I can now get the selection brush to create selections around the image but the work flow for doing this seems a little strange. These are the steps that work for me: 1.) Left click on the image to create a circular selection with the selection brush 2.) Left click again anywhere on the image but not on the circular selection 3.) Press the b key (adds the first selection to the overlay i believe) 4.) I can now left click and add another circular selection on the image 5.) Repeat above for all selections then 5.) Image>Overlay>To ROI Manager (adds all the overlays as separate roi's) I'm not sure why i have to do step 2.) before i press b. Its not a big deal but would be good if you could just left click on the next area, perhaps there is good reason for this. Thanks, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU On 7 Dec 2016, at 15:22, PEARSON Matthew <[hidden email]<mailto:[hidden email]>> wrote: Hi all, I'm trying to figure out the ways to query if a selection is say an oval, rectangle or composite in a macro? I know i can do ROIManager>More>List to find out what Type each selection is but is the only way to extract this info through renaming the overlay elements table to "Results" then using getResultString on the Type column? If it is a composite i will then split this selection so i can process each area separately. But perhaps there is an alternative for what i want to do. I want to mark several selections on an image and add them to the manager using a tool that has a defined initial size but can be expanded freehand if necessary by left clicking and moving the mouse hence using the selection brush but the issue with it is it can produce composite or a single selection depending on if the user holds the shift key or not. So if the user has pressed shift i need to know that the selection is a composite and then split into separate selections for processing. If they have not held shift then the selection will be just one single marked area but the macro doesn't know which they've done unless i extract the overlay elements info. A paintbrush type tool which allows you to add multiple separate selections to the ROI manager would be useful if it doesn't somehow exist already? Thanks for the advice, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- 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 |
In reply to this post by PEARSON Matthew
Hi Matt,
according to my understanding, the selection brush is mainly meant as a 'repair selection' brush. If there is no selection, it creates one. If there is a selection: If you start brushing outside the current selection, it is in 'remove from selection' mode, and you can use it to remove a few pixels from the margin of the selection (because the selection was a bit too large). If you start inside the current selection, it adds to the selection, e.g. if you want to extend the borders a bit. You can force the behavior with the SHIFT (add) and ALT (subtract) modifier keys. I am not aware of a possibility to have the selection brush delete the old selection and create a new one. So you can create a selection, press 'b' and then deselect all (shift-A). Then add a new brush point. For convenience, you could have the 'add to overlay' and 'deselect' in a macro with a shortcut. Alternatively, use the Overlay brush. Michael _______________________________________________________________________________ On 2016-12-08 10:15, PEARSON Matthew wrote: > Hi all, > > I think i have cracked my problem with the selection brush and in fact > realise i'd asked a similar question a couple of years ago but then > didn't pursue the idea. I can now get the selection brush to create > selections around the image but the work flow for doing this seems a > little strange. These are the steps that work for me: > > 1.) Left click on the image to create a circular selection with the > selection brush > 2.) Left click again anywhere on the image but not on the circular > selection > 3.) Press the b key (adds the first selection to the overlay i believe) > 4.) I can now left click and add another circular selection on the > image > 5.) Repeat above for all selections then > 5.) Image>Overlay>To ROI Manager (adds all the overlays as separate > roi's) > > I'm not sure why i have to do step 2.) before i press b. Its not a > big deal but would be good if you could just left click on the next > area, perhaps there is good reason for this. > > Thanks, > > Matt > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Michael,
Sorry for the delay in replying to you, i have the imagej posts filtering into a separate folder in my email client but sometimes they go straight to my main inbox instead and i don't seem to be able to keep track of both locations at the same time! I had one from Wayne hiding there too and have apologised to him. You raised some good points here so glad i found your email in the end! The key aspect for me is this: So you can create a selection, press 'b' and then deselect all (shift-A). I wasn't expecting to have to press shift-A to allow the selection brush to paint a new selection elsewhere. What i have been doing is adding a selection but ensuring that it is not just a single click but i click and hold and paint an area larger than the width of the selection brush itself, then when i press b the selection brush isn't in repair mode and i can paint a new selection elsewhere. But i like your suggestion of making a shortcut key to add the overlay and select none. Is there anyway to make this work without having to install this mini macro or adding to the startup macros, i.e. initialise it within my analysis macro somehow? The only reason i ask is because anyone using my macro would possibly do it on their own computer so they would have to make sure they had the shortcut macro setup before running. I'm guessing the macro would look something like below: macro "Add Overlay [o]" { run("Add Selection…"); run("Select None"); } Thanks, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU On 8 Dec 2016, at 18:10, Michael Schmid <[hidden email]<mailto:[hidden email]>> wrote: Hi Matt, according to my understanding, the selection brush is mainly meant as a 'repair selection' brush. If there is no selection, it creates one. If there is a selection: If you start brushing outside the current selection, it is in 'remove from selection' mode, and you can use it to remove a few pixels from the margin of the selection (because the selection was a bit too large). If you start inside the current selection, it adds to the selection, e.g. if you want to extend the borders a bit. You can force the behavior with the SHIFT (add) and ALT (subtract) modifier keys. I am not aware of a possibility to have the selection brush delete the old selection and create a new one. So you can create a selection, press 'b' and then deselect all (shift-A). Then add a new brush point. For convenience, you could have the 'add to overlay' and 'deselect' in a macro with a shortcut. Alternatively, use the Overlay brush. Michael _______________________________________________________________________________ On 2016-12-08 10:15, PEARSON Matthew wrote: Hi all, I think i have cracked my problem with the selection brush and in fact realise i'd asked a similar question a couple of years ago but then didn't pursue the idea. I can now get the selection brush to create selections around the image but the work flow for doing this seems a little strange. These are the steps that work for me: 1.) Left click on the image to create a circular selection with the selection brush 2.) Left click again anywhere on the image but not on the circular selection 3.) Press the b key (adds the first selection to the overlay i believe) 4.) I can now left click and add another circular selection on the image 5.) Repeat above for all selections then 5.) Image>Overlay>To ROI Manager (adds all the overlays as separate roi's) I'm not sure why i have to do step 2.) before i press b. Its not a big deal but would be good if you could just left click on the next area, perhaps there is good reason for this. Thanks, Matt -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Matt,
you can have your macro create a file with a short macro and install that macro from the file: str = 'macro "Add Overlay [o]" {\n' str = str + 'run("Add Selection...");\n'; str = str + 'run("Select None");\n}'; path=getDirectory("imagej")+"/macros/addOverlay.ijm"; File.saveString(str, path); run("Install...", "install=["+path+"]"); Note that I am using single quotes to create the string; the ImageJ macro language accepts both single and double quotes. Using single quotes, there is no problem of having to escape the double quotes that occur in the String. Michael ________________________________________________________________ On 2016-12-15 13:19, PEARSON Matthew wrote: > Hi Michael, > > Sorry for the delay in replying to you, i have the imagej posts > filtering into a separate folder in my email client but sometimes > they go straight to my main inbox instead and i don't seem to be able > to keep track of both locations at the same time! I had one from > Wayne hiding there too and have apologised to him. > > You raised some good points here so glad i found your email in the > end! The key aspect for me is this: So you can create a selection, > press 'b' and then deselect all (shift-A). I wasn't expecting to have > to press shift-A to allow the selection brush to paint a new > selection elsewhere. What i have been doing is adding a selection > but ensuring that it is not just a single click but i click and hold > and paint an area larger than the width of the selection brush > itself, then when i press b the selection brush isn't in repair mode > and i can paint a new selection elsewhere. But i like your > suggestion of making a shortcut key to add the overlay and select > none. Is there anyway to make this work without having to install > this mini macro or adding to the startup macros, i.e. initialise it > within my analysis macro somehow? The only reason i ask is because > anyone using my macro would possibly do it on their own computer so > they would have to make sure they had the shortcut macro setup before > running. > > I'm guessing the macro would look something like below: macro "Add > Overlay [o]" { run("Add Selection…"); run("Select None"); } > > Thanks, > > Matt > > -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute > of Genetics and Molecular Medicine (IGMM) University of Edinburgh > Crewe Road EH4 2XU > > > > > On 8 Dec 2016, at 18:10, Michael Schmid > <[hidden email]<mailto:[hidden email]>> wrote: > > Hi Matt, > > according to my understanding, the selection brush is mainly meant as > a 'repair selection' brush. If there is no selection, it creates > one. If there is a selection: If you start brushing outside the > current selection, it is in 'remove from selection' mode, and you can > use it to remove a few pixels from the margin of the selection > (because the selection was a bit too large). If you start inside the > current selection, it adds to the selection, e.g. if you want to > extend the borders a bit. You can force the behavior with the SHIFT > (add) and ALT (subtract) modifier keys. I am not aware of a > possibility to have the selection brush delete the old selection and > create a new one. > > So you can create a selection, press 'b' and then deselect all > (shift-A). Then add a new brush point. For convenience, you could > have the 'add to overlay' and 'deselect' in a macro with a shortcut. > > Alternatively, use the Overlay brush. > > Michael > > _______________________________________________________________________________ > > On 2016-12-08 10:15, PEARSON Matthew wrote: Hi all, I think i have > cracked my problem with the selection brush and in fact realise i'd > asked a similar question a couple of years ago but then didn't pursue > the idea. I can now get the selection brush to create selections > around the image but the work flow for doing this seems a little > strange. These are the steps that work for me: 1.) Left click on the > image to create a circular selection with the selection brush 2.) > Left click again anywhere on the image but not on the circular > selection 3.) Press the b key (adds the first selection to the > overlay i believe) 4.) I can now left click and add another circular > selection on the image 5.) Repeat above for all selections then 5.) > Image>Overlay>To ROI Manager (adds all the overlays as separate > roi's) I'm not sure why i have to do step 2.) before i press b. Its > not a big deal but would be good if you could just left click on the > next area, perhaps there is good reason for this. Thanks, Matt > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Michael,
That's great! Works like a dream. Thanks again, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU On 15 Dec 2016, at 13:33, Michael Schmid <[hidden email]<mailto:[hidden email]>> wrote: Hi Matt, you can have your macro create a file with a short macro and install that macro from the file: str = 'macro "Add Overlay [o]" {\n' str = str + 'run("Add Selection...");\n'; str = str + 'run("Select None");\n}'; path=getDirectory("imagej")+"/macros/addOverlay.ijm"; File.saveString(str, path); run("Install...", "install=["+path+"]"); Note that I am using single quotes to create the string; the ImageJ macro language accepts both single and double quotes. Using single quotes, there is no problem of having to escape the double quotes that occur in the String. Michael ________________________________________________________________ On 2016-12-15 13:19, PEARSON Matthew wrote: Hi Michael, Sorry for the delay in replying to you, i have the imagej posts filtering into a separate folder in my email client but sometimes they go straight to my main inbox instead and i don't seem to be able to keep track of both locations at the same time! I had one from Wayne hiding there too and have apologised to him. You raised some good points here so glad i found your email in the end! The key aspect for me is this: So you can create a selection, press 'b' and then deselect all (shift-A). I wasn't expecting to have to press shift-A to allow the selection brush to paint a new selection elsewhere. What i have been doing is adding a selection but ensuring that it is not just a single click but i click and hold and paint an area larger than the width of the selection brush itself, then when i press b the selection brush isn't in repair mode and i can paint a new selection elsewhere. But i like your suggestion of making a shortcut key to add the overlay and select none. Is there anyway to make this work without having to install this mini macro or adding to the startup macros, i.e. initialise it within my analysis macro somehow? The only reason i ask is because anyone using my macro would possibly do it on their own computer so they would have to make sure they had the shortcut macro setup before running. I'm guessing the macro would look something like below: macro "Add Overlay [o]" { run("Add Selection…"); run("Select None"); } Thanks, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU On 8 Dec 2016, at 18:10, Michael Schmid <[hidden email]<mailto:[hidden email]><mailto:[hidden email]>> wrote: Hi Matt, according to my understanding, the selection brush is mainly meant as a 'repair selection' brush. If there is no selection, it creates one. If there is a selection: If you start brushing outside the current selection, it is in 'remove from selection' mode, and you can use it to remove a few pixels from the margin of the selection (because the selection was a bit too large). If you start inside the current selection, it adds to the selection, e.g. if you want to extend the borders a bit. You can force the behavior with the SHIFT (add) and ALT (subtract) modifier keys. I am not aware of a possibility to have the selection brush delete the old selection and create a new one. So you can create a selection, press 'b' and then deselect all (shift-A). Then add a new brush point. For convenience, you could have the 'add to overlay' and 'deselect' in a macro with a shortcut. Alternatively, use the Overlay brush. Michael _______________________________________________________________________________ On 2016-12-08 10:15, PEARSON Matthew wrote: Hi all, I think i have cracked my problem with the selection brush and in fact realise i'd asked a similar question a couple of years ago but then didn't pursue the idea. I can now get the selection brush to create selections around the image but the work flow for doing this seems a little strange. These are the steps that work for me: 1.) Left click on the image to create a circular selection with the selection brush 2.) Left click again anywhere on the image but not on the circular selection 3.) Press the b key (adds the first selection to the overlay i believe) 4.) I can now left click and add another circular selection on the image 5.) Repeat above for all selections then 5.) Image>Overlay>To ROI Manager (adds all the overlays as separate roi's) I'm not sure why i have to do step 2.) before i press b. Its not a big deal but would be good if you could just left click on the next area, perhaps there is good reason for this. Thanks, Matt -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- 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 |
Free forum by Nabble | Edit this page |