Hi everyone,
I wanted to ask if there is a possibility to apply the process/batch/macro function to all open images or only a selection of images within a folder? To batch process all images of a folder is somewhat inconvenient for me. cheers, Finn |
Hello,
to me this is a very important point as well. I wrote a plugin called Macro_IO_Settings (http://www.mri.cnrs.fr/index.php?m=82) that allows to setup a list of input files (even if they are in different folders). See page 18 of http://dev.mri.cnrs.fr/attachments/8/remote-imagej-slides.pdf to get an idea of how it looks like. The list is then available from within a plugin. It would be nice if the process/batch/macro could use this or something similar for its input-files. Volker On 14/04/11 13:05, Finn Peters wrote: > Hi everyone, > > I wanted to ask if there is a possibility to apply the > process/batch/macro function to all open images or only a selection of > images within a folder? To batch process all images of a folder is > somewhat inconvenient for me. > > cheers, > Finn |
2011/4/14 Volker Baecker <[hidden email]>:
> Hello, > to me this is a very important point as well. I wrote a plugin called > Macro_IO_Settings (http://www.mri.cnrs.fr/index.php?m=82) that allows to > setup a list of input files (even if they are in different folders). See > page 18 of http://dev.mri.cnrs.fr/attachments/8/remote-imagej-slides.pdf > to get an idea of how it looks like. > The list is then available from within a plugin. It would be nice if the > process/batch/macro could use this or something similar for its input-files. > Volker You could do it with python: walk a directory and its subdirectories, inspect each file name and decide if you run the macro, command or plugin on it. In Fiji, open the "File - New - Script", select "Language - Python", and type something like: import os folder = "/path/to/folder" for root, dirs, files in os.walk(folder): for filename in files: if -1 = filename.find("path-of-the-name-we-want"): imp = IJ.openImage(root + "/" + filename) IJ.run(imp, "Gaussian Blur...", "sigma=2") IJ.save(imp, "/new/path/to/" + filename) Each file of the folder and all its subfolders will be walked. At each iteration, the root and the files are given, and also any present subdirectories of root (the "dirs"). Albert -- http://albert.rierol.net |
In reply to this post by Finn Peters
The macro language can get a list of all files in a directory (and can search directories recursively). We use this to, for example, process all files ending with ".tif" or to process all the "red#####" files one way and "green#######" another way. For an idea how to implement, start by looking at look at getDirectory(string) at http://rsbweb.nih.gov/ij/developer/macro/functions.html
Cheers, Michael -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Finn Peters Sent: Thursday, April 14, 2011 7:06 AM To: [hidden email] Subject: batch processing for a selection of images Hi everyone, I wanted to ask if there is a possibility to apply the process/batch/macro function to all open images or only a selection of images within a folder? To batch process all images of a folder is somewhat inconvenient for me. cheers, Finn ------------------------------------------------------------ This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email. ================================= |
In reply to this post by Finn Peters
Hi Finn,
if you want to do some processing for all images open in ImageJ, you can use a very simple macro: for (i=1; i<=nImages; i++) { selectImage(i); processImage(); //or simply put your processing commands here. } function processImage() { run("Smooth"); //or whatever operation(s) you like... //Make sure you leave no new images open, //and don't close the current image. } Michael ________________________________________________________________ On 14 Apr 2011, at 13:05, Finn Peters wrote: > Hi everyone, > > I wanted to ask if there is a possibility to apply the process/ > batch/macro function to all open images or only a selection of > images within a folder? To batch process all images of a folder is > somewhat inconvenient for me. > > cheers, > Finn |
Hello, What if operating with all the files within a directory, you want to
separate the channels and make compositions? you should have to identify the new windows and include in the macro to continue operating... in my case I want to separate the channels of all the files within a directory, and make those compositions On 14 April 011 15:13, Michael Schmid <[hidden email]> wrote: > Hi Finn, > > if you want to do some processing for all images open in ImageJ, you can > use a very simple macro: > > for (i=1; i<=nImages; i++) { > selectImage(i); > processImage(); //or simply put your processing commands here. > } > > function processImage() { > run("Smooth"); > //or whatever operation(s) you like... > //Make sure you leave no new images open, > //and don't close the current image. > } > > Michael > ________________________________________________________________ > > > On 14 Apr 2011, at 13:05, Finn Peters wrote: > > Hi everyone, >> >> I wanted to ask if there is a possibility to apply the process/batch/macro >> function to all open images or only a selection of images within a folder? >> To batch process all images of a folder is somewhat inconvenient for me. >> >> cheers, >> Finn >> > |
2011/4/14 Ramon <[hidden email]>:
> Hello, What if operating with all the files within a directory, you want to > separate the channels and make compositions? you should have to identify the > new windows and include in the macro to continue operating... in my case I > want to separate the channels of all the files within a directory, and make > those compositions Then don't use a macro. Macros work best for recording a sequence of commands and then wrapping that in a loop and apply it to many images or many slices of an image. If your macro opens new windows, its complexity will escalate very quickly--it's all related to the central concept of the "current image" in ImageJ. When the current image changes in an unpredictable way, it's time to use something other than a macro. For example, use a plugin instead, or a script in python that gives you the same power of a plugin without having to compile or care about class types. Albert -- http://albert.rierol.net |
In reply to this post by melkor2.0
Hi Ramon,
no problem, you can easily adapt the macro for the case that you want to create new windows: imgArray = newArray(nImages); for (i=0; i<nImages; i++) { selectImage(i+1); imgArray[i] = getImageID(); } //now we have a list of all open images, we can work on it: for (i=0; i< imgArray.length; i++) { selectImage(imgArray[i]); //do whatever you like, whether it creates new images or not. //e.g. if (nSlices() > 1) run("Make Montage..."); } Michael ________________________________________________________________ On 14 Apr 2011, at 15:21, Ramon wrote: > Hello, What if operating with all the files within a directory, you > want to > separate the channels and make compositions? you should have to > identify the > new windows and include in the macro to continue operating... in my > case I > want to separate the channels of all the files within a directory, > and make > those compositions > > On 14 April 011 15:13, Michael Schmid <[hidden email]> wrote: > >> Hi Finn, >> >> if you want to do some processing for all images open in ImageJ, >> you can >> use a very simple macro: >> >> for (i=1; i<=nImages; i++) { >> selectImage(i); >> processImage(); //or simply put your processing commands here. >> } >> >> function processImage() { >> run("Smooth"); >> //or whatever operation(s) you like... >> //Make sure you leave no new images open, >> //and don't close the current image. >> } >> >> Michael >> ________________________________________________________________ >> >> >> On 14 Apr 2011, at 13:05, Finn Peters wrote: >> >> Hi everyone, >>> >>> I wanted to ask if there is a possibility to apply the process/ >>> batch/macro >>> function to all open images or only a selection of images within >>> a folder? >>> To batch process all images of a folder is somewhat inconvenient >>> for me. >>> >>> cheers, >>> Finn >>> >> |
In reply to this post by Michael Schmid
Hi Michael,
thanks a lot, this is just what I was looking for. cheers, Finn > Hi Finn, > > if you want to do some processing for all images open in ImageJ, you > can use a very simple macro: > > for (i=1; i<=nImages; i++) { > selectImage(i); > processImage(); //or simply put your processing commands here. > } > > function processImage() { > run("Smooth"); > //or whatever operation(s) you like... > //Make sure you leave no new images open, > //and don't close the current image. > } > > Michael > ________________________________________________________________ > > On 14 Apr 2011, at 13:05, Finn Peters wrote: > >> Hi everyone, >> >> I wanted to ask if there is a possibility to apply the >> process/batch/macro function to all open images or only a selection >> of images within a folder? To batch process all images of a folder is >> somewhat inconvenient for me. >> >> cheers, >> Finn > |
Free forum by Nabble | Edit this page |