There ImageJ experts,
I am a beginners in writing macros, I want to perform the following process in ImageJ, but the present macro I have only process a single set of files from the folders and stops even though I have it set up in batch mode 1 Open three different folders with equal number of serialized images 2 Pick images with the same serial number eg, image C_001, B_001, C_001 from folders A, B, C 3 Stack of images picked with the same serial number above, 4 Find the standard deviation of the stack and save as a new image to another directory 5 Repeat steps 1 to 4 until all the images in the folders are processed This is the Macro I presently wrote which does not run all the images requires("1.33s"); dir1 = getDirectory("Choose the Directory for the reference images"); dir2 = getDirectory("Choose the directory for time series images=1"); dir3 = getDirectory("Choose the directory for time series images=2"); dir4 = getDirectory("Choose a directory for Difference images "); Dialog.create("SET UP INPUT PARAMETERS"); Dialog.addMessage("PROVIDE A NAME FOR THE OUTPUT TEXT FILE"); fname = "file name"; Dialog.addString("File Name:", fname); Dialog.addMessage("DATASET IMAGE FILE EXTENSION"); Dialog.addString("Reference Image File Extension:", ".tif"); Dialog.addString("Time Series Image File Extension:", ".tif"); Dialog.addString("Time Series Image File Extension:", ".tif"); Dialog.show(); fname = Dialog.getString(); f = File.open(dir3+fname+".txt"); exten1 = Dialog.getString(); exten2 = Dialog.getString(); exten3 = Dialog.getString(); setBatchMode(true); // prevents display of images list1 = getFileList(dir1); list2 = getFileList(dir2); list3 = getFileList(dir3); count = 0; // Loop over the reference images for (i=0; i<list1.length; i++) { path1 = dir1+list1[i]; open(path1); // Reference Dataset showProgress(count++, list1.length); t1 = getTitle(); IDa = getImageID(); run("Set Scale...", "distance=0 known=1 pixel=1 unit=inch"); // Loop over the time-series images for (j=0; j<list2.length; j++) { path2 = dir2+list2[j]; open(path2); // Time-series Dataset IDb = getImageID(); t2 = getTitle(); run("Set Scale...", "distance=0 known=1 pixel=1 unit=inch"); // Loop over the time-series images for (k=0; k<list3.length; k++) { path3 = dir3+list3[k]; open(path3); // Time-series Dataset IDc = getImageID(); t3 = getTitle(); run("Set Scale...", "distance=0 known=1 pixel=1 unit=inch"); run("Images to Stack"); IDd = getImageID(); run("Z Project...", "start=1 stop=2 projection=[Standard Deviation]"); selectImage(IDd); close(); run("Specify...", "width=512 height=512 x=256 y=256 oval"); run("Measure"); meanstdDev = getResult("Mean", 0); stdDev =getResult("StdDev",0); print(t1+" ,"+t2+" , "+t3+", "+meanstdDev+", "+stdDev); print(f,t1+" ,"+t2+" ,"+t3+", "+meanstdDev+", "+stdDev); run("Select None"); run("Clear Results"); // The name is assigned to the output file outputname = "Stdev_"+t3; rename(outputname); // saveAs("Text Image", dir4+outputname+".txt"); saveAs("Tiff", dir4+outputname+".tif"); IDe = getImageID(); selectImage(IDe); close(); } } } File.close(f) print(count+" files processed"); print("All done"); |
Free forum by Nabble | Edit this page |