Image not found error in macro when using setBatchMode(true)

Any idea why the following macro MWE

run("AuPbSn 40");
run("Frangi Vesselness", "dogauss=true spacingstring=[1, 1] scalestring=[2, 5]");
imageCalculator("Add create", "AuPbSn40.jpg","result");

fails with the following error message:

Image not found in line 4

? The debug window shows the following additional information:

Memory * 122MB of 3931MB (3%)
nImages() * 1
getTitle() * “AuPbSn40.jpg”

The same macro executes flawlessly when the first line setBatchMode(true) is deleted/commented. Expected behaviour: with setBatchMode(true) the macro does all the calculation and shows the images only in the end.
In other words, in batch mode (as opposed to non-batch-mode) the window created by the Frangi Vesselness plugin is not added to the window list, and is therefore unselectable. This of course makes the batch mode unusable.

I feel this must be more or less a FAQ, but I searched the forum for quite a bit without finding an answer. One of the most closely related posts are:

but the `solution’ appears to involve some on-and-off-switching of the batch mode, which defeats the purpose of the batch mode itself.

I first thought this was an issue in headless mode only (where the same issue arises without even setting setBatchMode(true)), prompting the topic

Maybe the problem is that the result of the Frangi Vesselness is a virtual image?
You can see that it is virtual in the header (V).
In batchmode you have no access to the image anymore since it is not really fully in memory.

Tried a few things but had no solution to get around that in batchmode. Except the show and hide feature of the batch mode.

In such cases it might be better to look at proper scripting. IJ1 Macro has limits.

1 Like

Oh, good observation, thanks. That may explain why this issue is not a FAQ, if it affects only virtual return images. I don’t really get why a virtual image does not deserve an entry in the image window list, but I can see why there is a problem.
Are virtual images in ImageJ always disk-backed ? Clearly the Frangi Vesselness result is not generated on the fly as you go back and forth between stack slices, so if it’s not in memory where else can it be than on the disk ?

I’ll have to inspect the Frangi Vesselness plugin source code. If there’s a temporal file, accessing that may be a work around hack.

On an ImageJ level, would it make sense to promote virtual images created by plugins to real images when running in batch mode ?

(As for macro vs scripting I agree, but for a one-time job the macro recorder is oh so convenient; I willl check though whether the Frangi Vesselness plugin has an API that makes it usable in a script)

1 Like

This plugin is strange. There seem to be two versions and the ImageJ wiki links to the one labeled as experimental in the gui. The experimental Frangi does not have this problem.

The one you use is implemented as an op:

Maybe it is not a virtual image afterall? Would be strange to have a virtual image without a specific directory.