Login  Register

Re: Batch Stack Focusing

Posted by Daan VAN DEN BRINK on Mar 28, 2017; 2:34pm
URL: http://imagej.273.s1.nabble.com/Batch-Stack-Focusing-tp5018376p5018407.html

Hello Amy,

I had a super quick look at your macro. Could it be that the closing
bracket of the for-loop in the 'processFile(path)' function is not
enclosing all the commands?
Also, all you files will be named "stack".

Hope that helps.

Daan

On 27/03/17 14:08, AC17 wrote:

> Hi all,
>
> This is my first time attempting to write a macro in image J. I would really
> appreciate your help with this…
>
> I have a main directory with multiple subdirectories. Each subdirectory
> contains multiple images (z stacks). I would like to write a code which will
> take my main directory and open a subdirectory , open all the images in that
> subdirectory, stack the images, run the stack focusing plugin and then save
> the stack in the corresponding folder. I would like to loop this so that all
> the subdirectories within my main directory are processed.
>
> This is what I have so far. This code runs for a few minutes but I then
> can’t find my saved stacks.
>
>     dir = getDirectory("Choose image sequence folder");
>     setBatchMode(true);
>     count = 0;
>     countFiles(dir);
>     n = 0;
>     processFiles(dir);
>     print(count+" files processed");
>    
>     function countFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                countFiles(""+dir+list[i]);
>            else
>                count++;
>        }
>    }
>
>     function processFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                processFiles(""+dir+list[i]);
>            else {
>               showProgress(n++, count);
>               path = dir+list[i];
>               processFile(path);
>            }
>        }
>    }
>
>    function processFile(path) {
> for (i=0; i<list.length; i++)
>            open(path);}
>            {
>            run("Images to Stack", "name=Stack title=[] use");
>            run("Stack Focuser ", "enter=11");
>             saveAs("Tiff", "stack" );
>             close();
>        }
>
> Many thanks for your help!
>
> Amy
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--

*Daan M. VAN DEN BRINK*

Laboratoire de Biologie et Modélisation de la Cellule (LBMC) - UMR 5239

  Team Mollereau

*ENS de Lyon* — Site MONOD - LR2

   46 allée d'Italie — 69364 LYON CEDEX 07, FRANCE

   Tel.: +33 (0)4.72.72.89.29


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html