Batch Processing images with different z-stacks

batch-processing
Tags: #<Tag:0x00007fa30f97fc48>

#1

Hi all,

I am new to ImageJ and here is my problem: I have a set of .ome.tiff images I would like to run this macro on:

run("Stack to Hyperstack...", "order=xyzct channels=4 slices=x frames=1 display=Color");
run("Split Channels");
close();
selectWindow("C1-imagename-0015.ome.tiff");
close();
run("Red");
run("Merge Channels...", "c1=[C3-imagename.ome.tiff] c2=[C2-imagename-0015.ome.tiff] create");
run("Subtract Background...", "rolling=50");
run("Detect Particles", "  two=[Detect in both channels independently] ch1a=4 ch1s=3 ch2a=4 ch2s=3 calculate max=2 plot add=Nothing");

I would like to apply this macro to all images individually via batch processing, however I am struggling with these problems:
1.) Each image consists of 4 separate fluorescent channels, 1 timepoint and with different amounts of z-stacks. How, when the macro runs Stack to Hyperstack, can I run this command across all images so that I end up with 4 channels and a varying number of slices?
2.) After I have split the channels, I only would like to run the background correction on 2 channels, and so I close the other two. How can I make this occur in each image?
3.) Same problem as 2.) I would like to merge the remaining two channels into one. How do I do this across all images?

Thanks for the help!


#2

@mflee

In general - you can use theBuilt-In Macro Functions page to help search for appropriate function calls… it’s super helpful!

For this you can use something like this to generalize that Stack to Hyperstack... call:

getDimensions(width, height, channels, slices, frames);
run("Stack to Hyperstack...", "order=xyzct channels=" + channels + " slices="+ slices + " frames=" + frames + " display=Color");

I have to run to a meeting… so I"ll give you a quick answer on these latter two questions… but will tell you the best thing to do to generalize these code calls is to concatenate strings… so using code calls like:

title = getTitle();
selectWindow("C1-" + title);
run("Merge Channels...", "c1=[C3-" + title +"] c2=[C2-" + title +"] create");

Hope this at least helps get you started! If you have more questions - just post again. We are here to help you!

eta :slight_smile: