Images to stack

Dear all,
I have open 4 images that I want to stack together. When I apply “Images to Stack” they are ordered according with the ID number. Does anyone has a macro to create stack from single images in which you can order the images according the title name?


run("Concatenate...", "keep image1=name2 image2=name3 image3=name1 image4=name4");

If you have your image titles e.g. in the variables n1, n2, n3, n4 then the macro is

run("Concatenate...", "keep image1=" + n1 + " image2=" + n2 + " image3=" + n3 + " image4=" + n4);

‘keep’ is optinal.

see Image>Stacks>Tools>Concatenate…

Thanks for your help, but I was wondering to get a macro more similar to this:

run(“Concatenate…”, "keep image1= if contains term “Low” image2=if contains term “medium” image3= if contains term “high”);

Add the images in the order you want by copying the source contents (select all, copy), then add a slice to the stack (which in the first iteration can be a simple image!), set that new slice as being active, paste the clipboard contents.

If you know up front how many slices there will be in a stack, create a new image as stack with sufficient slices. Get its imageId, Select the source, copy the content, select the stackby its ID, set the slice, paste.

The list of built-in functions holds a lot of info.