Weird macro behaviour

Posted by analia on
URL: http://imagej.273.s1.nabble.com/Weird-macro-behaviour-tp5011475.html

Dear all,

I have programmed a simple code for the processing of some biological images. Without going into the specifics, the code splits channels, gets the green channel, runs convolution, makes binary and then analyses particles.  So far so good. Then, it uses ROI manager, takes labels and changes color to magenta.
The idea is to overlay the original image at the end. So, the "Add Image..." command is issued, the resulting image is flattened and saved as tif.

My problem is the run("Add Image...","image="+original) command, or, better said, where I execute it.

If I open a new macro window in ImageJ (ImageJ->Plugins->Macros->New->Macro), write down the code and execute it from that window (Macros->Run macro), it works just fine.

...
run("Analyze Particles...", "size=0-500 pixel circularity=0-1 show=Nothing add");
                       
roiManager("Show all without labels");
run("Colors...","selection=magenta");
               
open(<sourcePath>);
original=getTitle();
               
print(">>>> "+original);
               
selectImage(4); //1, 2 and 3 correspond to the channels...
roi=getTitle();
print(">>>> "+roi);
               
run("Add Image...","image="+original);
               
run("Flatten");

saveAs("Tiff",<destinyPath>+roi);


Now, if I write the macro in a text editor and do ImageJ->Plugins->Macros->Run  the command run("Add Image...","image="+original) does not work. If I comment it, and save to file the original and the roi (flattened) images, everything is good, but this command doe snot work and I can get the original image to be added to the roi image. How can this be possible?

My machine is a Windows 8.1 64-bit and I am using ImageJ 1.49n.

Probably (more than likely), I am missing some specifics of ImageJ macro programming, but I go over it again, and again, and don't see it (as it usually happens). Please could someone help me?


Many thanks in advance,
AnĂ¡lia