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 as my analysis require, 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.