Dear GP,
Your macro has no main body from which you call the functions. See for example https://imagej.nih.gov/ij/macros/Arrays.txt . The first 8 lines of code are the main body of the macro followed by some functions. These functions (reverseArray and printArray) are called from within the main body. You have just a collection of functions.
Without any testing it might be possible to just change the first function to main body by changing "function processDir(dir)" to "macro process_Dir" and add "setBatchMode(true);" to this part of the code. But I did not test your code.
Best wishes
Kees
Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and- services/cbs/lite/aif
ImageJ workshops 1 and 2 June 2017: http://www2.le.ac.uk/colleges/medbiopsych/facilities-and- services/cbs/AIF/workshops/ imagej-workshops-June-2017
-----Original Message-----
From: GP [mailto:[hidden email]]
Sent: 30 March 2017 15:53
To: [hidden email]
Subject: Re: Output_Files not Saved in Subfolder when the Subfolder contains Super-subfolders
Hie!
I was not able to find the solution to the problem I encountered probably it's some minor mistake:
The following steps have to be performed in the script:
1. Go through the main Directory
2. Find all the Folders present (Ex: 'test1', 'test2', 'test3'.. etc) 3. In each Folder create a Subfolder (let's call it 'Recrop') 4. Get list of images in each Folder 5. Perform image functions on them and Save output images in respective 'Recrop' subfolders.
6. Go to all 'Recrop' subfolders and create two Super-subfolders 'SuperSub1'
and 'SuperSub2'
7. Get list of images in 'Recrop'
8. Perform two types of image functions and save them respectively in 'SuperSub1' and 'SuperSub2'
The script works fine when executed till step 5 On executing step 6 'SuperSub1' and 'SuperSub2' are created inside 'Recrop'
but the output images from step 5 are not saved in 'Recrop' anymore.
The error might be in the way I am calling the function but I can't figure out how to fix it.
I have attached my macro here:
function processDir(dir) {
listdir = getFileList(dir);
for (j = 0; j < listdir.length; j++) {
outDir = dir+listdir[j]+"Recrop";
File.makeDirectory(outDir);
outpath = outDir+"/";
inDir = dir+listdir[j];
processFolder(inDir); } }
function processFolder(inDir) {
list = getFileList(inDir);
for (i = 0; i < list.length; i++) {
path = inDir+list[i]; //print (path);
processFile(path, outpath); } }
setBatchMode(true);
function processFile(path, outpath){
if (endsWith(path, ".tif")|| endsWith(path, ".TIF")) {
open(path);
Process here...
Title = File.nameWithoutExtension();
saveAs("TIFF", outpath+Title); //doesnt save
images to 'outpath'
close(); } } // on
executing code after this block
function processFolder(recrop){
listrecrop = getFileList(recrop);
for(k=0; k<listrecrop.length; k++) {
path_re = recrop+listrecrop[k];
if (endsWith(path_re, "/")) {
list_recrop = getFileList(recrop);
for(l=0; l<list_recrop.length; l++) {
inpath_re = path_re+list_recrop[l];
outDir_sub1 = path_re+"/"+"SuperSub1";
File.makeDirectory(outDir_sub1);
outpath_sub1= outDir_sub1+"/";
outDir_sub2 = path_re+"/"+"SuperSub2";
File.makeDirectory(outDir_sub2);
outpath_sub2 = outDir_sub2+"/";
processFile(inpath_re, outpath_sub1, outpath_sub2); } } } }
setBatchMode(true);
function processFile(inpath_re, outpath_sub1, outpath_sub2) {
if (endsWith(inpath_re, ".tif")|| endsWith(inpath_re,
".TIF")) {
open(inpath_re);
Process here..
saveAs("TIFF", outpath_sub1);
close(); }
if (endsWith(inpath_re, ".tif")|| endsWith(inpath_re,
".TIF")) {
open(inpath_re);
Process here..
saveAs("TIFF", outpath_sub2);
close(); } }
Thank you so much,
Best Regards,
--
View this message in context: http://imagej.1557.x6.nabble.com/Re-Output-Files-not-Saved- in-Subfolder-when-the- Subfolder-contains-Super- subfolders-tp5018423.html
Sent from the ImageJ mailing list archive at Nabble.com.
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
If you reply to this email, your message will be added to the discussion below:http://imagej.1557.x6.nabble.com/Re-Output-Files-not-Saved- in-Subfolder-when-the- Subfolder-contains-Super- subfolders-tp5018423p5018424. html To unsubscribe from Re: Output_Files not Saved in Subfolder when the Subfolder contains Super-subfolders, click here.
NAML
Free forum by Nabble | Disable Popup Ads | Edit this page |