Open image in 2 files into one sequence using macro

Hi everyone,
I want to open 2 files into one image sequence using macro.
The code I have now is opening two files separately.

run("Image Sequence...", "open=/Users/Desktop/FourSets/Set_1");
run("Image Sequence...", "open=/Users/Desktop/FourSets/Set_2");

If I can combine 2 files, I could set frame from 0 to 19 (10 frames for each file). For situation now, i only can set frame from 0-9 to first file,0-9 to second file, and then use a python file to merge two results.

Can I do a loop in macro to open image through one file and then start scanning images in next file?

Thank you!

Dear @mingxxu,

There are looping statements available in the ImageJ1 macro language. Take a look at the documentation.

However, you could more easily achieve your goal by concatenating the two opened stacks with a macro:

run("Image Sequence...", "open=/Users/Desktop/FourSets/Set_1");
set1Title = getTitle();
run("Image Sequence...", "open=/Users/Desktop/FourSets/Set_2");
set2Title = getTitle();
run("Concatenate...", "  title=[Concatenated Stacks] image1="+set1Title+" image2="+set2Title);
close(set2Title);

Best,
Stefan

1 Like

Hi @stelfrich
Thank you so much! This is exactly what I am looking for!

Mingx