Trouble with Fiji makeOval macro

Hi,

I am very new with Fiji and would welcome any input for my current problem.

I am trying to make a macro that would draw three concentric circles of defined size around given coordinates. I am working with .czi images from Zeiss confocal microscope. The input that would be different for each image/each set of concentric circles is the variable diamplaque which is the diameter of the innermost circle and the X and Y coordinates of the circle centre. After making the circles I would use them to do area analysis with Analyze particles.

My macro currently looks like this:

diamplaque = 59; //plaque diameter in pixels
diam15 = (diamplaque+96);	
diam30 = (diamplaque+192);
  
X = 46.851 //these are scaled coordinates
Y = 217.213 //these are scaled coordinates
toUnscaled(X, Y);
 

  makeOval(X-(diamplaque/2), Y-(diamplaque/2), diamplaque, diamplaque);
    roiManager("Add");
    Overlay.show;
  makeOval(X-(diam15/2), Y-(diam15/2), diam15, diam15);
    roiManager("Add");
    Overlay.show;
  makeOval(X-(diam30/2), Y-(diam30/2), diam30, diam30);
    roiManager("Add");
    Overlay.show;

The problem I am encountering is that this macro will keep on running(?) and makes these circles on all the images I open after running this macro.

I have noticed that if the macro contains only one makeOval command, it works as I would expect and makes the oval on the active image only (not on the other images that are open at the same time, nor images opened afterwards). With multiple makeOval commands it keeps on making the ovals on all images that are open or are opened thereafter. Any ideas how to fix this or make the macro in a different way?

Welcome to the forum @hennam.

I´m not sure if I understand completely what you mean by “keep on running”, but my guess is that if you open a new image, the ROIs from the previous image (where you ran the macro) are still in the ROI Manager. Because ROIs can be transferred from image to image with the help of the ROI Manager you also see them in the new image. Actually, you did not copy anything yet to the Overlay (which is something different to the ROIs).
The code below should add the circles to the overlay to the image (which is saved with the image as opposed to ROIs). I.e. when you reopen the image, the circles can be retrieved.

diamplaque = 59; //plaque diameter in pixels
diam15 = (diamplaque+96);	
diam30 = (diamplaque+192);
  
X = 46.851; //these are scaled coordinates
Y = 217.213; //these are scaled coordinates
toUnscaled(X, Y);
 

  makeOval(X-(diamplaque/2), Y-(diamplaque/2), diamplaque, diamplaque);
    roiManager("Add");
    
  makeOval(X-(diam15/2), Y-(diam15/2), diam15, diam15);
    roiManager("Add");
    
  makeOval(X-(diam30/2), Y-(diam30/2), diam30, diam30);
    roiManager("Add");

  run("From ROI Manager"); //adds all elements from the ROI Manager to the overlay
  run("List Elements"); //Lists the overlay elements

  roiManager("reset"); //deletes all ROIs from the ROI Manager
1 Like