Fiji Headless Mode LoG Fails

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

Fiji Headless Mode LoG Fails

Olivier Burri
Dear ImageJ/FIJI Users

I've built a very simple macro that I want to call from Fiji's Headless mode.
It takes as arguments the path of an image and a number for the LoG filter, separated by a ';'.

callMacro("thismacro", "imagepath;val_for_LoG"); works as expected and the images reflect the change in the val_for_LoG that I input

But when I run

ImageJ.exe  --headless -macro "mymacro" "arg1;arg2" -batch
It runs properly and saves the image, but they are all the same, no matter what I put as my arg2.

It seems that in headless mode, the run("FeatureJ Laplacian", "compute smoothing="+params);  line isn't called properly, or something similar.
I know there is something in the params variable, as I append it to the filename, and that gets created properly.

Anyone know how I could solve this?

Best

Oli


Macro below

macro "As headless" {
        args = split(getArgument(), ";");
        sep = File.separator;
       
        fullpath = args[0];
        fullpath = replace(fullpath, "/", sep);
        params = parseFloat(args[1]);
        print(args[1], params);
        path = substring(fullpath, 0, lastIndexOf(fullpath, sep));
        print(path);
        image = substring(fullpath, lastIndexOf(fullpath,sep), lengthOf(fullpath));
       
       
       
        open(path+image);

       
        run("FeatureJ Laplacian", "compute smoothing="+params);
       
        name = substring(image, 0, lengthOf(image)-4);
        saveAs("TIFF", path+name+" with LoG_"+params+".tif");
       
}

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

Re: Fiji Headless Mode LoG Fails

dscho
Hi Olivier,

On Tue, 23 Jul 2013, Burri Olivier wrote:

> I've built a very simple macro that I want to call from Fiji's Headless
> mode.  It takes as arguments the path of an image and a number for the
> LoG filter, separated by a ';'.
>
> callMacro("thismacro", "imagepath;val_for_LoG"); works as expected and
> the images reflect the change in the val_for_LoG that I input
>
> But when I run
>
> ImageJ.exe  --headless -macro "mymacro" "arg1;arg2" -batch
> It runs properly and saves the image, but they are all the same, no
> matter what I put as my arg2.
>
> It seems that in headless mode, the run("FeatureJ Laplacian", "compute
> smoothing="+params);  line isn't called properly, or something similar.
> I know there is something in the params variable, as I append it to the
> filename, and that gets created properly.

Looking at the source code, I see that this line:

        https://github.com/fiji/fiji/blob/master/src-plugins/FeatureJ_/src/main/java/FJ_Laplacian.java#L29

calls this method:

        https://github.com/fiji/fiji/blob/master/src-plugins/FeatureJ_/src/main/java/FJ.java#L39

which in turn calls the WindowManager to return the current image.

Now, I am not quite clear how you call your macro (in sequence? in
parallel?), so I only have the *hunch* that there is a timing issue
between these two lines:

> [...]
> open(path+image);
> [...]
> run("FeatureJ Laplacian", "compute smoothing="+params);

The easiest way would be to output getTitle() and/or
getInfo("image.filename") after the open() statement.

OTOH it could also be the case that for some reason, "image" contains the
wrong name (I did not see any debug output of that variable except using
part of it for the output file name, so I guess that accounts for debug
output).

Ciao,
Dscho

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