Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
5 posts
|
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 |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
697 posts
|
Good day!
Maybe the following macro code does what you are after: //////// inputDir = getDirectory("choose the input directory"); listdir = getFileList( inputDir ); for (i = 0; i < listdir.length; i++) { path = inputDir + listdir[i]; if ( File.isDirectory( path ) ) { run("Image Sequence...", "open=" + path + " sort"); } } //////// Regards Herbie :::::::::::::::::::::::::::::::::::: Am 11.11.17 um 11:47 schrieb duerna: > 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 > ... [show rest of quote] -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
5 posts
|
This post was updated on Nov 11, 2017; 12:35pm.
Hi, Herbie
Thank you very much. It's works. Now I could open each sub-folder as a stack, and I add my code, but it only analysis the last stack, and did not give me a .avi saving. here is my code: //////// inputDir = getDirectory("choose the input directory"); outputDir = getDirectory("choose the output directory"); listdir = getFileList( inputDir ); for (i = 0; i < listdir.length; i++) { path = inputDir + listdir[i]; if ( File.isDirectory( path ) ) { run("Image Sequence...", "open=" + path + " 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("AVI", outputFolder+file); close(); } //////// I want set contrast and threshold of all stacks, and save each stacks as .avi into a folder. Would you please give me some suggestion? Best Regards. Duerna -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Disable Popup Ads | Edit this page |