Repeat segmented line selection

That’s odd. It works for me as @Bio7 posted it. Please check again to make sure you have copied correctly. No extra spaces in the commands or variable names, no missing parentheses or semicolons, no extra characters introduced by copying and pasting, etc.

I put the pixel size as 0.45 microns based on 2.18 pixels per micron, not microns per pixel.

However, now that I look at it, this also does not match the scale bar on the image. That suggests 0.79 pixels/micron or 1.266 microns/pixel.

@mbkenawy, you should verify the scale with a stage micrometer. Otherwise your areas will not be measured correctly.

1 Like

I have evaluated the macro line by line, and there are lines which it doesn’t like.
pixelDist = dist*pixelSize;
Error msg: pixelDist= <dist>* pixelSize;

for ( i=0; i < num; i++) {
Error msg: for ( i=0; i < <num>; i ++)}

roiManager("Select", i);
Error msg: roiManager ("Select" , <i>);

roiManager("translate", 0, -pixelDist);
Error msg:')' expected in line 1
roiManager ("translate" <,> 0, -pixelDist);

roiManager("Add")};
Error msg: Statement cannot begin with '}' in line 1
roiManager ("Add") <}>

I am surprised that it worked with you.
May be it is related to my version1.48.
As regards the scale, I will recheck it after creation of the lines

regards

I’m sorry, but the error messages as written don’t make sense. It will be a lot easier to fix this issue if you can copy and paste your information instead of transcribing it, as this process introduces new and irrelevant errors.

  1. Copy your entire macro code out of the macro editor window in ImageJ. Then paste it into your post in the forum.
  2. Format your pasted code as code (looks like typewriter font): Select it with the mouse, then click the </> tool in the forum’s post editor.
  3. If you get errors, take a screenshot and paste the image into the forum using the upload tool (just to the right of the </> tool).

Just checking – you are pasting the code directly into the macro editor within ImageJ, right? Don’t use Word or some other word processor, because it may introduce invisible characters that can cause this sort of syntax error.

If the scale is wrong, your lines will be wrong.

1 Like
roiManager("Add");
pixelSize=2.18
dist=10 
pixelDist = dist*pixelSize;
num = 25;
for ( i=0; i < num; i++) {
roiManager ("Select", i);
roiManager ("translate", 0, -pixelDist);
roiManager ("Add")};
roiManager ("Show All");
1 Like

OK, that code works for me on Fiji and “vanilla” (non-Fiji) ImageJ.

My Fiji version:

My ImageJ:

1 Like

Thx tswayne and Bio7 for your patience and help.

It seems that the problem with my ImageJ version (V 1.48). I have downloaded a newer version and it seems to work.
However I can’t find my original segmented line, even if I add it on roiManager.
Also in the older version there was a cell counter tool, where you can count different types of cells. I can’t find this tool in the newer version!

Many thanks and sorry for overloading,

Regards,

@tswayne Totally off topic, but FYI, since you use OS X: you can quickly take a screenshot of a single application window by pressing Shift+Command+4, then pressing the space bar, then clicking the window of interest. If you do it that way, you’ll get a nice PNG with transparency including drop shadow. :grin:

2 Likes

Hi tswayne and Bio7,

I still have the issue where I can’t find the original segmented line that I have created even if I add it on the roi manager.
And I can’t find the cell counter tool in the newer version of ImageJ.

Regards,

Much classier! Thanks for the tip, @ctrueden!

The Cell Counter is in Fiji. You can search for any command by typing “L” (for locate or launch). If you have regular ImageJ you may have to find and download the plugin separately. But I recommend the Fiji package.

I see that there is a problem with the macro, that the first line is not preserved.
But if you add it twice and iterate through starting with the second ROI, then it gives you your first line and all the others. The last line also appears twice in the ROI manager – I’m not sure why, but I think it’s acceptable.

Below is a corrected version.

roiManager("Add");
roiManager("Add");  //add an extra copy to preserve original line
pixelSize=2.18
dist=10 
pixelDist = dist*pixelSize;
num = 5;
for ( i=1; i < num; i++) {
roiManager ("Select", i);
roiManager ("translate", 0, -pixelDist);
roiManager ("Add")};
roiManager ("Show All");
1 Like