Subtracting a background image from a virtual stack

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Subtracting a background image from a virtual stack

acla345
Hi all,

I am having a problem subtracting a background image from my virtual stack
that will hopefully be fairly easy to fix. I have a code that works; the
abbreviated version of the code is this:

backgroundImage="filepath";
open(backgroundImage);
dumBI=getImageID();

filename = dir1 + list[1];
run("Image Sequence...", "open=[filename] starting=1 increment=1 scale=100
file=.tif or=[] sort use");
image=getTitle();

imageCalculator("Subtract create 32-bit stack", image, dumBI);

This works, however, I cannot run it when I increased the stack size (~10k
images) due to memory restrictions. Does anyone know of a way to make the
above command work (imageCalculator("Subtract create 32-bit stack", image,
dumBI);) without increasing the memory over 2GB? I am currently running my
whole script in batch mode through the terminal.

Or, does anyone know what would be used for "image" in the above command if
I wanted to loop through the stack slices? Ie,

filename = dir1 + list[1];
run("Image Sequence...", "open=[filename] starting=1 increment=1 scale=100
file=.tif or=[] sort use");
for (n=1; n<=nSlices; n++) {
setSlice(n);

slice= WHAT NEEDS TO GO HERE? (how to I get slice ID)

imageCalculator("Subtract 32-bit",slice, dumBI);

Thanks in advance for your help!