http://imagej.273.s1.nabble.com/Macro-open-each-sub-folders-as-a-stack-tp5019681p5019682.html
> Hi, everyone,
>
> I have a folder with multiple sub-folders, and each of which contains 18
> number of tif(.tif) files.
> I'd like to open every sub-folders files as a stack in imageJ.
>
>
> With some online macro documentation,
> I can open files in each sub-folders, and do somethings like change 16-bit
> files into 8-bit files.
>
> But I need open each sub-floder as a stacks,
> I have some problem to get stack with macro,
>
> Here is the code that I have currently,
>
> inputDir = getDirectory("choose the input directory");
> outputDir = getDirectory("choose the output directory");
>
> processDir(inputDir, outputDir);
>
> function processDir(inputDir, outputDir) {
> listdir = getFileList(inputDir);
> for (j = 0; j < listdir.length; j++) {
> print("Processing: " + listdir[j]);
> File.makeDirectory(outputDir + listdir[j]);
> outputFolder = outputDir + listdir[j];
> inputFolder = inputDir + listdir[j];
> setBatchMode(true);
> processFolder(inputFolder);
> setBatchMode(false);
> }
> }
>
> function processFolder(inputFolder) {
> list = getFileList(inputFolder);
> for (i = 0; i < list.length; i++) {
> processFile(inputFolder, outputFolder, list[i]);
> }
> }
>
> function processFile(inputFolder, outputFolder, file) {
> print("Processing: " + inputFolder + file);
> open(inputFolder + file);
> *run("Image Sequence...", "open=[inputFolder + file] number=18 starting=1
> increment=1 scale=100 file=[] or=[] sort");*
> run("Enhance Contrast", "saturated=0.35");
> run("Apply LUT", "stack");
> setAutoThreshold("Otsu dark");
> setThreshold(60, 255);
> run("Convert to Mask", " ");
>
> print("Saving to: " + outputFolder);
> saveAs("tiff", outputFolder+file);
> close();
> }
>
>
>
> If you could tell me how to open sub-folder as a stack.
>
> Thank you in advance.
>
>
>
> --
> Sent from:
http://imagej.1557.x6.nabble.com/>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>