Dear all,
hereafter I send you a peace of code. I have an image with nuclei. I roughly segment them (this is not a problem) Next I convert the generated ROI's to new images and save them into a specified directory. To keep track of all the images (using the name of the image without the "." and the extension), i used this nice code I got from the list some time ago. But now I would like to batch process whole folders of such images. Usually I simply use the macro "BatchProcess" where I insert a function, but here due to the fact that I call the name of the image this doesn't work. Has someone suggestions about this ? Thank you very much, Fabrice. name = getTitle; dotIndex = indexOf(name, "."); title = substring(name, 0, dotIndex); // Get path to aurelien directory aurelien = getDirectory("aurelien"); if (aurelien=="") exit("No aurelien directory available"); // Create a directory in temp myDir = aurelien+title+File.separator; File.makeDirectory(myDir); if (!File.exists(myDir)) exit("Unable to create directory"); setBatchMode(true); // Segmentation process run("Duplicate...", "title=one.tif"); run("Gaussian Blur...", "sigma=2"); run("Make Binary"); run("Watershed"); run("Analyze Particles...", "size=8000-Infinity circularity=0.00-1.00 show=Nothing exclude clear add"); close(); // Convert ROI's to new images and save to corresponding folder myID = getImageID(); n = roiManager("count"); for (i=0; i<n; i++) { selectImage(myID); roiManager("select", i); run("Copy"); newImage(title+"_"+i+1, "8-bit Black", 400, 400, 1); run("Paste"); saveAs("tiff", myDir+getTitle); close(); run("Select None"); } -- Senger Fabrice ------------------------------------------------------------------------ The original MIME headers for this attachment are: Content-Type: image/tiff; name="stable controle 1.tif" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="stable controle 1.tif" -- Senger Fabrice |
Hi Fabrice,
Have you had a look at the BatchProcessFolders.txt or BatchProcessFolders_onlyTifIn Subfolder.txt macros in the ImageJ macro examples? They layout the basic outline of how to set up a macro to step through the files in a given directory or a set of subdirectories. These examples should be pretty easy to merge into your current code. Cheers, Damon Senger Fabrice wrote: > Dear all, > > hereafter I send you a peace of code. > I have an image with nuclei. > I roughly segment them (this is not a problem) > Next I convert the generated ROI's to new images and save them into a > specified directory. > To keep track of all the images (using the name of the image without > the "." and the extension), i used this nice code I got from the list > some time ago. > But now I would like to batch process whole folders of such images. > Usually I simply use the macro "BatchProcess" where I insert a > function, but here due to the fact that I call the name of the image > this doesn't work. > > Has someone suggestions about this ? > > Thank you very much, > > Fabrice. > > > name = getTitle; > dotIndex = indexOf(name, "."); > title = substring(name, 0, dotIndex); > > > // Get path to aurelien directory > aurelien = getDirectory("aurelien"); > if (aurelien=="") > exit("No aurelien directory available"); > > // Create a directory in temp > myDir = aurelien+title+File.separator; > File.makeDirectory(myDir); > if (!File.exists(myDir)) > exit("Unable to create directory"); > > setBatchMode(true); > > // Segmentation process > > run("Duplicate...", "title=one.tif"); > run("Gaussian Blur...", "sigma=2"); > run("Make Binary"); > run("Watershed"); > run("Analyze Particles...", "size=8000-Infinity circularity=0.00-1.00 > show=Nothing exclude clear add"); > close(); > > // Convert ROI's to new images and save to corresponding folder > > myID = getImageID(); > n = roiManager("count"); > for (i=0; i<n; i++) { > selectImage(myID); > roiManager("select", i); > run("Copy"); > newImage(title+"_"+i+1, "8-bit Black", 400, 400, 1); > run("Paste"); > saveAs("tiff", myDir+getTitle); > close(); > run("Select None"); > > } > -- Damon Poburko, PhD Postdoctoral Research Fellow Stanford University School of Medicine Dept. of Molecular & Cellular Physiology 279 Campus Dr., Beckman B103, Stanford, CA 94305 Ph: 650 725 7564, fax: 650 725 8021 |
Free forum by Nabble | Edit this page |