Dear All,
For one of my small macro projects in counting I need to generate random points in a stack and use Multi-point tool to count them. I need two variants: 1) each stack slice contains its own points; 2) all slices contain the same set of points - points on the first slice are seen through all of them. I have tried 2 methods: makePoint() and makeSelection(). Both are not good enough. makePoint allows to change properties of points and works well with Multi-point Tool but creates only the 1st variant (separate set for each slice). makeSelection creates the 2nd variant but does not allow to change point properties (color, size etc.) and does not work very well with Multi-point Tool. Are there workarounds for that? I do not see Overlay options for points (like Overlay.drawLine that I have used in my precious macros successfully). Example macros are attached. -- Sincerely, Alex macro1--------------------- run("MRI Stack (528K)"); getDimensions(width, height, channels, slices, frames); PntNumber = 5; for (i=0; i<PntNumber; i++) { x = round(random*(width-1)); y = round(random*(height-1)); makePoint(x, y, "small red cross add"); }; -------------------------- macro2------------------- run("MRI Stack (528K)"); getDimensions(width, height, channels, slices, frames); PntNumber = 5; for (i=0; i<PntNumber; i++) { x = newArray(PntNumber); y = newArray(PntNumber); for (i=0; i<x.length; i++) { x[i] = round(random*(width-1)); } for (i=0; i<x.length; i++) { y[i] = round(random*(height-1)); } makeSelection("point", x, y); }; -------------------- -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
> On Nov 5, 2018, at 10:29 AM, Aleksandr Mironov <[hidden email]> wrote:
> > Dear All, > For one of my small macro projects in counting I need to generate random points in a stack and use Multi-point tool to count them. I need two variants: 1) each stack slice contains its own points; 2) all slices contain the same set of points - points on the first slice are seen through all of them. I have tried 2 methods: makePoint() and makeSelection(). Both are not good enough. makePoint allows to change properties of points and works well with Multi-point Tool but creates only the 1st variant (separate set for each slice). Points created by makePoint() will appear in all slices if you set the positions to 0, as in this example: run("MRI Stack (528K)"); getDimensions(width, height, channels, slices, frames); PntNumber = 5; for (i=0; i<PntNumber; i++) { x = round(random*(width-1)); y = round(random*(height-1)); makePoint(x, y, "large cyan cross add"); Overlay.setPosition(0); }; > makeSelection creates the 2nd variant but does not allow to change point properties (color, size etc.) and does not work very well with Multi-point Tool. You can set point properties (color, size etc.) with makeSelection() in the same way as makePoint(), as in this example: run("MRI Stack (528K)"); getDimensions(width, height, channels, slices, frames); PntNumber = 5; for (i=0; i<PntNumber; i++) { x = newArray(PntNumber); y = newArray(PntNumber); for (i=0; i<x.length; i++) x[i] = round(random*(width-1)); for (i=0; i<x.length; i++) y[i] = round(random*(height-1)); makeSelection("large cyan cross points", x, y); } -wayne > Are there workarounds for that? I do not see Overlay options for points (like Overlay.drawLine that I have used in my precious macros successfully). > Example macros are attached. > > -- > Sincerely, > Alex > > > macro1--------------------- > run("MRI Stack (528K)"); > getDimensions(width, height, channels, slices, frames); > PntNumber = 5; > for (i=0; i<PntNumber; i++) { > x = round(random*(width-1)); > y = round(random*(height-1)); > makePoint(x, y, "small red cross add"); > }; > -------------------------- > > macro2------------------- > > run("MRI Stack (528K)"); > getDimensions(width, height, channels, slices, frames); > PntNumber = 5; > for (i=0; i<PntNumber; i++) { > x = newArray(PntNumber); > y = newArray(PntNumber); > for (i=0; i<x.length; i++) { > x[i] = round(random*(width-1)); > } > for (i=0; i<x.length; i++) { > y[i] = round(random*(height-1)); > } > makeSelection("point", x, y); > }; -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thank you Wayne!
Sincerely, Alex On 06/11/2018 05:21, Wayne Rasband wrote: >> On Nov 5, 2018, at 10:29 AM, Aleksandr Mironov <[hidden email]> wrote: >> >> Dear All, >> For one of my small macro projects in counting I need to generate random points in a stack and use Multi-point tool to count them. I need two variants: 1) each stack slice contains its own points; 2) all slices contain the same set of points - points on the first slice are seen through all of them. I have tried 2 methods: makePoint() and makeSelection(). Both are not good enough. makePoint allows to change properties of points and works well with Multi-point Tool but creates only the 1st variant (separate set for each slice). > Points created by makePoint() will appear in all slices if you set the positions to 0, as in this example: > > run("MRI Stack (528K)"); > getDimensions(width, height, channels, slices, frames); > PntNumber = 5; > for (i=0; i<PntNumber; i++) { > x = round(random*(width-1)); > y = round(random*(height-1)); > makePoint(x, y, "large cyan cross add"); > Overlay.setPosition(0); > }; > >> makeSelection creates the 2nd variant but does not allow to change point properties (color, size etc.) and does not work very well with Multi-point Tool. > You can set point properties (color, size etc.) with makeSelection() in the same way as makePoint(), as in this example: > > run("MRI Stack (528K)"); > getDimensions(width, height, channels, slices, frames); > PntNumber = 5; > for (i=0; i<PntNumber; i++) { > x = newArray(PntNumber); > y = newArray(PntNumber); > for (i=0; i<x.length; i++) > x[i] = round(random*(width-1)); > for (i=0; i<x.length; i++) > y[i] = round(random*(height-1)); > makeSelection("large cyan cross points", x, y); > } > > -wayne > > >> Are there workarounds for that? I do not see Overlay options for points (like Overlay.drawLine that I have used in my precious macros successfully). >> Example macros are attached. >> >> -- >> Sincerely, >> Alex >> >> >> macro1--------------------- >> run("MRI Stack (528K)"); >> getDimensions(width, height, channels, slices, frames); >> PntNumber = 5; >> for (i=0; i<PntNumber; i++) { >> x = round(random*(width-1)); >> y = round(random*(height-1)); >> makePoint(x, y, "small red cross add"); >> }; >> -------------------------- >> >> macro2------------------- >> >> run("MRI Stack (528K)"); >> getDimensions(width, height, channels, slices, frames); >> PntNumber = 5; >> for (i=0; i<PntNumber; i++) { >> x = newArray(PntNumber); >> y = newArray(PntNumber); >> for (i=0; i<x.length; i++) { >> x[i] = round(random*(width-1)); >> } >> for (i=0; i<x.length; i++) { >> y[i] = round(random*(height-1)); >> } >> makeSelection("point", x, y); >> }; > -- > 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 Wayne Rasband-2
These are very useful additions to selections. Thank you for adding them.
Are there other great functionalities we are missing? Unfortunately, these (the setting to zero and other options) aren't documented at https://imagej.nih.gov/ij/developer/macro/functions.html or https://imagej.nih.gov/ij/macros/MakeSelectionDemo.txt Best regards- Michael Cammer, Sr Research Scientist, DART Microscopy Laboratory NYU Langone Health, 540 First Avenue, SK2 Microscopy Suite, New York, NY 10016 C: 914-309-3270 [hidden email] http://nyulmc.org/micros http://microscopynotes.com/ -----Original Message----- From: Wayne Rasband <[hidden email]> Sent: Tuesday, November 6, 2018 12:21 AM To: [hidden email] Subject: Re: Random points in a stack Points created by makePoint() will appear in all slices if you set the positions to 0, as in this example: run("MRI Stack (528K)"); getDimensions(width, height, channels, slices, frames); PntNumber = 5; for (i=0; i<PntNumber; i++) { x = round(random*(width-1)); y = round(random*(height-1)); makePoint(x, y, "large cyan cross add"); Overlay.setPosition(0); }; You can set point properties (color, size etc.) with makeSelection() in the same way as makePoint(), as in this example: run("MRI Stack (528K)"); getDimensions(width, height, channels, slices, frames); PntNumber = 5; for (i=0; i<PntNumber; i++) { x = newArray(PntNumber); y = newArray(PntNumber); for (i=0; i<x.length; i++) x[i] = round(random*(width-1)); for (i=0; i<x.length; i++) y[i] = round(random*(height-1)); makeSelection("large cyan cross points", x, y); } -wayne ------------------------------------------------------------ This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email. ================================= -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Wayne Rasband-2
Dear Wayne,
I have found small niggle when I tried to use makePoint() in my macro: newImage("New", "8-bit ramp", 512, 512, 1); makePoint(200, 200, "large red cross add"); Overlay.setPosition(0); Two colors (green and orange) do not work with this macro, making the point yellow (default) instead of green or orange. If I try to make points manually (Point Tool) and choosing color by double click then these colors work fine. Sincerely, Alex On 06/11/2018 05:21, Wayne Rasband wrote: >> On Nov 5, 2018, at 10:29 AM, Aleksandr Mironov <[hidden email]> wrote: >> >> Dear All, >> For one of my small macro projects in counting I need to generate random points in a stack and use Multi-point tool to count them. I need two variants: 1) each stack slice contains its own points; 2) all slices contain the same set of points - points on the first slice are seen through all of them. I have tried 2 methods: makePoint() and makeSelection(). Both are not good enough. makePoint allows to change properties of points and works well with Multi-point Tool but creates only the 1st variant (separate set for each slice). > Points created by makePoint() will appear in all slices if you set the positions to 0, as in this example: > > run("MRI Stack (528K)"); > getDimensions(width, height, channels, slices, frames); > PntNumber = 5; > for (i=0; i<PntNumber; i++) { > x = round(random*(width-1)); > y = round(random*(height-1)); > makePoint(x, y, "large cyan cross add"); > Overlay.setPosition(0); > }; > >> makeSelection creates the 2nd variant but does not allow to change point properties (color, size etc.) and does not work very well with Multi-point Tool. > You can set point properties (color, size etc.) with makeSelection() in the same way as makePoint(), as in this example: > > run("MRI Stack (528K)"); > getDimensions(width, height, channels, slices, frames); > PntNumber = 5; > for (i=0; i<PntNumber; i++) { > x = newArray(PntNumber); > y = newArray(PntNumber); > for (i=0; i<x.length; i++) > x[i] = round(random*(width-1)); > for (i=0; i<x.length; i++) > y[i] = round(random*(height-1)); > makeSelection("large cyan cross points", x, y); > } > > -wayne > > >> Are there workarounds for that? I do not see Overlay options for points (like Overlay.drawLine that I have used in my precious macros successfully). >> Example macros are attached. >> >> -- >> Sincerely, >> Alex >> >> >> macro1--------------------- >> run("MRI Stack (528K)"); >> getDimensions(width, height, channels, slices, frames); >> PntNumber = 5; >> for (i=0; i<PntNumber; i++) { >> x = round(random*(width-1)); >> y = round(random*(height-1)); >> makePoint(x, y, "small red cross add"); >> }; >> -------------------------- >> >> macro2------------------- >> >> run("MRI Stack (528K)"); >> getDimensions(width, height, channels, slices, frames); >> PntNumber = 5; >> for (i=0; i<PntNumber; i++) { >> x = newArray(PntNumber); >> y = newArray(PntNumber); >> for (i=0; i<x.length; i++) { >> x[i] = round(random*(width-1)); >> } >> for (i=0; i<x.length; i++) { >> y[i] = round(random*(height-1)); >> } >> makeSelection("point", x, y); >> }; > -- > 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 |