Concentric Circle Formation Slices

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Concentric Circle Formation Slices

Thaddeus
I intend to produce a macro where after a user generated circle a series of
concentric circles is produced. However, the variables change without any
alteration on my part. The bounding rectangle positions and radius just
decrease on their own for no reason each time I run the macro so I cannot
script it in any straight forward manner. Here is my macro so far:

setBackgroundColor(0, 0, 0);
run("Clear Outside");  // Clear background data

W1 = getValue("Width");
H1 = getValue("Height");
xb = getValue("BX");
yb = getValue("BY");

R = (H1+W1)/4    //get radius
xc=xb+W1/2        // Center x value
yc=yb+H1/2         // Center x value
Rx=0.9*R             // Reduced radius
x=xc-Rx*sqrt(2)   //New bounded corner x value            
y=yc-Rx*sqrt(2)   //New bounded corner y value

makeOval(xb,yb,2*,2*R); // This should reproduce the same exact oval as the
user generated one and it
                                      //does not (Ideally this new circle
would be smaller and about the same
                                      //centroid as the original, but I cant
even make the same oval yet)
run("Clear", "slice");        // Remove center data

//Next I would recall the image and repeat with new smaller outer circle

// Ideally I should run this in a loop and each iteration will save only the
data from each new concentric ring

//Thanks for your time and help



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Concentric Circle Formation Slices

Krs5
Dear Thaddeus,

Your macro works for a circle (assuming that the code makeOval(xb,yb,2*,2*R); is makeOval(xb,yb,2*R,2*R);) but for an oval the Xradius and Yradius don't have to be the same and would be

Rx = W1/2;
Ry = H1/2;

and not necessary R = (H1+W1)/4; This is only valid for a circle.

Best wishes

Kees


Dr Ir K.R. Straatman
Advanced Imaging Facility

University of Leicester
www.le.ac.uk/advanced-imaging-facility<http://www.le.ac.uk/advanced-imaging-facility>

________________________________
From: Thaddeus <[hidden email]>
Sent: 18 August 2020 09:39
Subject: Concentric Circle Formation Slices

I intend to produce a macro where after a user generated circle a series of
concentric circles is produced. However, the variables change without any
alteration on my part. The bounding rectangle positions and radius just
decrease on their own for no reason each time I run the macro so I cannot
script it in any straight forward manner. Here is my macro so far:

setBackgroundColor(0, 0, 0);
run("Clear Outside");  // Clear background data

W1 = getValue("Width");
H1 = getValue("Height");
xb = getValue("BX");
yb = getValue("BY");

R = (H1+W1)/4    //get radius
xc=xb+W1/2        // Center x value
yc=yb+H1/2         // Center x value
Rx=0.9*R             // Reduced radius
x=xc-Rx*sqrt(2)   //New bounded corner x value
y=yc-Rx*sqrt(2)   //New bounded corner y value

makeOval(xb,yb,2*,2*R); // This should reproduce the same exact oval as the
user generated one and it
                                      //does not (Ideally this new circle
would be smaller and about the same
                                      //centroid as the original, but I cant
even make the same oval yet)
run("Clear", "slice");        // Remove center data

//Next I would recall the image and repeat with new smaller outer circle

// Ideally I should run this in a loop and each iteration will save only the
data from each new concentric ring

//Thanks for your time and help



--
Sent from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.1557.x6.nabble.com%2F&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7Ca3eb8eb9333748a5d97908d84354327b%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C637333376207306947&amp;sdata=Xkw060aXUDcBcLXX2pUj6X3kTBoztG8fFp6ces56YQw%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7Ca3eb8eb9333748a5d97908d84354327b%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C637333376207306947&amp;sdata=wrCLwYK%2BAC5W3LUcYW8JrCYjDky48T77BzwMUDLJ3sM%3D&amp;reserved=0

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Concentric Circle Formation Slices

Thaddeus
In reply to this post by Thaddeus
Thank you for your help. Yes I left out the R on accident. You are right, I
am trying to just solve the problem for simple circles right now and the
problem still remains. With the exact same parameters and with a true circle
drawn imagej move the circle and makes it smaller without me changing any
values. Thanks for your help.



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Concentric Circle Formation Slices

Thaddeus
In reply to this post by Thaddeus
Update on a certain image this macro actually works for producing appropriate
size circles that are about the same centroid. Mathematically it makes
sense. However, on images I am actually interested in it doesn't work and
makes random sized and position circles. Here it is:

setBackgroundColor(0, 0, 0);
run("Clear Outside");

W1 = getValue("Width");
H1 = getValue("Height");
xb = getValue("BX");
yb = getValue("BY");

R = (H1+W1)/4
xc=xb+R
yc=yb+R
Rx=0.9*R

x=xc-Rx
y=yc-Rx

makeOval(x,y,2*Rx,2*Rx);
run("Clear", "slice");






--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Concentric Circle Formation Slices

Gabriel Landini
On Tuesday, 18 August 2020 17:58:16 BST Thaddeus wrote:
> Update on a certain image this macro actually works for producing
> appropriate size circles that are about the same centroid. Mathematically
> it makes sense. However, on images I am actually interested in it doesn't
> work and makes random sized and position circles. Here it is:

I think this has to do with the calibration of the image.
If I run the macro on the flybrain image (in one duplicated slice, which is
calibrated in um) the new circle is centred elsewhere and it becomes larger.
If I remove the calibration, then it works fine.

So try adding "raw" to the values that you get, i.e.:

W1 = getValue("Width raw");
H1 = getValue("Height raw");
xb = getValue("BX raw");
yb = getValue("BY raw");


Cheers

Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

ROI manager problems

Krs5
Dear list, Wayne

I came across some strange behaviour of the ROI manager when used together with Stack.setPosition. If I run the macro code below and check the ROI in the manager, I find its position is 2, 6, 1 and not at 2, 3, 1

run("Confocal Series");
Stack.setPosition(2, 3, 1);
makeOval(135, 197, 71, 72);
roiManager("Add");

If I try 1, 3, 1 the resulting ROI is at 1, 5, 1.

Furthermore, I noticed that 'Associate "Show All" ROIs with slices' does not seem to work.

Best wishes

Kees


Dr Ir K.R. Straatman
Advanced Imaging Facility

University of Leicester
www.le.ac.uk/advanced-imaging-facility<http://www.le.ac.uk/advanced-imaging-facility>



--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ROI manager problems

Wayne Rasband-2
> On Aug 20, 2020, at 6:19 AM, Straatman, Kees (Dr.) <[hidden email]> wrote:
>
> Dear list, Wayne
>
> I came across some strange behaviour of the ROI manager when used together with Stack.setPosition. If I run the macro code below and check the ROI in the manager, I find its position is 2, 6, 1 and not at 2, 3, 1

Modify the macro to use Roi.setPosition(c,z,t) and it should work as expected.

  run("Confocal Series");
  makeOval(135, 197, 71, 72);
  Roi.setPosition(2, 3, 1);
  roiManager("Add”);

-wayne


> run("Confocal Series");
> Stack.setPosition(2, 3, 1);
> makeOval(135, 197, 71, 72);
> roiManager("Add");
>
> If I try 1, 3, 1 the resulting ROI is at 1, 5, 1.
>
> Furthermore, I noticed that 'Associate "Show All" ROIs with slices' does not seem to work.
>
> Best wishes
>
> Kees

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html