Posted by
fabrice senger-2 on
Sep 08, 2010; 2:52pm
URL: http://imagej.273.s1.nabble.com/add-x-number-of-stacks-tp3687001p3687007.html
Hi there, this is what I was looking for...
In any case I attach the code I was working on.
Thank you,
Fabrice.
dir = getDirectory("Choose a Directory ");
list = getFileList(dir);
run(dir+list[0]);
id1 = getImageID;
run(dir+list[1]);
id2 = getImageID;
imageCalculator("Add create stack", id1,id2);
rename("test");
waitForUser("checkpoint");
for (i=0; i<list.length-2; i++) {
showProgress(i, list.length);
run(dir+list[i+2]);
id3=getImageID;
imageCalculator("Add create stack", "test",id3);
rename("test");
}
2010/9/8 Rasband, Wayne (NIH/NIMH) [E] <
[hidden email]>
> On Sep 8, 2010, at 2:33 AM, fabrice senger wrote:
>
> > Hello,
> >
> > and thank you for your answer.
> >
> > Actually if there are 10 stacks with 3 images(01,02,03) , I want to add
> all
> > together so that all 01 are added, all 02 are added and all 03 are added
> and
> > so I get a new stack with 3 images.
> >
> > Concatenate thus not help as this produces a new stack but one stack
> after
> > another.
> >
> > Ther several ways to sum stacks but it is always one to another, and I
> would
> > like to automate this, maybe in batch mode...
>
> Here is an easy way to do this:
>
> 1. Use File>Import>Raw to Open the 10 stacks as a single 30 image stack.
> 2. Use Image>Hyperstacks>Stack to Hyperstack to convert the stack to
> a 10 slice, 3 frame hyperstack (Order="xyctz", c=1, z=10, t=3, display
> mode="Grayscale").
> 3. Use Image>Stack>Z Project (Projection type = "Sum Slices").
>
> Use the command recorder (Plugins>Macros>Record) to generate a macro. It
> will look something like this:
>
> run("Image Sequence...", "open=/Users/wayne/stack/stack01.tif sort");
> run("Stack to Hyperstack...", "order=xyctz channels=1 slices=4 frames=3
> display=Grayscale");
> run("Z Project...", "projection=[Sum Slices] all");
>
> -wayne
>