karthikeyan
karthikeyan

Reputation: 163

ImageJ - Running concatenate from a macro - valid choice error

I am trying to run concatenation of two images through a macro. The final aim is to use in a batch mode.

Here is the code:

dir1 = getDirectory("Choose Source Directory ");

list = getFileList(dir1);

i=0;
filename1 = dir1 + list[i];
filename2 = dir1 + list[i+1];

open(filename1);
open(filename2);

imag1 = list[i]; imag2 = list[i+1];

run("Concatenate...", "  title=[Concatenated Stacks] image1=imag1 image2=imag2");

When executed, the error is like this:

enter image description here

What is the right choice for executing this macro?

Upvotes: 0

Views: 2144

Answers (1)

Jan Eglinger
Jan Eglinger

Reputation: 4090

(Note: ImageJ usage questions are best asked on the ImageJ forum instead of here.)

You're currently setting the input to a literal "imag1", and there is no opened image with the title "imag1". You have to provide the content of your variable to the option string of the Concatenate command, either by string concatenation, or with the ImageJ-specific &variable syntax.


From the ImageJ1 Macro Language documentation:

The input fields of a dialog can be set to the contents of a macro variables by using string concatentation:

noise = 50;
output = "Point Selection";
run("Find Maxima...", "noise="+noise+" output=["+output+"] light");

With ImageJ 1.43 and later, there is an easier method that only requires adding "&" to the variable name in the options string:

noise = 50;
output = "Point Selection";
run("Find Maxima...", "noise=&noise output=&output light");

Upvotes: 1

Related Questions