Macro Problem : Process files from subfolder

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

Macro Problem : Process files from subfolder

chloroplaster
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Macro Problem : Process files from subfolder

chloroplaster
Hi Again, I resolved but only partially the problem
My main folder has 3 folders, but my code only process 2 of the subfolders

Thanks for your help !!! :)
______________________
Here is my new code

dir1=getDirectory('');
list1= getFileList (dir1);
        for (i=0; i<(list1.length+1); i++)
        {
                dir2 = dir1+list1[i];
                list2 = getFileList (dir2);
                        for (j=0; j<list2.length; j++)
                                {
                                open (dir2+list2[j]);
                                run("Split Channels");
                                setAutoThreshold("Default dark");
                                //run("Threshold...");
                                setThreshold(30000, 65535);
                                run("Analyze Particles...", "size=1-20 circularity=0.10-1.00 show=[Overlay Masks] summarize in_situ");
                                close();
                                run("Measure");
                                run("Gaussian Blur...", "sigma=5");
                                setAutoThreshold("Default dark");
                                //run("Threshold...");
                                setThreshold(9000, 34290);
                                run("Analyze Particles...", "size=50-Infinity show=[Overlay Masks] summarize in_situ");
                                close();
                                close();
                                setAutoThreshold("Default dark");
                                //run("Threshold...");
                                setThreshold(5700, 65535);
                                run("Analyze Particles...", "size=50-Infinity show=[Overlay Masks] summarize in_situ slice");
                                close();
                                }
        }
Reply | Threaded
Open this post in threaded view
|

Re: Macro Problem : Process files from subfolder

Jan Eglinger
Hi Pierre,

Fiji's script editor [1] contains a template for exactly that purpose:
applying a macro recursively on all files in a folder and in all
subfolders. You find it in the editor's menu:
        Templates > IJ1 Macro > Process Folder

In case you are using plain ImageJ 1.x, you can copy and paste the
template code from here:

https://github.com/imagej/imagej-legacy/blob/master/src/main/resources/script_templates/IJ1_Macro/Process_Folder.ijm

Hope that helps,
Jan

[1]: http://fiji.sc/Using_the_Script_Editor


On 25.04.15 21:15, chloroplaster wrote:

> Hi Again, I resolved but only partially the problem
> My main folder has 3 folders, but my code only process 2 of the subfolders
>
> Thanks for your help !!! :)
> ______________________
> Here is my new code
>
> dir1=getDirectory('');
> list1= getFileList (dir1);
> for (i=0; i<(list1.length+1); i++)
> {
> dir2 = dir1+list1[i];
> list2 = getFileList (dir2);
> for (j=0; j<list2.length; j++)
> {
> open (dir2+list2[j]);
> run("Split Channels");
> setAutoThreshold("Default dark");
> //run("Threshold...");
> setThreshold(30000, 65535);
> run("Analyze Particles...", "size=1-20 circularity=0.10-1.00
> show=[Overlay Masks] summarize in_situ");
> close();
> run("Measure");
> run("Gaussian Blur...", "sigma=5");
> setAutoThreshold("Default dark");
> //run("Threshold...");
> setThreshold(9000, 34290);
> run("Analyze Particles...", "size=50-Infinity show=[Overlay Masks]
> summarize in_situ");
> close();
> close();
> setAutoThreshold("Default dark");
> //run("Threshold...");
> setThreshold(5700, 65535);
> run("Analyze Particles...", "size=50-Infinity show=[Overlay Masks]
> summarize in_situ slice");
> close();
> }
> }
>

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